summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/android/qandroidassetsfileenginehandler.cpp
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>2014-03-12 12:48:19 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-15 10:45:36 +0100
commit287fa94fe2f93e2857a4c15f69435c4ea14de82e (patch)
tree2ff53f815d8f58e89afc6d39ccc31e6a9da463fb /src/plugins/platforms/android/qandroidassetsfileenginehandler.cpp
parentde5185472651a6051a3c7b6e2519cc5f2b951a62 (diff)
Android: Fix another "QApplication not on main() thread" crash
The assets file engine is created before main() is called, thus prepopulate was called before main(). In this function, we created a QDataStream which internally created a QBuffer which inherits from QObject. This caused the main thread pointer to be initialized early, and the old "QApplication is not on the main() thread" warning and crash returned. The fix is to prepopulate the first time the file engine is used instead. Task-number: QTBUG-37444 Change-Id: I2c6e5f1a8ca88b5dc7d8e145fffeb7587dc0e623 Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com>
Diffstat (limited to 'src/plugins/platforms/android/qandroidassetsfileenginehandler.cpp')
-rw-r--r--src/plugins/platforms/android/qandroidassetsfileenginehandler.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/plugins/platforms/android/qandroidassetsfileenginehandler.cpp b/src/plugins/platforms/android/qandroidassetsfileenginehandler.cpp
index b112e265a5..4968b8f188 100644
--- a/src/plugins/platforms/android/qandroidassetsfileenginehandler.cpp
+++ b/src/plugins/platforms/android/qandroidassetsfileenginehandler.cpp
@@ -262,17 +262,20 @@ private:
AndroidAssetsFileEngineHandler::AndroidAssetsFileEngineHandler()
: m_assetsCache(std::max(5, qgetenv("QT_ANDROID_MAX_ASSETS_CACHE_SIZE").toInt()))
, m_hasPrepopulatedCache(false)
+ , m_hasTriedPrepopulatingCache(false)
{
m_assetManager = QtAndroid::assetManager();
- prepopulateCache();
}
AndroidAssetsFileEngineHandler::~AndroidAssetsFileEngineHandler()
{
}
-void AndroidAssetsFileEngineHandler::prepopulateCache()
+void AndroidAssetsFileEngineHandler::prepopulateCache() const
{
+ Q_ASSERT(!m_hasTriedPrepopulatingCache);
+ m_hasTriedPrepopulatingCache = true;
+
QMutexLocker locker(&m_assetsCacheMutext);
Q_ASSERT(m_assetsCache.isEmpty());
@@ -364,7 +367,11 @@ QAbstractFileEngine * AndroidAssetsFileEngineHandler::create(const QString &file
if (!path.size())
path = fileName.left(fileName.length() - 1).toUtf8();
+
m_assetsCacheMutext.lock();
+ if (!m_hasTriedPrepopulatingCache)
+ prepopulateCache();
+
QSharedPointer<AndroidAssetDir> *aad = m_assetsCache.object(path);
m_assetsCacheMutext.unlock();
if (!aad) {