aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlextensionplugin.cpp
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.cpp
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.cpp')
-rw-r--r--src/qml/qml/qqmlextensionplugin.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/qml/qml/qqmlextensionplugin.cpp b/src/qml/qml/qqmlextensionplugin.cpp
index 7a62c967e7..f779199b74 100644
--- a/src/qml/qml/qqmlextensionplugin.cpp
+++ b/src/qml/qml/qqmlextensionplugin.cpp
@@ -117,6 +117,16 @@ QUrl QQmlExtensionPlugin::baseUrl() const
}
/*!
+ \since 6.0
+
+ Override this method to unregister types manually registered in registerTypes.
+*/
+void QQmlExtensionPlugin::unregisterTypes()
+{
+
+}
+
+/*!
\internal
*/