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 <hjk@qt.io>
This commit is contained in:
Christian Stenger
2024-07-23 09:52:12 +02:00
parent 7b4b1e2a72
commit 370c2d7787
3 changed files with 9 additions and 0 deletions

View File

@@ -575,9 +575,11 @@ void DebuggerRunTool::start()
connect(engine, &DebuggerEngine::attachToCoreRequested, this, [this](const QString &coreFile) { connect(engine, &DebuggerEngine::attachToCoreRequested, this, [this](const QString &coreFile) {
auto rc = new RunControl(ProjectExplorer::Constants::DEBUG_RUN_MODE); auto rc = new RunControl(ProjectExplorer::Constants::DEBUG_RUN_MODE);
rc->copyDataFromRunControl(runControl()); rc->copyDataFromRunControl(runControl());
rc->resetDataForAttachToCore();
auto name = QString(Tr::tr("%1 - Snapshot %2").arg(runControl()->displayName()).arg(++d->snapshotCounter)); auto name = QString(Tr::tr("%1 - Snapshot %2").arg(runControl()->displayName()).arg(++d->snapshotCounter));
auto debugger = new DebuggerRunTool(rc); auto debugger = new DebuggerRunTool(rc);
debugger->setStartMode(AttachToCore); debugger->setStartMode(AttachToCore);
debugger->setCloseMode(DetachAtClose);
debugger->setRunControlName(name); debugger->setRunControlName(name);
debugger->setCoreFilePath(FilePath::fromString(coreFile), true); debugger->setCoreFilePath(FilePath::fromString(coreFile), true);
debugger->startRunControl(); debugger->startRunControl();

View File

@@ -364,6 +364,12 @@ void RunControl::copyDataFromRunControl(RunControl *runControl)
d->copyData(runControl->d.get()); d->copyData(runControl->d.get());
} }
void RunControl::resetDataForAttachToCore()
{
d->m_workers.clear();
d->state = RunControlState::Initialized;
}
void RunControl::copyDataFromRunConfiguration(RunConfiguration *runConfig) void RunControl::copyDataFromRunConfiguration(RunConfiguration *runConfig)
{ {
QTC_ASSERT(runConfig, return); QTC_ASSERT(runConfig, return);

View File

@@ -150,6 +150,7 @@ public:
void copyDataFromRunConfiguration(RunConfiguration *runConfig); void copyDataFromRunConfiguration(RunConfiguration *runConfig);
void copyDataFromRunControl(RunControl *runControl); void copyDataFromRunControl(RunControl *runControl);
void resetDataForAttachToCore();
void setAutoDeleteOnStop(bool autoDelete); void setAutoDeleteOnStop(bool autoDelete);