diff options
author | Lincoln Ramsay <lincoln.ramsay@nokia.com> | 2012-04-16 14:54:23 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-04-20 05:12:51 +0200 |
commit | 7628b8de96bc1de3f97d1ea2e4519139a4937f8a (patch) | |
tree | 438ad46d2b0fc9223f6975cf91933ca604feaa6f /src | |
parent | 01fea6e0d5a0ef709c1660e2420a842b90e6f85f (diff) |
Changes so that sensor.start() does not block (QML)
The C++ library tries to delay things as much as possible. It turns
out that doing this for QML is not optimal because it means calling
sensor.start() can block for a long time (up to hundreds of
milliseconds in worst case scenarious). If the sensor is started
after the UI is visible, this will cause a stutter.
The workaround is not particularly elegant. We force the sensors
library to do its setup while the QML plugin is being loaded.
Change-Id: Iae945ccb79eb568c5decbfdf8a5d623cd96e9d6b
Reviewed-by: Zsolt Simon <zsolt.simon@nokia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/imports/sensors/sensors.cpp | 3 | ||||
-rw-r--r-- | src/imports/sensors2/sensors2.cpp | 5 |
2 files changed, 7 insertions, 1 deletions
diff --git a/src/imports/sensors/sensors.cpp b/src/imports/sensors/sensors.cpp index b81bdd3d..f65af6a2 100644 --- a/src/imports/sensors/sensors.cpp +++ b/src/imports/sensors/sensors.cpp @@ -106,6 +106,9 @@ public: int major; int minor; + // Force all of the sensors initialization to happen now, while we don't have a UI thread to interrupt + (void)QSensor::sensorTypes(); + // Register the 1.1 interfaces major = 1; minor = 1; diff --git a/src/imports/sensors2/sensors2.cpp b/src/imports/sensors2/sensors2.cpp index ebcefcfb..190ecde0 100644 --- a/src/imports/sensors2/sensors2.cpp +++ b/src/imports/sensors2/sensors2.cpp @@ -57,8 +57,11 @@ public: virtual void registerTypes(const char *uri) { qDebug() << "QSensors2DeclarativeModule::registerTypes(const char *uri)"; - Q_ASSERT(QLatin1String(uri) == QLatin1String("QtSensors")); + + // Force all of the sensors initialization to happen now, while we don't have a UI thread to interrupt + (void)QSensor::sensorTypes(); + qmlRegisterUncreatableType<qsensor2common >(uri, 5, 0, "Sensor", QLatin1String("Cannot create Sensor")); qmlRegisterType <QSensor2Tilt >(uri, 5, 0, "TiltSensor"); qmlRegisterType <QSensor2AmbientLight>(uri, 5, 0, "AmbientLightSensor"); |