aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2016-11-22 15:53:07 +0100
committerSimon Hausmann <simon.hausmann@qt.io>2016-11-23 13:06:27 +0000
commiteb7ec4fb9492b51d8371d8689b9538d6d22d13fd (patch)
treef809e744c90e5dc53d6454b4927df43598da04d4
parentd236661940b09194cc6a864ffbe687569922787e (diff)
Fix handling of qrc:/// urls with disk caching
Use the right function for converting a qrc:/// url to a local path. QUrl::toLocalFile() gives us an empty path, which prevents us from getting a time stamp and comparing it against the stamp in the cache file. This fixes disk caching with samegame. Change-Id: Id3eb270f1f7a7f25143d2f075a45f32bdb0384c5 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
-rw-r--r--src/qml/compiler/qv4compileddata.cpp2
-rw-r--r--tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp21
2 files changed, 21 insertions, 2 deletions
diff --git a/src/qml/compiler/qv4compileddata.cpp b/src/qml/compiler/qv4compileddata.cpp
index e815c41a86..f8668b48e4 100644
--- a/src/qml/compiler/qv4compileddata.cpp
+++ b/src/qml/compiler/qv4compileddata.cpp
@@ -397,7 +397,7 @@ bool CompilationUnit::loadFromDisk(const QUrl &url, EvalISelFactory *iselFactory
return false;
}
- const QString sourcePath = url.toLocalFile();
+ const QString sourcePath = QQmlFile::urlToLocalFileOrQrc(url);
QScopedPointer<CompilationUnitMapper> cacheFile(new CompilationUnitMapper());
CompiledData::Unit *mappedUnit = cacheFile->open(cacheFilePath(url), sourcePath, errorString);
diff --git a/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp b/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp
index f8698f0afa..8af446173d 100644
--- a/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp
+++ b/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp
@@ -549,7 +549,6 @@ void tst_qmldiskcache::cacheResources()
{
CleanlyLoadingComponent component(&engine, QUrl("qrc:/test.qml"));
- qDebug() << component.errorString();
QScopedPointer<QObject> obj(component.create());
QVERIFY(!obj.isNull());
QCOMPARE(obj->property("value").toInt(), 20);
@@ -558,17 +557,37 @@ void tst_qmldiskcache::cacheResources()
const QStringList entries = QDir(qmlCacheDirectory).entryList(QDir::NoDotAndDotDot | QDir::Files);
QCOMPARE(entries.count(), 1);
+ QDateTime cacheFileTimeStamp;
+
{
QFile cacheFile(qmlCacheDirectory + QLatin1Char('/') + entries.constFirst());
QVERIFY2(cacheFile.open(QIODevice::ReadOnly), qPrintable(cacheFile.errorString()));
QV4::CompiledData::Unit unit;
QVERIFY(cacheFile.read(reinterpret_cast<char *>(&unit), sizeof(unit)) == sizeof(unit));
+ cacheFileTimeStamp = QFileInfo(cacheFile.fileName()).lastModified();
+
QDateTime referenceTimeStamp = QFileInfo(":/test.qml").lastModified();
if (!referenceTimeStamp.isValid())
referenceTimeStamp = QFileInfo(QCoreApplication::applicationFilePath()).lastModified();
QCOMPARE(qint64(unit.sourceTimeStamp), referenceTimeStamp.toMSecsSinceEpoch());
}
+
+ waitForFileSystem();
+
+ {
+ CleanlyLoadingComponent component(&engine, QUrl("qrc:///test.qml"));
+ QScopedPointer<QObject> obj(component.create());
+ QVERIFY(!obj.isNull());
+ QCOMPARE(obj->property("value").toInt(), 20);
+ }
+
+ {
+ const QStringList entries = QDir(qmlCacheDirectory).entryList(QDir::NoDotAndDotDot | QDir::Files);
+ QCOMPARE(entries.count(), 1);
+
+ QCOMPARE(QFileInfo(qmlCacheDirectory + QLatin1Char('/') + entries.constFirst()).lastModified().toMSecsSinceEpoch(), cacheFileTimeStamp.toMSecsSinceEpoch());
+ }
}
void tst_qmldiskcache::stableOrderOfDependentCompositeTypes()