diff options
author | Alex Blasche <alexander.blasche@digia.com> | 2014-03-04 16:17:09 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-03-11 10:59:16 +0100 |
commit | 2d2dbd3199a10985c713e97d32688e001e4cb226 (patch) | |
tree | 62e1e34a4507d218ce58f9659c17e73bc9e5ca80 /src/bluetooth/android/androidbroadcastreceiver_p.h | |
parent | 54ba9be8850dc7fbeb7151ed5579a22965851008 (diff) |
Android: Fix crashes due to concurrency issues
BroadcastReceiver.onReceive() is executed in the main thread whereas
the Qt classes are in a different thread. This created issues whereby
Java's qtObject pointer was reset by the Qt classes/thread but
onReceive still trying to access the same object later on.
In most cases the Qt classes using BroadcastReceiver were half way
through their object tear down. This patch fixes the problem by
guarding qtObject against concurrent thread access and ensures that
the qtObject pointer is reset before the object tear down starts.
Change-Id: Iab97b0af8e10686d97419ac8504f2fe69e9536f3
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
Diffstat (limited to 'src/bluetooth/android/androidbroadcastreceiver_p.h')
-rw-r--r-- | src/bluetooth/android/androidbroadcastreceiver_p.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/bluetooth/android/androidbroadcastreceiver_p.h b/src/bluetooth/android/androidbroadcastreceiver_p.h index 303e4ae8..58c2b40b 100644 --- a/src/bluetooth/android/androidbroadcastreceiver_p.h +++ b/src/bluetooth/android/androidbroadcastreceiver_p.h @@ -60,12 +60,12 @@ public: void addAction(const QAndroidJniObject &filter); bool isValid() const; + void unregisterReceiver(); protected: friend void QtBroadcastReceiver_jniOnReceive(JNIEnv *, jobject, jlong, jobject, jobject); virtual void onReceive(JNIEnv *env, jobject context, jobject intent) = 0; - void unregisterReceiver(); QAndroidJniObject activityObject; QAndroidJniObject intentFilterObject; |