Permalink
Browse files

Update Camera Samples - remove ForeignWindowControl race condition wo…

…rkaround
  • Loading branch information...
1 parent 42d7e66 commit 057ef88cb8bcf535403ef4abd7ce0ba8c01cb204 Sean McVeigh committed Dec 12, 2012
Showing with 3 additions and 27 deletions.
  1. +0 −17 HelloCamera/src/hellocameraapp.cpp
  2. +3 −10 HelloVideoCamera/src/hellovideocameraapp.cpp
@@ -30,11 +30,6 @@
using namespace bb::cascades;
-// define this to debug the ForeignWindowControl race condition
-#define BREAK_FWC
-// define this to enable a workaround for the above race condition
-//#define WORKAROUND_FWC
-
HelloCameraApp::HelloCameraApp(bb::cascades::Application *app) :
QObject(app),
mCameraHandle(CAMERA_HANDLE_INVALID)
@@ -102,28 +97,16 @@ void HelloCameraApp::onWindowAttached(screen_window_t win,
const QString &group,
const QString &id)
{
-#ifdef BREAK_FWC
- // typically a value of 1ms will cause the window to only be visible the
- // first time you start it. on subsequent invocations, it does not become visible
- // unless you force a refresh of the cascades window.
- // a value of 10 ms seems to expose the problem every time.
- usleep(10000);
-#endif
qDebug() << "onWindowAttached: " << win << ", " << group << ", " << id;
// set screen properties to mirror if this is the front-facing camera
int i = (mCameraUnit == CAMERA_UNIT_FRONT);
screen_set_window_property_iv(win, SCREEN_PROPERTY_MIRROR, &i);
// put the viewfinder window behind the cascades window
i = -1;
screen_set_window_property_iv(win, SCREEN_PROPERTY_ZORDER, &i);
-#ifdef WORKAROUND_FWC
- mViewfinderWindow->setVisible(false);
- mViewfinderWindow->setVisible(true);
-#endif
screen_context_t screen_ctx;
screen_get_window_property_pv(win, SCREEN_PROPERTY_CONTEXT, (void **)&screen_ctx);
screen_flush_context(screen_ctx, 0);
-
}
@@ -31,9 +31,6 @@
using namespace bb::cascades;
-// workaround a ForeignWindowControl race condition
-#define WORKAROUND_FWC
-
HelloVideoCameraApp::HelloVideoCameraApp(bb::cascades::Application *app) :
mCameraHandle(CAMERA_HANDLE_INVALID),
@@ -113,13 +110,9 @@ void HelloVideoCameraApp::onWindowAttached(screen_window_t win,
// put the viewfinder window behind the cascades window
i = -1;
screen_set_window_property_iv(win, SCREEN_PROPERTY_ZORDER, &i);
-#ifdef WORKAROUND_FWC
- // seems we still need a workaround in R9 for a potential race due to
- // ForeignWindowControl updating/flushing the window's properties in
- // parallel with the execution of the onWindowAttached() handler.
- mViewfinderWindow->setVisible(false);
- mViewfinderWindow->setVisible(true);
-#endif
+ screen_context_t screen_ctx;
+ screen_get_window_property_pv(win, SCREEN_PROPERTY_CONTEXT, (void **)&screen_ctx);
+ screen_flush_context(screen_ctx, 0);
}

0 comments on commit 057ef88

Please sign in to comment.