From ec9597b1606e48b10d1f4b6d4dcefd9c2592281e Mon Sep 17 00:00:00 2001
From: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Date: Mon, 5 Oct 2009 17:30:45 +0200
Subject: [PATCH] CDB: Restore current thread.

---
 src/plugins/debugger/cdb/cdbstacktracecontext.cpp | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/plugins/debugger/cdb/cdbstacktracecontext.cpp b/src/plugins/debugger/cdb/cdbstacktracecontext.cpp
index 3e5f1c65fcb..8cf72461fe4 100644
--- a/src/plugins/debugger/cdb/cdbstacktracecontext.cpp
+++ b/src/plugins/debugger/cdb/cdbstacktracecontext.cpp
@@ -226,6 +226,8 @@ static inline QString msgGetThreadStateFailed(unsigned long threadId, const QStr
     return QString::fromLatin1("Unable to determine the state of thread %1: %2").arg(threadId).arg(why);
 }
 
+// Determine information about thread. This changes the
+// current thread to thread->id.
 static inline bool getStoppedThreadState(const CdbComInterfaces &cif,
                                          ThreadData *t,
                                          QString *errorMessage)
@@ -315,6 +317,14 @@ bool CdbStackTraceContext::getThreads(const CdbComInterfaces &cif,
         }
         threads->push_back(threadData);
     }
+    // Restore thread id
+    if (isStopped && threads->back().id != *currentThreadId) {
+        hr = cif.debugSystemObjects->SetCurrentThreadId(*currentThreadId);
+        if (FAILED(hr)) {
+            *errorMessage= msgGetThreadsFailed(msgComFailed("SetCurrentThreadId", hr));
+            return false;
+        }
+    }
     return true;
 }
 
-- 
GitLab