aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2016-08-03 13:50:44 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2016-08-05 10:50:57 +0000
commit8d1bae4c0f45ea6853d5ff63fda4f625f1e4bb83 (patch)
treedb174201c2dba5ff3bd3fd2c2e269c111a8b1033
parentedb1c204c3bc9ad01ccf7a8abb0e8a02fd89ed72 (diff)
Enable QML/JS disk cache by default
Except on Windows, where there is still one bug to fix. Change-Id: I1a22f42859733eedd37596a3e8fc09680720ff10 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
-rw-r--r--src/qml/qml/qqmltypeloader.cpp25
-rw-r--r--tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp2
-rw-r--r--tests/auto/qml/qqmlengine/tst_qqmlengine.cpp6
-rw-r--r--tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp10
4 files changed, 33 insertions, 10 deletions
diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp
index 06cabfeb65..40a2c596e3 100644
--- a/src/qml/qml/qqmltypeloader.cpp
+++ b/src/qml/qml/qqmltypeloader.cpp
@@ -103,12 +103,22 @@
#endif
DEFINE_BOOL_CONFIG_OPTION(dumpErrors, QML_DUMP_ERRORS);
-DEFINE_BOOL_CONFIG_OPTION(diskCache, QML_DISK_CACHE);
-DEFINE_BOOL_CONFIG_OPTION(forceDiskCacheRefresh, QML_FORCE_DISK_CACHE_REFRESH);
+DEFINE_BOOL_CONFIG_OPTION(_disableDiskCache, QML_DISABLE_DISK_CACHE);
+DEFINE_BOOL_CONFIG_OPTION(forceDiskCache, QML_FORCE_DISK_CACHE);
Q_DECLARE_LOGGING_CATEGORY(DBG_DISK_CACHE)
Q_LOGGING_CATEGORY(DBG_DISK_CACHE, "qt.qml.diskcache")
+static bool disableDiskCache()
+{
+ return _disableDiskCache()
+ // ### FIXME: Fix crashes on Windows with mmap'ed code.
+#if defined(Q_OS_WIN)
+ || true
+#endif
+ ;
+}
+
QT_BEGIN_NAMESPACE
namespace {
@@ -2068,10 +2078,7 @@ void QQmlTypeData::unregisterCallback(TypeDataCallback *callback)
bool QQmlTypeData::tryLoadFromDiskCache()
{
- if (!diskCache())
- return false;
-
- if (forceDiskCacheRefresh())
+ if (disableDiskCache() && !forceDiskCache())
return false;
if (isDebugging())
@@ -2515,7 +2522,7 @@ void QQmlTypeData::compile(const QQmlRefPointer<QQmlTypeNameCache> &importCache,
return;
}
- const bool trySaveToDisk = (diskCache() || forceDiskCacheRefresh()) && !m_document->jsModule.debugMode;
+ const bool trySaveToDisk = (!disableDiskCache() || forceDiskCache()) && !m_document->jsModule.debugMode;
if (trySaveToDisk) {
QString errorString;
if (m_compiledData->saveToDisk(url(), &errorString)) {
@@ -2909,7 +2916,7 @@ void QQmlScriptBlob::dataReceived(const Data &data)
{
QV4::ExecutionEngine *v4 = QV8Engine::getV4(m_typeLoader->engine());
- if (diskCache() && !forceDiskCacheRefresh()) {
+ if (!disableDiskCache() || forceDiskCache()) {
QQmlRefPointer<QV4::CompiledData::CompilationUnit> unit = v4->iselFactory->createUnitForLoading();
QString error;
if (unit->loadFromDisk(url(), v4->iselFactory.data(), &error)) {
@@ -2955,7 +2962,7 @@ void QQmlScriptBlob::dataReceived(const Data &data)
// The js unit owns the data and will free the qml unit.
unit->data = unitData;
- if (diskCache() || forceDiskCacheRefresh()) {
+ if (!disableDiskCache() || forceDiskCache()) {
QString errorString;
if (!unit->saveToDisk(url(), &errorString)) {
qCDebug(DBG_DISK_CACHE()) << "Error saving cached version of" << unit->url().toString() << "to disk:" << errorString;
diff --git a/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp b/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp
index ca47aae92e..c3a80eebde 100644
--- a/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp
+++ b/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp
@@ -190,7 +190,7 @@ struct TestCompiler
void tst_qmldiskcache::initTestCase()
{
- qputenv("QML_DISK_CACHE", "1");
+ qputenv("QML_FORCE_DISK_CACHE", "1");
}
void tst_qmldiskcache::regenerateAfterChange()
diff --git a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp
index 74e54b64e9..9c155eda5b 100644
--- a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp
+++ b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp
@@ -275,6 +275,12 @@ void tst_qqmlengine::clearComponentCache()
// Modify qml file
{
+ // On macOS with HFS+ the precision of file times is measured in seconds, so to ensure that
+ // the newly written file has a modification date newer than an existing cache file, we must
+ // wait.
+ // Similar effects of lacking precision have been observed on some Linux systems.
+ QThread::sleep(1);
+
QFile file("temp.qml");
QVERIFY(file.open(QIODevice::WriteOnly));
file.write("import QtQuick 2.0\nQtObject {\nproperty int test: 11\n}\n");
diff --git a/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp b/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp
index f3ba3e8971..f19e82032a 100644
--- a/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp
+++ b/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp
@@ -56,6 +56,7 @@ public slots:
}
private slots:
+ void initTestCase();
void basicProperties();
void showFiles();
void resetFiltering();
@@ -97,6 +98,15 @@ void tst_qquickfolderlistmodel::checkNoErrors(const QQmlComponent& component)
QVERIFY(!component.isError());
}
+void tst_qquickfolderlistmodel::initTestCase()
+{
+ // The tests rely on a fixed number of files in the directory with the qml files
+ // (the data dir), so disable the disk cache to avoid creating .qmlc files and
+ // confusing the test.
+ qputenv("QML_DISABLE_DISK_CACHE", "1");
+ QQmlDataTest::initTestCase();
+}
+
void tst_qquickfolderlistmodel::basicProperties()
{
QQmlComponent component(&engine, testFileUrl("basic.qml"));