OSDN Git Service

Debugger: Disable "Start debugging" when attaching/starting remote
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>
Mon, 2 Nov 2009 11:47:47 +0000 (12:47 +0100)
committercon <qtc-committer@nokia.com>
Mon, 2 Nov 2009 19:41:59 +0000 (20:41 +0100)
Directly enable project explorer actions.
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
(cherry picked from commit c069cd588af0cdc335ec2ed909281a0bf9da666b)

src/plugins/debugger/debuggerplugin.cpp
src/plugins/debugger/debuggerplugin.h

index 9cbf5d3..3d296ee 100644 (file)
@@ -484,7 +484,8 @@ DebuggerPlugin::DebuggerPlugin()
     m_cmdLineEnabledEngines(AllEngineTypes),
     m_cmdLineAttachPid(0),
     m_cmdLineWinCrashEvent(0),
-    m_toggleLockedAction(0)
+    m_toggleLockedAction(0),
+    m_peStartDebuggingAction(0)
 {}
 
 DebuggerPlugin::~DebuggerPlugin()
@@ -669,6 +670,10 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess
     Core::ActionContainer *mstart =
         am->actionContainer(ProjectExplorer::Constants::M_DEBUG_STARTDEBUGGING);
 
+    // Register an action "Continue" under a different context  (Gdb Running)
+    // in the action manager under the "Start Debugging" action's id.
+    // Activating this context will then cause the "Start Debugging" action
+    // to switch to "Continue".
     Core::Command *cmd = 0;
     const DebuggerManagerActions actions = m_manager->debuggerManagerActions();
     cmd = am->registerAction(actions.continueAction,
@@ -804,6 +809,14 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess
     connect(resetToSimpleAction, SIGNAL(triggered()),
         m_manager, SLOT(setSimpleDockWidgetArrangement()));
 
+    // Retrieve "Start debugging" action from Project explorer.
+    if (const Core::Command *dcmd = am->command(QLatin1String(ProjectExplorer::Constants::DEBUG))) {
+        m_peStartDebuggingAction = dcmd->action();
+    } else {
+        *errorMessage = QLatin1String("Internal error: Cannot access external actions");
+        return false;
+    }
+
     // FIXME:
     addAutoReleasedObject(new CommonOptionsPage);
     addAutoReleasedObject(new DebuggingHelperOptionPage);
@@ -1157,6 +1170,7 @@ void DebuggerPlugin::handleStateChanged(int state)
     } else {
         core->removeAdditionalContext(m_gdbRunningContext);
         core->updateContext();
+        m_peStartDebuggingAction->setEnabled(state == DebuggerNotReady);        
     }
 
     const bool started = state == InferiorRunning
index 1e1af9c..449c2af 100644 (file)
@@ -143,6 +143,7 @@ private:
     QAction *m_attachExternalAction;
     QAction *m_attachCoreAction;
     QAction *m_detachAction;
+    QAction *m_peStartDebuggingAction;
 };
 
 } // namespace Internal