diff options
author | Friedemann Kleint <Friedemann.Kleint@digia.com> | 2013-04-03 15:38:36 +0200 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@digia.com> | 2013-07-19 10:47:18 +0200 |
commit | 975021d7d292f70be41e85e604be45a1e9e2b430 (patch) | |
tree | e0ef9009c3333806d34e2bf0d2b92b4fdd5eedf9 | |
parent | 6456a0fc17d2d1ef96864b651fad107f4578bf33 (diff) | |
download | qt-creator-975021d7d292f70be41e85e604be45a1e9e2b430.tar.gz |
Debug support: Introduce factory function with error checking.
Change-Id: Iabd7b100c6d62093ac19088eaef4f74b35ad0ee3
Reviewed-by: Andrew Knight <andrew.knight@digia.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
-rw-r--r-- | src/plugins/winrt/winrtdebugsupport.cpp | 37 | ||||
-rw-r--r-- | src/plugins/winrt/winrtdebugsupport.h | 6 | ||||
-rw-r--r-- | src/plugins/winrt/winrtrunfactories.cpp | 6 |
3 files changed, 35 insertions, 14 deletions
diff --git a/src/plugins/winrt/winrtdebugsupport.cpp b/src/plugins/winrt/winrtdebugsupport.cpp index 278423afdf..1f43178a26 100644 --- a/src/plugins/winrt/winrtdebugsupport.cpp +++ b/src/plugins/winrt/winrtdebugsupport.cpp @@ -48,7 +48,14 @@ namespace WinRt { namespace Internal { // Wrapper for Debugger::RunControl, which gets initialized as the parent -WinRtDebugSupport::WinRtDebugSupport(WinRtRunConfiguration *rc, QString *errorMessage) +WinRtDebugSupport::WinRtDebugSupport(Debugger::DebuggerRunControl *rc) + : QObject(rc) // Die with runControl + , m_runControl(rc) +{ + connect(m_runControl, SIGNAL(finished()), SLOT(onDebuggerFinished())); +} + +Debugger::DebuggerRunControl *WinRtDebugSupport::createRunControl(WinRtRunConfiguration *rc, QString *errorMessage) { DebuggerStartParameters sp; sp.masterEngineType = CdbEngineType; @@ -56,12 +63,28 @@ WinRtDebugSupport::WinRtDebugSupport(WinRtRunConfiguration *rc, QString *errorMe sp.startMode = AttachExternal; sp.closeMode = KillAtClose; sp.languages = CppLanguage; - sp.debuggerCommand = DebuggerKitInformation::debuggerCommand(rc->target()->kit()).toString(); - sp.attachPID = startAppx(rc->activationID(), rc->arguments(), errorMessage); - - m_runControl = DebuggerPlugin::createDebugger(sp, rc, errorMessage); - setParent(m_runControl); // Die with runControl - connect(m_runControl, SIGNAL(finished()), SLOT(onDebuggerFinished())); + const ProjectExplorer::Kit *kit = rc->target()->kit(); + sp.masterEngineType = DebuggerKitInformation::engineType(kit); + if (sp.masterEngineType != CdbEngineType) { + *errorMessage = tr("No CDB-debugger configured in kit \"%1\".").arg(kit->displayName()); + return 0; + } + sp.debuggerCommand = DebuggerKitInformation::debuggerCommand(kit).toString(); + if (sp.debuggerCommand.isEmpty()) { + *errorMessage = tr("No debugger configured in kit \"%1\"").arg(kit->displayName()); + return 0; + } + sp.attachPID = WinRtDebugSupport::startAppx(rc->activationID(), rc->arguments(), errorMessage); + if (sp.attachPID < 0) + return 0; + + DebuggerRunControl *runControl = DebuggerPlugin::createDebugger(sp, rc, errorMessage); + if (!runControl) { + WinRtDebugSupport::stopAppx(sp.attachPID); + return 0; + } + new WinRtDebugSupport(runControl); + return runControl; } void WinRtDebugSupport::onDebuggerFinished() diff --git a/src/plugins/winrt/winrtdebugsupport.h b/src/plugins/winrt/winrtdebugsupport.h index e458079f2a..8037c02a2b 100644 --- a/src/plugins/winrt/winrtdebugsupport.h +++ b/src/plugins/winrt/winrtdebugsupport.h @@ -40,14 +40,12 @@ namespace WinRt { namespace Internal { class WinRtRunConfiguration; -class WinRTRunner; class WinRtDebugSupport : public QObject { Q_OBJECT public: - WinRtDebugSupport(WinRtRunConfiguration *rc, QString *errorMessage); - Debugger::DebuggerRunControl *runControl() const { return m_runControl; } + static Debugger::DebuggerRunControl *createRunControl(WinRtRunConfiguration *rc, QString *errorMessage); static qint64 startAppx(const QString &activationID, const QString &arguments, QString *errorMessage = nullptr); @@ -58,6 +56,8 @@ private slots: void onDebuggerFinished(); private: + explicit WinRtDebugSupport(Debugger::DebuggerRunControl *); + Debugger::DebuggerRunControl *m_runControl; }; diff --git a/src/plugins/winrt/winrtrunfactories.cpp b/src/plugins/winrt/winrtrunfactories.cpp index 7d4fbe9fa2..723ae40d9d 100644 --- a/src/plugins/winrt/winrtrunfactories.cpp +++ b/src/plugins/winrt/winrtrunfactories.cpp @@ -131,10 +131,8 @@ ProjectExplorer::RunControl *WinRtRunControlFactory::create( switch (mode) { case NormalRunMode: return new WinRtRunControl(rc, mode); - case DebugRunMode: { - WinRtDebugSupport *debugger = new WinRtDebugSupport(rc, errorMessage); - return debugger->runControl(); - } + case DebugRunMode: + return WinRtDebugSupport::createRunControl(rc, errorMessage); default: break; } |