summaryrefslogtreecommitdiffstats
path: root/src/sensors
diff options
context:
space:
mode:
authorLorn Potter <lorn.potter@jollamobile.com>2014-07-07 16:58:22 +1000
committerLorn Potter <lorn.potter@jollamobile.com>2014-07-10 21:58:02 +0200
commit9f377d1fa286817a17a5e5de3786a2d73aeaa822 (patch)
treeaecefd0f3e6e9f8b74420af1e0ce558ef47fb8f0 /src/sensors
parent044486f8b41b9ae7bdfad838be79ec5b2782fed5 (diff)
Series of crash fixes from Mer, squashed
1)tracing plugin loading 2)m_remoteSensorManager can be nullptr But it seems it does not solve incorrect initialization in the case manager interface is nullptr: init() for different sensors does not check initDone 3)split initSensor() to template function and function most of initSensor() does not depend on template param, so it is better to split it -> less code should be generated 4)do not use sensor manager if it is invalid 5)correct class members initialization order 6)assert sensor interface is not null From what I saw according to logic it should not happen so using Q_ASSERT for better maintainability 7)check local interface pointer in SensorfwTapSensor::start() Signed-off-by: Denis Zalevskiy <denis.zalevskiy@jolla.com> Change-Id: I5c1bf3999ad2268c0dba9b3fe511d999c2e63fd9 Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
Diffstat (limited to 'src/sensors')
-rw-r--r--src/sensors/qsensormanager.cpp28
1 files changed, 23 insertions, 5 deletions
diff --git a/src/sensors/qsensormanager.cpp b/src/sensors/qsensormanager.cpp
index 29bd4b5f..abe5f853 100644
--- a/src/sensors/qsensormanager.cpp
+++ b/src/sensors/qsensormanager.cpp
@@ -48,12 +48,15 @@
#include "sensorlog_p.h"
#include <QTimer>
#include <QFile>
+#include <QLoggingCategory>
QT_BEGIN_NAMESPACE
typedef QHash<QByteArray,QSensorBackendFactory*> FactoryForIdentifierMap;
typedef QHash<QByteArray,FactoryForIdentifierMap> BackendIdentifiersForTypeMap;
+static QLoggingCategory sensorsCategory("qt.sensors");
+
class QSensorManagerPrivate : public QObject
{
friend class QSensorManager;
@@ -77,7 +80,6 @@ public:
loadExternalPlugins = false;
}
}
-
bool loadExternalPlugins;
PluginLoadingState pluginLoadingState;
QFactoryLoader *loader;
@@ -101,9 +103,16 @@ public:
if (config.isEmpty()) return; // QStandardPaths is broken?
config += QLatin1String("/QtProject/Sensors.conf");
#endif
- if (!QFile::exists(config)) return;
+ qCDebug(sensorsCategory) << "Loading config from" << config;
+ if (!QFile::exists(config)) {
+ qCWarning(sensorsCategory) << "There is no config file" << config;
+ return;
+ }
QFile cfgfile(config);
- if (!cfgfile.open(QFile::ReadOnly)) return;
+ if (!cfgfile.open(QFile::ReadOnly)) {
+ qCWarning(sensorsCategory) << "Can't open config file" << config;
+ return;
+ }
QTextStream stream(&cfgfile);
QString line;
@@ -169,13 +178,19 @@ Q_GLOBAL_STATIC(QSensorManagerPrivate, sensorManagerPrivate)
static void initPlugin(QObject *o)
{
- if (!o) return;
+ qCDebug(sensorsCategory) << "Init plugin" << o;
+ if (!o) {
+ qCWarning(sensorsCategory) << "Null plugin" << o;
+ return;
+ }
QSensorManagerPrivate *d = sensorManagerPrivate();
if (!d) return; // hardly likely but just in case...
- if (d->seenPlugins.contains(o))
+ if (d->seenPlugins.contains(o)) {
+ qCDebug(sensorsCategory) << "Plugin is seen" << o;
return;
+ }
QSensorChangesInterface *changes = qobject_cast<QSensorChangesInterface*>(o);
if (changes)
@@ -184,8 +199,11 @@ static void initPlugin(QObject *o)
QSensorPluginInterface *plugin = qobject_cast<QSensorPluginInterface*>(o);
if (plugin) {
+ qCDebug(sensorsCategory) << "Register sensors for " << plugin;
d->seenPlugins.insert(o);
plugin->registerSensors();
+ } else {
+ qCWarning(sensorsCategory) << "Can't cast to plugin" << o;
}
}