From 98e37b3b158fc83e11c0db763ac7b68999ba47e2 Mon Sep 17 00:00:00 2001
From: hjk <qtc-committer@nokia.com>
Date: Tue, 7 Sep 2010 14:19:44 +0200
Subject: [PATCH] debugger: don't remove corefiles that we did not create.

---
 src/plugins/debugger/debuggerengine.cpp  |  1 +
 src/plugins/debugger/debuggerengine.h    |  1 +
 src/plugins/debugger/gdb/gdbengine.cpp   |  1 +
 src/plugins/debugger/snapshothandler.cpp | 10 +++++-----
 4 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/plugins/debugger/debuggerengine.cpp b/src/plugins/debugger/debuggerengine.cpp
index b114544c00a..05302371620 100644
--- a/src/plugins/debugger/debuggerengine.cpp
+++ b/src/plugins/debugger/debuggerengine.cpp
@@ -108,6 +108,7 @@ using namespace TextEditor;
 DebuggerStartParameters::DebuggerStartParameters()
   : attachPID(-1),
     useTerminal(false),
+    isSnapshot(false),
     breakAtMain(false),
     qmlServerAddress("127.0.0.1"),
     qmlServerPort(0),
diff --git a/src/plugins/debugger/debuggerengine.h b/src/plugins/debugger/debuggerengine.h
index bc6a57498e8..e18e763e169 100644
--- a/src/plugins/debugger/debuggerengine.h
+++ b/src/plugins/debugger/debuggerengine.h
@@ -68,6 +68,7 @@ public:
     QString executable;
     QString displayName;
     QString coreFile;
+    bool isSnapshot; // set if created internally
     QStringList processArgs;
     QStringList environment;
     QString workingDirectory;
diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp
index 38e2f75a1c7..b82e340aec2 100644
--- a/src/plugins/debugger/gdb/gdbengine.cpp
+++ b/src/plugins/debugger/gdb/gdbengine.cpp
@@ -3022,6 +3022,7 @@ void GdbEngine::handleMakeSnapshot(const GdbResponse &response)
             function = frame.function + _(":") + QString::number(frame.line);
         }
         sp.displayName = function + _(": ") + QDateTime::currentDateTime().toString();
+        sp.isSnapshot = true;
         DebuggerRunControl *rc = DebuggerPlugin::createDebugger(sp);
         DebuggerPlugin::startDebugger(rc);
     } else {
diff --git a/src/plugins/debugger/snapshothandler.cpp b/src/plugins/debugger/snapshothandler.cpp
index 2e9571c7535..c9bf24303bb 100644
--- a/src/plugins/debugger/snapshothandler.cpp
+++ b/src/plugins/debugger/snapshothandler.cpp
@@ -127,9 +127,9 @@ SnapshotHandler::~SnapshotHandler()
 {
     for (int i = m_snapshots.size(); --i >= 0; ) {
         if (DebuggerEngine *engine = engineAt(i)) {
-            QString fileName = engine->startParameters().coreFile;
-            if (!fileName.isEmpty())
-                QFile::remove(fileName);
+            const DebuggerStartParameters & sp = engine->startParameters();
+            if (sp.isSnapshot && !sp.coreFile.isEmpty())
+                QFile::remove(sp.coreFile);
         }
     }
 }
@@ -270,8 +270,8 @@ void SnapshotHandler::removeSnapshot(int index)
     const DebuggerEngine *engine = engineAt(index);
     QTC_ASSERT(engine, return);
     QString fileName = engine->startParameters().coreFile;
-    if (!fileName.isEmpty())
-        QFile::remove(fileName);
+    //if (!fileName.isEmpty())
+    //    QFile::remove(fileName);
     m_snapshots.removeAt(index);
     if (index == m_currentIndex)
         m_currentIndex = -1;
-- 
GitLab