From ec73b9ff3b0064cf7760baeb826d912d9a30d227 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. Task-number: QTBUG-55524 Reviewed-by: Ulf Hermann (cherry picked from commit 23527754d60780ac4830f1acd6a54d3487a2c362) Change-Id: I52c9e4c33649966c6291fafaa2efc4242ada6788 --- src/imports/qtquick2/plugin.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/imports/qtquick2/plugin.cpp b/src/imports/qtquick2/plugin.cpp index b4caf01d10..71e2fa7ec0 100644 --- a/src/imports/qtquick2/plugin.cpp +++ b/src/imports/qtquick2/plugin.cpp @@ -43,17 +43,22 @@ class QtQuick2Plugin : public QQmlExtensionPlugin Q_OBJECT Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: + QtQuick2Plugin() : moduleDefined(false) {} virtual void registerTypes(const char *uri) { Q_ASSERT(QLatin1String(uri) == QLatin1String("QtQuick")); Q_UNUSED(uri); + moduleDefined = true; QQmlQtQuick2Module::defineModule(); } ~QtQuick2Plugin() { - QQmlQtQuick2Module::undefineModule(); + if (moduleDefined) + QQmlQtQuick2Module::undefineModule(); } + + bool moduleDefined; }; //![class decl] -- cgit v1.2.3