Delay calculation of offline storage path as long as is practically possible.
authorRobin Burchell <robin.burchell@jollamobile.com>
Mon, 7 Oct 2013 23:23:15 +0000 (01:23 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Tue, 8 Oct 2013 00:57:35 +0000 (02:57 +0200)
This avoids calculating it incorrectly in the case that something later clobbers
argv, such as a zygote or booster-type mechanism.

Change-Id: Ifab16c7c94e9ee3fded0dfda2266a12c910858ee
Reviewed-by: Matthew Vogt <matthew.vogt@qinetic.com.au>
Reviewed-by: Martin Jones <martin.jones@jollamobile.com>
src/qml/qml/qqmlengine.cpp

index c8b602e..64cde85 100644 (file)
@@ -803,12 +803,6 @@ void QQmlEnginePrivate::init()
         QQmlProfilerService::initialize();
         QDebugMessageService::instance();
     }
-
-    QString dataLocation = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
-    if (!dataLocation.isEmpty())
-        offlineStoragePath = dataLocation.replace(QLatin1Char('/'), QDir::separator())
-                           + QDir::separator() + QLatin1String("QML")
-                           + QDir::separator() + QLatin1String("OfflineStorage");
 }
 
 QQuickWorkerScriptEngine *QQmlEnginePrivate::getWorkerScriptEngine()
@@ -1995,6 +1989,16 @@ void QQmlEngine::setOfflineStoragePath(const QString& dir)
 QString QQmlEngine::offlineStoragePath() const
 {
     Q_D(const QQmlEngine);
+
+    if (d->offlineStoragePath.isEmpty()) {
+        QString dataLocation = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
+        QQmlEnginePrivate *e = const_cast<QQmlEnginePrivate *>(d);
+        if (!dataLocation.isEmpty())
+            e->offlineStoragePath = dataLocation.replace(QLatin1Char('/'), QDir::separator())
+                                  + QDir::separator() + QLatin1String("QML")
+                                  + QDir::separator() + QLatin1String("OfflineStorage");
+    }
+
     return d->offlineStoragePath;
 }