aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2017-09-18 16:26:17 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2017-09-19 06:48:31 +0000
commit71a18fd64c93afa00f4d89de2ba47663f41eba2c (patch)
treeaed7d1f4bb6c4a69564a4a3f43a21d183cc77030 /src
parent44ae9cdb95b14813d339c7bbd00df608261c8b9d (diff)
Fix qmlClearTypeRegistrations() not dropping all registrations
In commit 48c09a85ce397979c7e706e3694c879ffe456e09 we added the undeletableTypes container to hold a reference on C++ registered types to keep the indices returned by the public qmlRegisterType() API stable. Since qmlClearTypeRegistrations() is API that also resets those indices, we must also clear the undeletableTypes container to avoid leaking memory. Change-Id: I2038c00913f894d58aca3714d64d497493585326 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/qml/qml/qqmlmetatype.cpp8
-rw-r--r--src/qml/qml/qqmlmetatype_p.h1
2 files changed, 9 insertions, 0 deletions
diff --git a/src/qml/qml/qqmlmetatype.cpp b/src/qml/qml/qqmlmetatype.cpp
index 8f5d11a96f..ac670bdabb 100644
--- a/src/qml/qml/qqmlmetatype.cpp
+++ b/src/qml/qml/qqmlmetatype.cpp
@@ -1144,6 +1144,13 @@ void QQmlType::derefHandle(QQmlTypePrivate *priv)
delete priv;
}
+int QQmlType::refCount(QQmlTypePrivate *priv)
+{
+ if (priv)
+ return priv->refCount;
+ return -1;
+}
+
namespace {
template <typename QQmlTypeContainer>
void removeQQmlTypePrivate(QQmlTypeContainer &container, const QQmlTypePrivate *reference)
@@ -1334,6 +1341,7 @@ void qmlClearTypeRegistrations() // Declared in qqml.h
data->urlToNonFileImportType.clear();
data->metaObjectToType.clear();
data->uriToModule.clear();
+ data->undeletableTypes.clear();
QQmlEnginePrivate::baseModulesUninitialized = true; //So the engine re-registers its types
#if QT_CONFIG(library)
diff --git a/src/qml/qml/qqmlmetatype_p.h b/src/qml/qml/qqmlmetatype_p.h
index 9a7736ffcd..74b1cf0e06 100644
--- a/src/qml/qml/qqmlmetatype_p.h
+++ b/src/qml/qml/qqmlmetatype_p.h
@@ -245,6 +245,7 @@ public:
QQmlTypePrivate *priv() const { return d; }
static void refHandle(QQmlTypePrivate *priv);
static void derefHandle(QQmlTypePrivate *priv);
+ static int refCount(QQmlTypePrivate *priv);
enum RegistrationType {
CppType = 0,