diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2019-02-18 14:24:45 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2019-02-18 14:40:10 +0000 |
commit | 06ec6340d0eff763e52135afabc13662b3892c43 (patch) | |
tree | 839663e808cb49633a35a453beb85f4b49801b96 /tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp | |
parent | 2131ec383b588e2160cb72247e61f7eab71cc0b1 (diff) |
Avoid unnecessary re-generation qml cache files in some circumstances
The map of name IDs to resolved types so far is copied several times
during compilation and different compile passes see different copies of it.
Compile passes may add things to the map, and if they do that on copies
that are inaccessible to other code, we get nondeterministic results.
Furthermore all the copies and pointers are confusing and inefficient.
Fixes: QTBUG-69340
Change-Id: I43ad3cbeeec34f90e05570eddc901fe8aa64c709
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp')
-rw-r--r-- | tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp | 53 |
1 files changed, 36 insertions, 17 deletions
diff --git a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp index 3745fad470..0c4abf19f4 100644 --- a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp +++ b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp @@ -55,6 +55,7 @@ private slots: void redirect(); void qmlSingletonWithinModule(); void multiSingletonModule(); + void implicitComponentModule(); }; void tst_QQMLTypeLoader::testLoadComplete() @@ -446,23 +447,8 @@ void tst_QQMLTypeLoader::qmlSingletonWithinModule() QVERIFY(obj->property("ok").toBool()); } -void tst_QQMLTypeLoader::multiSingletonModule() +static void checkCleanCacheLoad(const QString &testCase) { - qmlClearTypeRegistrations(); - QQmlEngine engine; - engine.addImportPath(testFile("imports")); - - qmlRegisterSingletonType(testFileUrl("CppRegisteredSingleton1.qml"), "cppsingletonmodule", - 1, 0, "CppRegisteredSingleton1"); - qmlRegisterSingletonType(testFileUrl("CppRegisteredSingleton2.qml"), "cppsingletonmodule", - 1, 0, "CppRegisteredSingleton2"); - - QQmlComponent component(&engine, testFileUrl("multisingletonuser.qml")); - QCOMPARE(component.status(), QQmlComponent::Ready); - QScopedPointer<QObject> obj(component.create()); - QVERIFY(!obj.isNull()); - QVERIFY(obj->property("ok").toBool()); - #if QT_CONFIG(process) const char *skipKey = "QT_TST_QQMLTYPELOADER_SKIP_MISMATCH"; if (qEnvironmentVariableIsSet(skipKey)) @@ -470,7 +456,7 @@ void tst_QQMLTypeLoader::multiSingletonModule() for (int i = 0; i < 5; ++i) { QProcess child; child.setProgram(QCoreApplication::applicationFilePath()); - child.setArguments(QStringList(QLatin1String("multiSingletonModule"))); + child.setArguments(QStringList(testCase)); QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); env.insert(QLatin1String("QT_LOGGING_RULES"), QLatin1String("qt.qml.diskcache.debug=true")); env.insert(QLatin1String(skipKey), QLatin1String("1")); @@ -481,9 +467,42 @@ void tst_QQMLTypeLoader::multiSingletonModule() QVERIFY(!child.readAllStandardOutput().contains("Checksum mismatch for cached version")); QVERIFY(!child.readAllStandardError().contains("Checksum mismatch for cached version")); } +#else + Q_UNUSED(testCase); #endif } +void tst_QQMLTypeLoader::multiSingletonModule() +{ + qmlClearTypeRegistrations(); + QQmlEngine engine; + engine.addImportPath(testFile("imports")); + + qmlRegisterSingletonType(testFileUrl("CppRegisteredSingleton1.qml"), "cppsingletonmodule", + 1, 0, "CppRegisteredSingleton1"); + qmlRegisterSingletonType(testFileUrl("CppRegisteredSingleton2.qml"), "cppsingletonmodule", + 1, 0, "CppRegisteredSingleton2"); + + QQmlComponent component(&engine, testFileUrl("multisingletonuser.qml")); + QCOMPARE(component.status(), QQmlComponent::Ready); + QScopedPointer<QObject> obj(component.create()); + QVERIFY(!obj.isNull()); + QVERIFY(obj->property("ok").toBool()); + + checkCleanCacheLoad(QLatin1String("multiSingletonModule")); +} + +void tst_QQMLTypeLoader::implicitComponentModule() +{ + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("implicitcomponent.qml")); + QCOMPARE(component.status(), QQmlComponent::Ready); + QScopedPointer<QObject> obj(component.create()); + QVERIFY(!obj.isNull()); + + checkCleanCacheLoad(QLatin1String("implicitComponentModule")); +} + QTEST_MAIN(tst_QQMLTypeLoader) #include "tst_qqmltypeloader.moc" |