From bbffec3effe533dd8ceb99b2d8c299fc070c88c6 Mon Sep 17 00:00:00 2001 From: Liang Jian Date: Fri, 14 Mar 2014 09:09:57 +0800 Subject: Fix QmldirCache object leak Delete all the QmldirCache objects in the linked list Change-Id: I9948ccce3d72aaed4f8b14b131e040177d7a15ef Reviewed-by: Simon Hausmann --- src/qml/qml/qqmlimport.cpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'src/qml/qml/qqmlimport.cpp') 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::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 -- cgit v1.2.3