From e6f43cbbe515f972dc1912f7594f7a988ee78deb Mon Sep 17 00:00:00 2001
From: Tobias Hunger <tobias.hunger@nokia.com>
Date: Tue, 13 Apr 2010 12:07:13 +0200
Subject: [PATCH] Fix possible crash in targetsetuppage

* Fix a possible memleak while at it.

TaskNumber: QTCREATORBUG-1125
Reviewed-by: dt
---
 src/plugins/qt4projectmanager/wizards/targetsetuppage.cpp | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/plugins/qt4projectmanager/wizards/targetsetuppage.cpp b/src/plugins/qt4projectmanager/wizards/targetsetuppage.cpp
index 9cbc3793dfa..4a73a035830 100644
--- a/src/plugins/qt4projectmanager/wizards/targetsetuppage.cpp
+++ b/src/plugins/qt4projectmanager/wizards/targetsetuppage.cpp
@@ -104,8 +104,11 @@ void TargetSetupPage::setImportInfos(const QList<ImportInfo> &infos)
                 break;
             }
         }
-        if (skip)
+        if (skip) {
+            if (i.isTemporary)
+                delete i.version;
             continue;
+        }
 
         m_infos.append(i);
 
@@ -382,6 +385,7 @@ void TargetSetupPage::importDirectoryAdded(const QString &directory)
         return;
     m_directoryChooser->setPath(QString());
     QList<ImportInfo> tmp = m_infos;
+    m_infos.clear(); // Clear m_infos without deleting temporary QtVersions!
     tmp.append(recursivelyCheckDirectoryForBuild(directory));
     setImportInfos(tmp);
 }
-- 
GitLab