From 60a911096f04b5159b99ad444bc9ad9aedf42eb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Str=C3=B8mme?= Date: Thu, 3 Apr 2014 17:26:05 +0200 Subject: [PATCH] Android: Use QMutexLock in camera callbacks. We should not release the locks before the native callbacks returns. Change-Id: Ia2691f6c5be66a3dcf371e48e3bac7498b401833 Reviewed-by: Yoann Lopes --- src/plugins/android/src/wrappers/jcamera.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/plugins/android/src/wrappers/jcamera.cpp b/src/plugins/android/src/wrappers/jcamera.cpp index b0e9f89f..f43e2308 100644 --- a/src/plugins/android/src/wrappers/jcamera.cpp +++ b/src/plugins/android/src/wrappers/jcamera.cpp @@ -82,27 +82,24 @@ static QJNIObjectPrivate rectToArea(const QRect &rect) // native method for QtCamera.java static void notifyAutoFocusComplete(JNIEnv* , jobject, int id, jboolean success) { - g_objectMapMutex.lock(); + QMutexLocker locker(&g_objectMapMutex); JCamera *obj = g_objectMap.value(id, 0); - g_objectMapMutex.unlock(); if (obj) Q_EMIT obj->autoFocusComplete(success); } static void notifyPictureExposed(JNIEnv* , jobject, int id) { - g_objectMapMutex.lock(); + QMutexLocker locker(&g_objectMapMutex); JCamera *obj = g_objectMap.value(id, 0); - g_objectMapMutex.unlock(); if (obj) Q_EMIT obj->pictureExposed(); } static void notifyPictureCaptured(JNIEnv *env, jobject, int id, jbyteArray data) { - g_objectMapMutex.lock(); + QMutexLocker locker(&g_objectMapMutex); JCamera *obj = g_objectMap.value(id, 0); - g_objectMapMutex.unlock(); if (obj) { QByteArray bytes; int arrayLength = env->GetArrayLength(data); @@ -114,9 +111,8 @@ static void notifyPictureCaptured(JNIEnv *env, jobject, int id, jbyteArray data) static void notifyFrameFetched(JNIEnv *env, jobject, int id, jbyteArray data) { - g_objectMapMutex.lock(); + QMutexLocker locker(&g_objectMapMutex); JCamera *obj = g_objectMap.value(id, 0); - g_objectMapMutex.unlock(); if (obj) { QByteArray bytes; int arrayLength = env->GetArrayLength(data);