From 9b340999c4cb9db1975c4b63f3388899d9023944 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Fri, 2 Feb 2018 10:25:37 +0100 Subject: Fix memory leak in QQC1 When repeatedly creating a QQuickView, loading a QML file that imports QQC1 and deleting the view again, we would leak memory that was allocated as a consequence of QML type registration in initializeEngine() callbacks that were called on every iteration. After the limitation of namespacing in the registerTypes() callback of QML module plugins has been lifted, we can move the type registrations into registerTypes() where they belong and which is called only once. Change-Id: I1d21b18dd060e169a1ee1095f5c5af7341443492 Reviewed-by: J-P Nurmi Reviewed-by: Mitch Curtis Reviewed-by: Michael Winkelmann --- src/controls/plugin.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/controls/plugin.cpp') diff --git a/src/controls/plugin.cpp b/src/controls/plugin.cpp index f78098ec..4eb6c466 100644 --- a/src/controls/plugin.cpp +++ b/src/controls/plugin.cpp @@ -149,11 +149,6 @@ void QtQuickControls1Plugin::registerTypes(const char *uri) const QString filesLocation = fileLocation(); for (int i = 0; i < int(sizeof(qmldir)/sizeof(qmldir[0])); i++) qmlRegisterType(QUrl(filesLocation + "/" + qmldir[i].type + ".qml"), uri, qmldir[i].major, qmldir[i].minor, qmldir[i].type); -} - -void QtQuickControls1Plugin::initializeEngine(QQmlEngine *engine, const char *uri) -{ - Q_UNUSED(uri); // Register private API. Note that to use these types outside of the // Qt Quick Controls module, both the public and private imports must be used. @@ -185,6 +180,14 @@ void QtQuickControls1Plugin::initializeEngine(QQmlEngine *engine, const char *ur #ifdef QT_WIDGETS_LIB qmlRegisterType(private_uri, 1, 0, "StyleItem"); +#endif +} + +void QtQuickControls1Plugin::initializeEngine(QQmlEngine *engine, const char *uri) +{ + Q_UNUSED(uri); + +#ifdef QT_WIDGETS_LIB engine->addImageProvider("__tablerow", new QQuickTableRowImageProvider1); #endif engine->addImageProvider("desktoptheme", new QQuickDesktopIconProvider1); -- cgit v1.2.1