aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports/qtquick2
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2020-03-09 09:53:30 +0100
committerFabian Kosmale <fabian.kosmale@qt.io>2020-03-09 10:54:39 +0100
commitc2081016ecc894563f19d3e6bfdc7501aa23fe91 (patch)
tree6977e9c9a63c307a09c0dd6383db9fc4370bb351 /src/imports/qtquick2
parentf3dccc334f01d088fcdf1c2016c8153fe6154b61 (diff)
Avoid unloading plugins which register types to prevent crashes
Plugins could register an arbitrary number of types in arbitrary places with qRegisterMetaType. This would lead to crashes when the plugin is unloaded, as the type registry would hold stale references to their QMetaTypes. By not unloading the plugin, the metatypes are kept safe in memory. [ChangeLog][QML][Important Behavior Changes] When writing a QQmlExtensionPlugin which procedurually registers types, you should overload the newly introduced unregisterTypes function, if you want to support unregistration with qmlClearEnginePlugins. Additionally, the destructor of your plugin should not contain any logic. Change-Id: I63b7a153f82be7996dbfca4d36f279c351dc6b9e Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/imports/qtquick2')
-rw-r--r--src/imports/qtquick2/plugin.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/imports/qtquick2/plugin.cpp b/src/imports/qtquick2/plugin.cpp
index 4e14aff15e..dde0b7207a 100644
--- a/src/imports/qtquick2/plugin.cpp
+++ b/src/imports/qtquick2/plugin.cpp
@@ -64,10 +64,11 @@ public:
QQmlQtQuick2Module::defineModule();
}
- ~QtQuick2Plugin() override
+ void unregisterTypes() override
{
if (moduleDefined)
QQmlQtQuick2Module::undefineModule();
+ moduleDefined = false;
}
bool moduleDefined = false;