diff options
-rw-r--r-- | src/plugins/debugger/cdb/cdbengine.cpp | 4 | ||||
-rw-r--r-- | src/plugins/debugger/gdb/gdbengine.cpp | 7 | ||||
-rw-r--r-- | src/plugins/debugger/lldb/lldbengine.cpp | 2 | ||||
-rw-r--r-- | src/plugins/debugger/threadshandler.cpp | 13 | ||||
-rw-r--r-- | src/plugins/debugger/threadshandler.h | 3 |
5 files changed, 11 insertions, 18 deletions
diff --git a/src/plugins/debugger/cdb/cdbengine.cpp b/src/plugins/debugger/cdb/cdbengine.cpp index 05708c6ca4..f9c7aee4f4 100644 --- a/src/plugins/debugger/cdb/cdbengine.cpp +++ b/src/plugins/debugger/cdb/cdbengine.cpp @@ -1002,7 +1002,7 @@ void CdbEngine::handleThreads(const DebuggerResponse &response) qPrintable(DebuggerResponse::stringFromResultClass(response.resultClass))); } if (response.resultClass == ResultDone) { - threadsHandler()->updateThreads(response.data); + threadsHandler()->setThreads(response.data); // Continue sequence reloadFullStack(); } else { @@ -1866,7 +1866,7 @@ void CdbEngine::processStop(const GdbMi &stopReason, bool conditionalBreakPointT } const GdbMi threads = stopReason["threads"]; if (threads.isValid()) { - threadsHandler()->updateThreads(threads); + threadsHandler()->setThreads(threads); if (forcedThread) threadsHandler()->setCurrentThread(forcedThread); } else { diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index 321e3a15a3..060e3b223e 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -2983,12 +2983,7 @@ void GdbEngine::handleThreadInfo(const DebuggerResponse &response) { if (response.resultClass == ResultDone) { ThreadsHandler *handler = threadsHandler(); - handler->updateThreads(response.data); - // This is necessary as the current thread might not be in the list. - if (!handler->currentThread()) { - if (Thread other = handler->threadAt(0)) - selectThread(other); - } + handler->setThreads(response.data); updateState(false); // Adjust Threads combobox. if (boolSetting(ShowThreadNames)) { runCommand({"threadnames " + action(MaximalStackDepth)->value().toString(), diff --git a/src/plugins/debugger/lldb/lldbengine.cpp b/src/plugins/debugger/lldb/lldbengine.cpp index a01c25559f..9d024cef97 100644 --- a/src/plugins/debugger/lldb/lldbengine.cpp +++ b/src/plugins/debugger/lldb/lldbengine.cpp @@ -656,7 +656,7 @@ void LldbEngine::updateAll() { DebuggerCommand cmd("fetchThreads"); cmd.callback = [this](const DebuggerResponse &response) { - threadsHandler()->updateThreads(response.data); + threadsHandler()->setThreads(response.data); fetchStack(action(MaximalStackDepth)->value().toInt()); reloadRegisters(); }; diff --git a/src/plugins/debugger/threadshandler.cpp b/src/plugins/debugger/threadshandler.cpp index 958a41ebd5..aa3e95c5c2 100644 --- a/src/plugins/debugger/threadshandler.cpp +++ b/src/plugins/debugger/threadshandler.cpp @@ -282,12 +282,6 @@ Thread ThreadsHandler::currentThread() const return m_currentThread; } -Thread ThreadsHandler::threadAt(int index) const -{ - QTC_ASSERT(index >= 0 && index < rootItem()->childCount(), return Thread()); - return rootItem()->childAt(index); -} - void ThreadsHandler::setCurrentThread(const Thread &thread) { if (thread == m_currentThread) @@ -368,8 +362,10 @@ void ThreadsHandler::notifyStopped(const QString &id) thread->notifyStopped(); } -void ThreadsHandler::updateThreads(const GdbMi &data) +void ThreadsHandler::setThreads(const GdbMi &data) { + rootItem()->removeChildren(); + // ^done,threads=[{id="1",target-id="Thread 0xb7fdc710 (LWP 4264)", // frame={level="0",addr="0x080530bf",func="testQString",args=[], // file="/.../app.cpp",fullname="/../app.cpp",line="1175"}, @@ -396,6 +392,9 @@ void ThreadsHandler::updateThreads(const GdbMi &data) const QString ¤tId = data["current-thread-id"].data(); m_currentThread = threadForId(currentId); + + if (!m_currentThread && !items.isEmpty()) + m_currentThread = rootItem()->childAt(0); } QAbstractItemModel *ThreadsHandler::model() diff --git a/src/plugins/debugger/threadshandler.h b/src/plugins/debugger/threadshandler.h index 8801c52116..82082fb747 100644 --- a/src/plugins/debugger/threadshandler.h +++ b/src/plugins/debugger/threadshandler.h @@ -79,13 +79,12 @@ public: int currentThreadIndex() const; Thread currentThread() const; - Thread threadAt(int index) const; Thread threadForId(const QString &id) const; void setCurrentThread(const Thread &thread); QString pidForGroupId(const QString &groupId) const; void updateThread(const ThreadData &threadData); - void updateThreads(const GdbMi &data); + void setThreads(const GdbMi &data); void removeThread(const QString &id); void removeAll(); |