From 23527754d60780ac4830f1acd6a54d3487a2c362 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Mon, 1 Aug 2016 13:39:37 +0200 Subject: Fix crash in tst_qqmlextensionplugin on shutdown On shutdown the test will unload all the plugins it loaded. In the case of the QtQuick2 plugin we only loaded it but never called registerTypes, as the test merely sees if the plugin can be instantiated. Consequently the attempt at unregistering the value type providers will fail because it was previously never defined. Note: We can't just let the QQmlValueTypeProvider destructor take care of the deregistration, as we do not truly unload plugins anymore (thankfully). However the plugin object will be destroyed and along with it we should correctly de-register the things we registered earlier, otherwise when initializing the plugin again, we'll register handers multiple times. Change-Id: Id778890bcd3f1fab16eb312a01de7d423ea3aa22 Reviewed-by: Ulf Hermann --- src/imports/qtquick2/plugin.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/imports/qtquick2') diff --git a/src/imports/qtquick2/plugin.cpp b/src/imports/qtquick2/plugin.cpp index e56027c1bb..d16467a5bb 100644 --- a/src/imports/qtquick2/plugin.cpp +++ b/src/imports/qtquick2/plugin.cpp @@ -61,13 +61,17 @@ public: { Q_ASSERT(QLatin1String(uri) == QLatin1String("QtQuick")); Q_UNUSED(uri); + moduleDefined = true; QQmlQtQuick2Module::defineModule(); } ~QtQuick2Plugin() { - QQmlQtQuick2Module::undefineModule(); + if (moduleDefined) + QQmlQtQuick2Module::undefineModule(); } + + bool moduleDefined = false; }; //![class decl] -- cgit v1.2.3