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/qqmlimport.cpp | |
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/qqmlimport.cpp')
-rw-r--r-- | src/qml/qml/qqmlimport.cpp | 21 |
1 files changed, 18 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 |