Debugger: Restrict scope of stored signalOperation

It's only actively alive between the attempt to stop, and being
stopped. Having it stored in 'global' member variable was a
workaround in pre-lambda times.

Change-Id: I169745afd7985ed9038edff763026c32f82f6126
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2017-08-17 10:37:05 +02:00
parent 2a62a72c69
commit cf1edc1fb5
2 changed files with 14 additions and 25 deletions

View File

@@ -798,33 +798,26 @@ void GdbEngine::interruptInferior()
showMessage("TRYING TO INTERRUPT INFERIOR");
if (HostOsInfo::isWindowsHost() && !m_isQnxGdb) {
QTC_ASSERT(state() == InferiorStopRequested, qDebug() << state(); notifyInferiorStopFailed());
QTC_ASSERT(!m_signalOperation, notifyInferiorStopFailed());
m_signalOperation = runTool()->device()->signalOperation();
QTC_ASSERT(m_signalOperation, notifyInferiorStopFailed());
connect(m_signalOperation.data(), &DeviceProcessSignalOperation::finished,
this, &GdbEngine::handleInterruptDeviceInferior);
m_signalOperation->setDebuggerCommand(runParameters().debugger.executable);
m_signalOperation->interruptProcess(inferiorPid());
DeviceProcessSignalOperation::Ptr signalOperation = runTool()->device()->signalOperation();
QTC_ASSERT(signalOperation, notifyInferiorStopFailed(); return);
connect(signalOperation.data(), &DeviceProcessSignalOperation::finished,
this, [this, signalOperation](const QString &error) {
if (error.isEmpty()) {
showMessage("Interrupted " + QString::number(inferiorPid()));
notifyInferiorStopOk();
} else {
showMessage(error, LogError);
notifyInferiorStopFailed();
}
});
signalOperation->setDebuggerCommand(runParameters().debugger.executable);
signalOperation->interruptProcess(inferiorPid());
} else {
interruptInferior2();
}
}
}
void GdbEngine::handleInterruptDeviceInferior(const QString &error)
{
if (error.isEmpty()) {
showMessage("Interrupted " + QString::number(inferiorPid()));
notifyInferiorStopOk();
} else {
showMessage(error, LogError);
notifyInferiorStopFailed();
}
m_signalOperation->disconnect(this);
m_signalOperation.clear();
}
void GdbEngine::runCommand(const DebuggerCommand &command)
{
const int token = ++currentToken();