summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/ios
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2015-11-18 09:01:51 +0100
committerLiang Qi <liang.qi@theqtcompany.com>2015-11-18 09:01:51 +0100
commitc7934f2489e2eb9a539206bab35f335b1943c5bd (patch)
treea27d0ed6c001fe9432e2a0f28fb935acf9e4c65f /src/plugins/platforms/ios
parentf40593b11199fbef886bfcb6b210a214d8c3adf3 (diff)
parent08f9a1bd6ab9b1777ee5ba163d75e5c848c39eb4 (diff)
Merge remote-tracking branch 'origin/5.6' into dev
Conflicts: src/corelib/io/qprocess.cpp src/corelib/io/qprocess_unix.cpp src/network/kernel/qnetworkinterface_winrt.cpp tools/configure/configureapp.cpp Change-Id: I47df00a01597d2e63b334b492b3b4221b29f58ea
Diffstat (limited to 'src/plugins/platforms/ios')
-rw-r--r--src/plugins/platforms/ios/qiosfileengineassetslibrary.mm40
1 files changed, 26 insertions, 14 deletions
diff --git a/src/plugins/platforms/ios/qiosfileengineassetslibrary.mm b/src/plugins/platforms/ios/qiosfileengineassetslibrary.mm
index 761a89c989..bb12c164d6 100644
--- a/src/plugins/platforms/ios/qiosfileengineassetslibrary.mm
+++ b/src/plugins/platforms/ios/qiosfileengineassetslibrary.mm
@@ -48,20 +48,29 @@ static QThreadStorage<QPointer<QIOSAssetData> > g_assetDataCache;
static const int kBufferSize = 10;
static ALAsset *kNoAsset = 0;
-static void ensureAuthorizationDialogNotBlocked()
+static bool ensureAuthorizationDialogNotBlocked()
{
if ([ALAssetsLibrary authorizationStatus] != ALAuthorizationStatusNotDetermined)
- return;
+ return true;
+
if (static_cast<QCoreApplicationPrivate *>(QObjectPrivate::get(qApp))->in_exec)
- return;
-
- // Since authorization status has not been determined, the user will be asked
- // to authorize the app. But since main has not finished, the dialog will be held
- // back until the launch completes. To avoid a dead-lock below, we start an event
- // loop to complete the launch.
- QEventLoop loop;
- QTimer::singleShot(1, &loop, &QEventLoop::quit);
- loop.exec();
+ return true;
+
+ if ([NSThread isMainThread]) {
+ // The dialog is about to show, but since main has not finished, the dialog will be held
+ // back until the launch completes. This is problematic since we cannot successfully return
+ // back to the caller before the asset is ready, which also includes showing the dialog. To
+ // work around this, we create an event loop to that will complete the launch (return from the
+ // applicationDidFinishLaunching callback). But this will only work if we're on the main thread.
+ QEventLoop loop;
+ QTimer::singleShot(1, &loop, &QEventLoop::quit);
+ loop.exec();
+ } else {
+ NSLog(@"QIOSFileEngine: unable to show assets authorization dialog from non-gui thread before QApplication is executing.");
+ return false;
+ }
+
+ return true;
}
// -------------------------------------------------------------------------
@@ -80,8 +89,10 @@ public:
, m_writeIndex(0)
, m_nextAssetReady(false)
{
- ensureAuthorizationDialogNotBlocked();
- startEnumerate();
+ if (!ensureAuthorizationDialogNotBlocked())
+ writeAsset(kNoAsset);
+ else
+ startEnumerate();
}
~QIOSAssetEnumerator()
@@ -186,7 +197,8 @@ public:
, m_assetUrl(assetUrl)
, m_assetLibrary(0)
{
- ensureAuthorizationDialogNotBlocked();
+ if (!ensureAuthorizationDialogNotBlocked())
+ return;
if (QIOSAssetData *assetData = g_assetDataCache.localData()) {
// It's a common pattern that QFiles pointing to the same path are created and destroyed