diff options
author | Bernd Weimer <bweimer@rim.com> | 2012-12-03 14:19:45 +0100 |
---|---|---|
committer | Thomas McGuire <thomas.mcguire@kdab.com> | 2012-12-03 14:48:19 +0100 |
commit | 561a0072e85815d48f49658adb2a1b7ce6959e96 (patch) | |
tree | f467232cdba9c824e273b6ba8207966f0ebfe905 | |
parent | 84217d0eaa98349f59b6c4dd9dd94c5122fb9189 (diff) |
BlackBerry: Fix for setting a new sensor device file
When a new sensor device file is set, the old one has to be closed
properly and the new one has to be initialized appropriately.
Change-Id: Ie0b1b7a9e21ee349c9c2873c9ba45e0432ccdea5
Reviewed-by: Thomas McGuire <thomas.mcguire@kdab.com>
-rw-r--r-- | plugins/sensors/blackberry/bbsensorbackend.cpp | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/plugins/sensors/blackberry/bbsensorbackend.cpp b/plugins/sensors/blackberry/bbsensorbackend.cpp index 3b6b581096..4bace8a808 100644 --- a/plugins/sensors/blackberry/bbsensorbackend.cpp +++ b/plugins/sensors/blackberry/bbsensorbackend.cpp @@ -113,15 +113,17 @@ sensor_type_e BbSensorBackendBase::sensorType() const void BbSensorBackendBase::setDevice(const QString &deviceFile, sensor_type_e sensorType) { - const bool isActive = m_deviceFile.isOpen(); - if (isActive) - stop(); - - m_sensorType = sensorType; - m_deviceFile.setFileName(deviceFile); - - if (isActive) - start(); + if (deviceFile != m_deviceFile.fileName()) { + setPaused(true); + delete m_socketNotifier.take(); + m_deviceFile.close(); + + m_sensorType = sensorType; + m_deviceFile.setFileName(deviceFile); + initSensorInfo(); + if (m_started) + start(); // restart with new device file + } } void BbSensorBackendBase::initSensorInfo() |