OSDN Git Service

Maemo: Fix possible crash when removing a Maemo target.
authorChristian Kandeler <christian.kandeler@nokia.com>
Tue, 3 May 2011 15:45:07 +0000 (17:45 +0200)
committerChristian Kandeler <christian.kandeler@nokia.com>
Tue, 3 May 2011 16:33:44 +0000 (18:33 +0200)
If there are no packaging files for whatever reason, we try to
access the first element of an empty list.

Reviewed-by: dt
src/plugins/qt4projectmanager/qt-maemo/qt4maemotarget.cpp

index 9a20379..03674d1 100644 (file)
@@ -302,13 +302,15 @@ void AbstractQt4MaemoTarget::handleTargetToBeRemoved(ProjectExplorer::Target *ta
     if (answer == QMessageBox::No)
         return;
     const QStringList pkgFilePaths = packagingFilePaths();
-    project()->rootProjectNode()->removeFiles(ProjectExplorer::UnknownFileType,
-        pkgFilePaths);
-    Core::IVersionControl * const vcs = core->vcsManager()
-        ->findVersionControlForDirectory(QFileInfo(packagingFilePaths().first()).dir().path());
-    if (vcs && vcs->supportsOperation(Core::IVersionControl::DeleteOperation)) {
-        foreach (const QString &filePath, pkgFilePaths)
-            vcs->vcsDelete(filePath);
+    if (!pkgFilePaths.isEmpty()) {
+        project()->rootProjectNode()->removeFiles(ProjectExplorer::UnknownFileType,
+            pkgFilePaths);
+        Core::IVersionControl * const vcs = core->vcsManager()
+            ->findVersionControlForDirectory(QFileInfo(pkgFilePaths.first()).dir().path());
+        if (vcs && vcs->supportsOperation(Core::IVersionControl::DeleteOperation)) {
+            foreach (const QString &filePath, pkgFilePaths)
+                vcs->vcsDelete(filePath);
+        }
     }
     removeTarget();
     QString error;