From 370c2d7787ec291565f4749e370fdecea77d12b1 Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Tue, 23 Jul 2024 09:52:12 +0200 Subject: [PATCH] Debugger: Fix snapshot handling Avoid sharing the workers with the engine creating the snapshot to avoid closing both when stopping the debugger engine for the snapshot. Correctly detach at finish to avoid having a runcontrol appearing still running. Fixes: QTCREATORBUG-31220 Change-Id: Iccb54b0fc2d7f5bf54b42a116e56c1a840b1f46e Reviewed-by: hjk --- src/plugins/debugger/debuggerruncontrol.cpp | 2 ++ src/plugins/projectexplorer/runcontrol.cpp | 6 ++++++ src/plugins/projectexplorer/runcontrol.h | 1 + 3 files changed, 9 insertions(+) diff --git a/src/plugins/debugger/debuggerruncontrol.cpp b/src/plugins/debugger/debuggerruncontrol.cpp index 007d3464bb8..f4f1405953e 100644 --- a/src/plugins/debugger/debuggerruncontrol.cpp +++ b/src/plugins/debugger/debuggerruncontrol.cpp @@ -575,9 +575,11 @@ void DebuggerRunTool::start() connect(engine, &DebuggerEngine::attachToCoreRequested, this, [this](const QString &coreFile) { auto rc = new RunControl(ProjectExplorer::Constants::DEBUG_RUN_MODE); rc->copyDataFromRunControl(runControl()); + rc->resetDataForAttachToCore(); auto name = QString(Tr::tr("%1 - Snapshot %2").arg(runControl()->displayName()).arg(++d->snapshotCounter)); auto debugger = new DebuggerRunTool(rc); debugger->setStartMode(AttachToCore); + debugger->setCloseMode(DetachAtClose); debugger->setRunControlName(name); debugger->setCoreFilePath(FilePath::fromString(coreFile), true); debugger->startRunControl(); diff --git a/src/plugins/projectexplorer/runcontrol.cpp b/src/plugins/projectexplorer/runcontrol.cpp index 5eac3498bcf..4dd364aaf0a 100644 --- a/src/plugins/projectexplorer/runcontrol.cpp +++ b/src/plugins/projectexplorer/runcontrol.cpp @@ -364,6 +364,12 @@ void RunControl::copyDataFromRunControl(RunControl *runControl) d->copyData(runControl->d.get()); } +void RunControl::resetDataForAttachToCore() +{ + d->m_workers.clear(); + d->state = RunControlState::Initialized; +} + void RunControl::copyDataFromRunConfiguration(RunConfiguration *runConfig) { QTC_ASSERT(runConfig, return); diff --git a/src/plugins/projectexplorer/runcontrol.h b/src/plugins/projectexplorer/runcontrol.h index 94288664361..b99439869ac 100644 --- a/src/plugins/projectexplorer/runcontrol.h +++ b/src/plugins/projectexplorer/runcontrol.h @@ -150,6 +150,7 @@ public: void copyDataFromRunConfiguration(RunConfiguration *runConfig); void copyDataFromRunControl(RunControl *runControl); + void resetDataForAttachToCore(); void setAutoDeleteOnStop(bool autoDelete);