summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLincoln Ramsay <lincoln.ramsay@nokia.com>2012-05-28 12:20:22 +1000
committerQt by Nokia <qt-info@nokia.com>2012-05-28 04:58:45 +0200
commitdd14ea8acf97103868d6dfcafb7b19275e605e97 (patch)
tree74ac18db8f907e2d6e58500c9601cf8dc28ffbfc /src
parent7d54123daa2080f96c7d74f58125141555832b09 (diff)
Check for Q_GLOBAL_STATIC returning 0 (Sensor Gestures).
It's probably not very likely but during app shutdown, the Q_GLOBAL_STATIC used in sensor gestures will start returning 0. Check for this to avoid the chance of a crash. Change-Id: I4b538ac9b9535bd9439a897d4eab51211c523e33 Reviewed-by: Lorn Potter <lorn.potter@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/sensors/gestures/qsensorgesturemanager.cpp19
-rw-r--r--src/sensors/gestures/qsensorgesturemanagerprivate.cpp5
2 files changed, 19 insertions, 5 deletions
diff --git a/src/sensors/gestures/qsensorgesturemanager.cpp b/src/sensors/gestures/qsensorgesturemanager.cpp
index 20cdb34d..d85051ad 100644
--- a/src/sensors/gestures/qsensorgesturemanager.cpp
+++ b/src/sensors/gestures/qsensorgesturemanager.cpp
@@ -68,7 +68,9 @@ QT_BEGIN_NAMESPACE
QSensorGestureManager::QSensorGestureManager(QObject *parent)
: QObject(parent)
{
- connect(QSensorGestureManagerPrivate::instance(),SIGNAL(newSensorGestureAvailable()),
+ QSensorGestureManagerPrivate *d = QSensorGestureManagerPrivate::instance();
+ if (!d) return; // hardly likely but just in case...
+ connect(d,SIGNAL(newSensorGestureAvailable()),
this,SIGNAL(newSensorGestureAvailable()));
}
@@ -89,7 +91,12 @@ QSensorGestureManager::~QSensorGestureManager()
bool QSensorGestureManager::registerSensorGestureRecognizer(QSensorGestureRecognizer *recognizer)
{
- bool ok = QSensorGestureManagerPrivate::instance()->registerSensorGestureRecognizer(recognizer);
+ QSensorGestureManagerPrivate *d = QSensorGestureManagerPrivate::instance();
+ if (!d) { // hardly likely but just in case...
+ delete recognizer;
+ return false;
+ }
+ bool ok = d->registerSensorGestureRecognizer(recognizer);
if (!ok)
delete recognizer;
@@ -103,7 +110,9 @@ QSensorGestureManager::~QSensorGestureManager()
*/
QStringList QSensorGestureManager::gestureIds() const
{
- return QSensorGestureManagerPrivate::instance()->gestureIds();
+ QSensorGestureManagerPrivate *d = QSensorGestureManagerPrivate::instance();
+ if (!d) return QStringList(); // hardly likely but just in case...
+ return d->gestureIds();
}
/*!
@@ -123,7 +132,9 @@ QSensorGestureManager::~QSensorGestureManager()
*/
QSensorGestureRecognizer *QSensorGestureManager::sensorGestureRecognizer(const QString &id)
{
- return QSensorGestureManagerPrivate::instance()->sensorGestureRecognizer(id);
+ QSensorGestureManagerPrivate *d = QSensorGestureManagerPrivate::instance();
+ if (!d) return 0; // hardly likely but just in case...
+ return d->sensorGestureRecognizer(id);
}
QT_END_NAMESPACE
diff --git a/src/sensors/gestures/qsensorgesturemanagerprivate.cpp b/src/sensors/gestures/qsensorgesturemanagerprivate.cpp
index 5e2089a9..fc22dc7c 100644
--- a/src/sensors/gestures/qsensorgesturemanagerprivate.cpp
+++ b/src/sensors/gestures/qsensorgesturemanagerprivate.cpp
@@ -236,7 +236,10 @@ void QSensorGestureManagerPrivate::recognizerStopped(const QSensorGestureRecogni
QSensorGestureManagerPrivate * QSensorGestureManagerPrivate::instance()
{
- return sensorGestureManagerPrivate();
+ QSensorGestureManagerPrivate *priv = sensorGestureManagerPrivate();
+ // It's safe to return 0 because this is checked when used
+ //if (!priv) qFatal("Cannot return from QSensorGestureManagerPrivate::instance() because sensorGestureManagerPrivate() returned 0.");
+ return priv;
}