aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlextensionplugin.h
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/qml/qml/qqmlextensionplugin.h
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/qml/qml/qqmlextensionplugin.h')
-rw-r--r--src/qml/qml/qqmlextensionplugin.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/qml/qml/qqmlextensionplugin.h b/src/qml/qml/qqmlextensionplugin.h
index ef7ff422cd..78371106bd 100644
--- a/src/qml/qml/qqmlextensionplugin.h
+++ b/src/qml/qml/qqmlextensionplugin.h
@@ -64,6 +64,7 @@ public:
QUrl baseUrl() const;
void registerTypes(const char *uri) override = 0;
+ virtual void unregisterTypes();
void initializeEngine(QQmlEngine *engine, const char *uri) override;
private: