diff options
author | hjk <hjk@qt.io> | 2017-08-17 10:37:05 +0200 |
---|---|---|
committer | hjk <hjk@qt.io> | 2017-08-17 10:04:34 +0000 |
commit | cf1edc1fb536287c1cb9760014c5dab9690bbf6a (patch) | |
tree | 5b907c5c3134be8cc089d57e70de2bcb585eee8e | |
parent | 2a62a72c6964513b845f6e7bd4e10a0a47c5eb88 (diff) |
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>
-rw-r--r-- | src/plugins/debugger/gdb/gdbengine.cpp | 35 | ||||
-rw-r--r-- | src/plugins/debugger/gdb/gdbengine.h | 4 |
2 files changed, 14 insertions, 25 deletions
diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index fd3f8892f3..53c00cbfd4 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -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(); diff --git a/src/plugins/debugger/gdb/gdbengine.h b/src/plugins/debugger/gdb/gdbengine.h index 70abb82f1e..3a5a9d6645 100644 --- a/src/plugins/debugger/gdb/gdbengine.h +++ b/src/plugins/debugger/gdb/gdbengine.h @@ -36,12 +36,10 @@ #include <coreplugin/id.h> -#include <projectexplorer/devicesupport/idevice.h> #include <utils/qtcprocess.h> #include <QProcess> #include <QTextCodec> -#include <QTime> #include <QTimer> #include <functional> @@ -128,7 +126,6 @@ protected: ////////// Gdb Process Management ////////// private: friend class GdbPlainEngine; friend class GdbCoreEngine; - void handleInterruptDeviceInferior(const QString &error); void handleGdbFinished(int exitCode, QProcess::ExitStatus exitStatus); void handleGdbError(QProcess::ProcessError error); void readGdbStandardOutput(); @@ -422,7 +419,6 @@ protected: protected: Utils::QtcProcess m_gdbProc; QString m_errorString; - ProjectExplorer::DeviceProcessSignalOperation::Ptr m_signalOperation; }; } // namespace Internal |