diff options
author | Mitch Curtis <mitch.curtis@qt.io> | 2018-12-04 10:54:20 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2019-06-25 15:52:47 +0200 |
commit | abfa03d7021aabe22f46a04d2b9d9f6adff2478a (patch) | |
tree | 11bd1ddfa91c35f128f51c3500d7761a80ceddbf /src/qml | |
parent | 82f126599b7b087f96622b91017a11caa496389f (diff) |
Unregister unit cache hook when destroying the plugin singleton
At the point the plugin is actually unloaded the hook turns into a
dangling pointer.
Fixes: QTBUG-71387
Change-Id: Ib8ccee3f9a86d4700fbea7e87c666cd8f30f71e4
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml')
-rw-r--r-- | src/qml/qml/qqmlmetatype.cpp | 29 | ||||
-rw-r--r-- | src/qml/qml/qqmlprivate.h | 1 |
2 files changed, 29 insertions, 1 deletions
diff --git a/src/qml/qml/qqmlmetatype.cpp b/src/qml/qml/qqmlmetatype.cpp index 573288b77f..aac76b6055 100644 --- a/src/qml/qml/qqmlmetatype.cpp +++ b/src/qml/qml/qqmlmetatype.cpp @@ -1648,7 +1648,14 @@ void qmlClearTypeRegistrations() // Declared in qqml.h #endif } -static int registerAutoParentFunction(QQmlPrivate::RegisterAutoParent &autoparent) +static void unregisterAutoParentFunction(const QQmlPrivate::AutoParentFunction &function) +{ + QMutexLocker lock(metaTypeDataLock()); + QQmlMetaTypeData *data = metaTypeData(); + data->parentFunctions.removeOne(function); +} + +static int registerAutoParentFunction(const QQmlPrivate::RegisterAutoParent &autoparent) { QMutexLocker lock(metaTypeDataLock()); QQmlMetaTypeData *data = metaTypeData(); @@ -1957,6 +1964,26 @@ int QQmlPrivate::qmlregister(RegistrationType type, void *data) return dtype.index(); } +void QQmlPrivate::qmlunregister(RegistrationType type, quintptr data) +{ + switch (type) { + case AutoParentRegistration: + unregisterAutoParentFunction(reinterpret_cast<AutoParentFunction>(data)); + break; + case QmlUnitCacheHookRegistration: + QQmlMetaType::removeCachedUnitLookupFunction( + reinterpret_cast<QmlUnitCacheLookupFunction>(data)); + break; + case TypeRegistration: + case InterfaceRegistration: + case SingletonRegistration: + case CompositeRegistration: + case CompositeSingletonRegistration: + qmlUnregisterType(data); + break; + } +} + //From qqml.h bool qmlProtectModule(const char *uri, int majVersion) { diff --git a/src/qml/qml/qqmlprivate.h b/src/qml/qml/qqmlprivate.h index ae84803648..8a45de9f76 100644 --- a/src/qml/qml/qqmlprivate.h +++ b/src/qml/qml/qqmlprivate.h @@ -318,6 +318,7 @@ namespace QQmlPrivate }; int Q_QML_EXPORT qmlregister(RegistrationType, void *); + void Q_QML_EXPORT qmlunregister(RegistrationType, quintptr); } QT_END_NAMESPACE |