diff options
author | Liang Jian <jianliang79@gmail.com> | 2014-03-14 09:09:57 +0800 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-03-14 07:55:29 +0100 |
commit | bbffec3effe533dd8ceb99b2d8c299fc070c88c6 (patch) | |
tree | 9bdf300eb7d9d5583e5f235737d545111b311cb4 /src/qml/qml | |
parent | 593be86d543b220d4f47e915c39b45ca3cb6e6af (diff) |
Fix QmldirCache object leak
Delete all the QmldirCache objects in the linked list
Change-Id: I9948ccce3d72aaed4f8b14b131e040177d7a15ef
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/qml')
-rw-r--r-- | src/qml/qml/qqmlimport.cpp | 21 | ||||
-rw-r--r-- | src/qml/qml/qqmlimport_p.h | 1 |
2 files changed, 19 insertions, 3 deletions
diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp index cae8365598..f153a67586 100644 --- a/src/qml/qml/qqmlimport.cpp +++ b/src/qml/qml/qqmlimport.cpp @@ -1578,8 +1578,7 @@ QQmlImportDatabase::QQmlImportDatabase(QQmlEngine *e) QQmlImportDatabase::~QQmlImportDatabase() { - qDeleteAll(qmldirCache); - qmldirCache.clear(); + clearDirCache(); } /*! @@ -1814,7 +1813,7 @@ void QQmlImportDatabase::setImportPathList(const QStringList &paths) fileImportPath = paths; // Our existing cached paths may have been invalidated - qmldirCache.clear(); + clearDirCache(); } /*! @@ -2024,4 +2023,20 @@ bool QQmlImportDatabase::importDynamicPlugin(const QString &filePath, const QStr #endif } +void QQmlImportDatabase::clearDirCache() +{ + QStringHash<QmldirCache *>::ConstIterator itr = qmldirCache.begin(); + while (itr != qmldirCache.end()) { + QmldirCache *cache = *itr; + do { + QmldirCache *nextCache = cache->next; + delete cache; + cache = nextCache; + } while (cache); + + ++itr; + } + qmldirCache.clear(); +} + QT_END_NAMESPACE diff --git a/src/qml/qml/qqmlimport_p.h b/src/qml/qml/qqmlimport_p.h index b19e777852..7894037cdc 100644 --- a/src/qml/qml/qqmlimport_p.h +++ b/src/qml/qml/qqmlimport_p.h @@ -174,6 +174,7 @@ private: const QString &typeNamespace, QList<QQmlError> *errors); bool registerPluginTypes(QObject *instance, const QString &basePath, const QString &uri, const QString &typeNamespace, QList<QQmlError> *errors); + void clearDirCache(); struct QmldirCache { int versionMajor; |