Changeset View
Changeset View
Standalone View
Standalone View
plugins/debuggercommon/midebugsession.cpp
Show First 20 Lines • Show All 47 Lines • ▼ Show 20 Line(s) | |||||
48 | #include <KLocalizedString> | 48 | #include <KLocalizedString> | ||
49 | #include <KMessageBox> | 49 | #include <KMessageBox> | ||
50 | #include <KSharedConfig> | 50 | #include <KSharedConfig> | ||
51 | #include <KShell> | 51 | #include <KShell> | ||
52 | 52 | | |||
53 | #include <QApplication> | 53 | #include <QApplication> | ||
54 | #include <QFileInfo> | 54 | #include <QFileInfo> | ||
55 | #include <QMetaEnum> | 55 | #include <QMetaEnum> | ||
56 | #include <QPointer> | | |||
57 | #include <QRegularExpression> | 56 | #include <QRegularExpression> | ||
58 | #include <QUrl> | 57 | #include <QUrl> | ||
59 | #include <QTimer> | 58 | #include <QTimer> | ||
60 | 59 | | |||
61 | using namespace KDevelop; | 60 | using namespace KDevelop; | ||
62 | using namespace KDevMI; | 61 | using namespace KDevMI; | ||
63 | using namespace KDevMI::MI; | 62 | using namespace KDevMI::MI; | ||
64 | 63 | | |||
▲ Show 20 Lines • Show All 484 Lines • ▼ Show 20 Line(s) | 547 | if (debuggerStateIsOn(s_attached)) { | |||
549 | addCommand(TargetDetach); | 548 | addCommand(TargetDetach); | ||
550 | emit debuggerUserCommandOutput(QStringLiteral("(gdb) detach\n")); | 549 | emit debuggerUserCommandOutput(QStringLiteral("(gdb) detach\n")); | ||
551 | } | 550 | } | ||
552 | 551 | | |||
553 | // Now try to stop debugger running. | 552 | // Now try to stop debugger running. | ||
554 | addCommand(GdbExit); | 553 | addCommand(GdbExit); | ||
555 | emit debuggerUserCommandOutput(QStringLiteral("(gdb) quit")); | 554 | emit debuggerUserCommandOutput(QStringLiteral("(gdb) quit")); | ||
556 | 555 | | |||
557 | // We cannot wait forever, kill gdb after 5 seconds if it's not yet quit | 556 | // We cannot wait forever, kill gdb after 5 seconds if it's not yet quit | ||
558 | QPointer<MIDebugSession> guarded_this(this); | 557 | QTimer::singleShot(5000, this, [this]() { | ||
antonanikin: Here we suppress warning instead of fixing because of suitable receiver missing. Maybe we can… | |||||
QTimer::singleShot(5000, this, [this]() {...} or what am I missing? When using the this as context object you can also simplify the lambda-body, i.e. remove the QPointer helper altogether. kfunk: `QTimer::singleShot(5000, this, [this]() {...}` or what am I missing?
When using the `this` as… | |||||
We can't use this here. On timeout our object (this) may be already destroyed. Therefore we use QPointer and check it for nullptr in lambda body. antonanikin: We can't use `this` here. On timeout our object (`this`) may be already destroyed. Therefore we… | |||||
Although I was wrong, sorry - we can (and should) use this here. Will update the revision. antonanikin: Although I was wrong, sorry - we can (and should) use `this` here. Will update the revision. | |||||
Yes, I think like this it should work. The QPointer was needed when QTimer::singleShotdidn't allow context objects (before Qt 5.4 iirc). kfunk: Yes, I think like this it should work. The `QPointer` was needed when `QTimer… | |||||
559 | QTimer::singleShot(5000, [guarded_this](){ | 558 | if (!debuggerStateIsOn(s_programExited) && debuggerStateIsOn(s_shuttingDown)) { | ||
560 | if (guarded_this) { | | |||
561 | if (!guarded_this->debuggerStateIsOn(s_programExited) | | |||
562 | && guarded_this->debuggerStateIsOn(s_shuttingDown)) { | | |||
563 | qCDebug(DEBUGGERCOMMON) << "debugger not shutdown - killing"; | 559 | qCDebug(DEBUGGERCOMMON) << "debugger not shutdown - killing"; | ||
564 | guarded_this->m_debugger->kill(); | 560 | m_debugger->kill(); | ||
565 | guarded_this->setDebuggerState(s_dbgNotStarted | s_appNotStarted); | 561 | setDebuggerState(s_dbgNotStarted | s_appNotStarted); | ||
566 | guarded_this->raiseEvent(debugger_exited); | 562 | raiseEvent(debugger_exited); | ||
567 | } | | |||
568 | } | 563 | } | ||
569 | }); | 564 | }); | ||
570 | 565 | | |||
571 | emit reset(); | 566 | emit reset(); | ||
572 | } | 567 | } | ||
573 | 568 | | |||
574 | void MIDebugSession::interruptDebugger() | 569 | void MIDebugSession::interruptDebugger() | ||
575 | { | 570 | { | ||
▲ Show 20 Lines • Show All 734 Lines • Show Last 20 Lines |
Here we suppress warning instead of fixing because of suitable receiver missing. Maybe we can use qApp as a receiver?