aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlmoduleplugin
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2019-10-01 12:37:55 +0200
committerUlf Hermann <ulf.hermann@qt.io>2019-10-08 12:49:05 +0200
commit914e0300792856ddac9b99b20a8d88dd6f087fa6 (patch)
tree16962e85671c3be2fea9fafc7f7fe45664c568be /tests/auto/qml/qqmlmoduleplugin
parent67fc5b677a05f88f043ea825810b7b244a516b42 (diff)
Use qmlProtectModule to protect a module from further modification
We don't need two mechanisms to do essentially the same thing. QQmlTypeLoader::Blob::addImport() had an "optimization" to never check for qmldir files of locked imports. This meant the first time you imported a module with a plugin that locked the module you could use the qmldir file to load additional .qml files afterwards. The second time you imported the same thing, you couldn't. As this is not a great example of consistent behavior, we drop this optimization and always allow the qmldir files of plugins that lock the module to specify additional QML files. As a side effect of this, additional plugins listed in a qmldir file can also now be loaded after the module has been locked by some other means. However, any qmlRegisterFooBar() called from the module will be prevented. Change-Id: Idabb2bd5f75fc85b62f42625173672b4ae84382e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmlmoduleplugin')
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/protectedModule/plugin.cpp4
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp2
2 files changed, 3 insertions, 3 deletions
diff --git a/tests/auto/qml/qqmlmoduleplugin/protectedModule/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/protectedModule/plugin.cpp
index ae8c231aab..bb5bb00adb 100644
--- a/tests/auto/qml/qqmlmoduleplugin/protectedModule/plugin.cpp
+++ b/tests/auto/qml/qqmlmoduleplugin/protectedModule/plugin.cpp
@@ -47,9 +47,9 @@ public:
void registerTypes(const char *uri)
{
- // Because the module is protected, this plugin should never be loaded
+ // The module is protected. The plugin can still be loaded, but it cannot register
+ // any types.
Q_UNUSED(uri);
- Q_ASSERT(0);
}
};
diff --git a/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp b/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp
index d2d6dc5d49..75885bc84a 100644
--- a/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp
+++ b/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp
@@ -609,7 +609,7 @@ void tst_qqmlmoduleplugin::importStrictModule_data()
<< "import org.qtproject.NonstrictModule 1.0\n"
"MyPluginType {}"
<< "Module 'org.qtproject.NonstrictModule' does not contain a module identifier directive - it cannot be protected from external registrations."
- << ":1:1: plugin cannot be loaded for module \"org.qtproject.NonstrictModule\": Cannot install element 'MyPluginType' into protected namespace 'org.qtproject.StrictModule'";
+ << ":1:1: plugin cannot be loaded for module \"org.qtproject.NonstrictModule\": Cannot install element 'MyPluginType' into protected module 'org.qtproject.StrictModule' version '1'";
QTest::newRow("non-strict preemption")
<< "import org.qtproject.PreemptiveModule 1.0\n"