From a2f9f25d8577fefe8358eb848da206e5ebdf4178 Mon Sep 17 00:00:00 2001 From: Tobias Koenig Date: Wed, 23 Oct 2013 18:04:58 +0200 Subject: [PATCH] Blackberry: Fix camera viewfinder Enter the event loop between opening the camera and starting the viewfinder window grabber. The latter needs a windowGroup set, so in case the QCamera and QCameraViewfinder are constructed directly/indirectly inside the main window constructor, we have to wait for the top-level window of the application to be created, so that we can retrieve the windowGroup from it. Task-number: QTBUG-33739 Change-Id: Ib23781f0e4a2a07ba388e22debcb59b00509ed16 Reviewed-by: Rafael Roquetto Reviewed-by: Fabian Bumberger Reviewed-by: Tobias Koenig Reviewed-by: Sean Harmer --- src/plugins/blackberry/camera/bbcamerasession.cpp | 14 ++++++-------- src/plugins/blackberry/camera/bbcamerasession.h | 2 +- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/plugins/blackberry/camera/bbcamerasession.cpp b/src/plugins/blackberry/camera/bbcamerasession.cpp index 8f8e666d..0185dccb 100644 --- a/src/plugins/blackberry/camera/bbcamerasession.cpp +++ b/src/plugins/blackberry/camera/bbcamerasession.cpp @@ -165,10 +165,8 @@ void BbCameraSession::setState(QCamera::State state) } } else if (state == QCamera::ActiveState) { if (openCamera()) { - applyConfiguration(); - if (startViewFinder()) { - m_state = state; - } + QMetaObject::invokeMethod(this, "applyConfiguration", Qt::QueuedConnection); + m_state = state; } } } else if (previousState == QCamera::LoadedState) { @@ -176,10 +174,8 @@ void BbCameraSession::setState(QCamera::State state) closeCamera(); m_state = state; } else if (state == QCamera::ActiveState) { - applyConfiguration(); - if (startViewFinder()) { - m_state = state; - } + QMetaObject::invokeMethod(this, "applyConfiguration", Qt::QueuedConnection); + m_state = state; } } else if (previousState == QCamera::ActiveState) { if (state == QCamera::LoadedState) { @@ -1157,6 +1153,8 @@ void BbCameraSession::applyConfiguration() } else if (m_captureMode & QCamera::CaptureVideo) { applyVideoSettings(); } + + startViewFinder(); } static void videoRecordingStatusCallback(camera_handle_t handle, camera_devstatus_t status, uint16_t value, void *context) diff --git a/src/plugins/blackberry/camera/bbcamerasession.h b/src/plugins/blackberry/camera/bbcamerasession.h index f57c7dab..f226d424 100644 --- a/src/plugins/blackberry/camera/bbcamerasession.h +++ b/src/plugins/blackberry/camera/bbcamerasession.h @@ -176,13 +176,13 @@ private slots: void deviceOrientationChanged(int); void handleCameraPowerUp(); void viewfinderFrameGrabbed(const QImage &image); + void applyConfiguration(); private: bool openCamera(); void closeCamera(); bool startViewFinder(); void stopViewFinder(); - void applyConfiguration(); bool startVideoRecording(); void stopVideoRecording();