diff -r e4ebb16b39ea -r 603d3f8b6302 src/sensors/qsensormanager.cpp --- a/src/sensors/qsensormanager.cpp Fri Sep 17 08:34:34 2010 +0300 +++ b/src/sensors/qsensormanager.cpp Mon Oct 04 01:37:06 2010 +0300 @@ -227,6 +227,8 @@ This is set in a config file and can be overridden if required. If no default is available the system will return the first registered sensor for \a type. + + \sa {Determining the default sensor for a type} */ QByteArray QSensor::defaultSensorForType(const QByteArray &type) { @@ -238,7 +240,14 @@ if (!d->backendsByType.contains(type)) return QByteArray(); - QSettings settings(QLatin1String("Nokia"), QLatin1String("Sensors")); + QSettings::Scope scope; +#ifdef QTM_BUILD_UNITTESTS + // The unit test needs to modify Sensors.conf but it can't access the system directory + scope = QSettings::UserScope; +#else + scope = QSettings::SystemScope; +#endif + QSettings settings(scope, QLatin1String("Nokia"), QLatin1String("Sensors")); QVariant value = settings.value(QString(QLatin1String("Default/%1")).arg(QString::fromLatin1(type))); if (!value.isNull()) { QByteArray defaultIdentifier = value.toByteArray();