diff options
author | Friedemann Kleint <Friedemann.Kleint@nokia.com> | 2009-10-07 13:36:48 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@nokia.com> | 2009-10-07 13:36:48 +0200 |
commit | 1fb8f60e03a267941822eb96ab8e6faedc6036f1 (patch) | |
tree | 3c126217e810a38919212ab7d915972011ac3f1d /src/plugins | |
parent | e2e9c773231ced6419dacc5edce273bf55912932 (diff) | |
download | qt-creator-1fb8f60e03a267941822eb96ab8e6faedc6036f1.tar.gz |
Debugger: Fix crash toggling Stack/"Derefence Pointers" without project
Enable debugger actions correctly.
Reviewed-by: hjk <qtc-committer@nokia.com>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/debugger/breakwindow.cpp | 2 | ||||
-rw-r--r-- | src/plugins/debugger/debuggermanager.cpp | 40 | ||||
-rw-r--r-- | src/plugins/debugger/debuggermanager.h | 2 | ||||
-rw-r--r-- | src/plugins/debugger/moduleswindow.cpp | 8 | ||||
-rw-r--r-- | src/plugins/debugger/registerwindow.cpp | 1 | ||||
-rw-r--r-- | src/plugins/debugger/sourcefileswindow.cpp | 2 | ||||
-rw-r--r-- | src/plugins/debugger/stackhandler.cpp | 1 | ||||
-rw-r--r-- | src/plugins/debugger/stackwindow.cpp | 5 | ||||
-rw-r--r-- | src/plugins/debugger/watchwindow.cpp | 11 |
9 files changed, 62 insertions, 10 deletions
diff --git a/src/plugins/debugger/breakwindow.cpp b/src/plugins/debugger/breakwindow.cpp index 46dc6faac7..b0edd85545 100644 --- a/src/plugins/debugger/breakwindow.cpp +++ b/src/plugins/debugger/breakwindow.cpp @@ -30,6 +30,7 @@ #include "breakwindow.h" #include "debuggeractions.h" +#include "debuggermanager.h" #include "ui_breakcondition.h" #include "ui_breakbyfunction.h" @@ -179,6 +180,7 @@ void BreakWindow::contextMenuEvent(QContextMenuEvent *ev) editConditionAction->setEnabled(si.size() > 0); QAction *synchronizeAction = new QAction(tr("Synchronize breakpoints"), &menu); + synchronizeAction->setEnabled(Debugger::DebuggerManager::instance()->debuggerActionsEnabled()); QModelIndex idx0 = (si.size() ? si.front() : QModelIndex()); QModelIndex idx2 = idx0.sibling(idx0.row(), 2); diff --git a/src/plugins/debugger/debuggermanager.cpp b/src/plugins/debugger/debuggermanager.cpp index a90d143f9d..7d96912c8a 100644 --- a/src/plugins/debugger/debuggermanager.cpp +++ b/src/plugins/debugger/debuggermanager.cpp @@ -1684,11 +1684,51 @@ void DebuggerManager::setState(DebuggerState state) d->m_actions.runToFunctionAction->setEnabled(stopped); d->m_actions.jumpToLineAction->setEnabled(stopped); d->m_actions.nextAction->setEnabled(stopped); + + const bool actionsEnabled = debuggerActionsEnabled(); + theDebuggerAction(RecheckDebuggingHelpers)->setEnabled(actionsEnabled); + theDebuggerAction(AutoDerefPointers)->setEnabled(actionsEnabled && d->m_engine->isGdbEngine()); + theDebuggerAction(ExpandStack)->setEnabled(actionsEnabled); + theDebuggerAction(ExecuteCommand)->setEnabled(d->m_state != DebuggerNotReady); + emit stateChanged(d->m_state); const bool notbusy = state == InferiorStopped || state == DebuggerNotReady || state == InferiorUnrunnable; setBusyCursor(!notbusy); + +} + +bool DebuggerManager::debuggerActionsEnabled() const +{ + if (!d->m_engine) + return false; + switch (state()) { + case InferiorPrepared: + case InferiorStarting: + case InferiorRunningRequested: + case InferiorRunning: + case InferiorUnrunnable: + case InferiorStopping: + case InferiorStopped: + return true; + case DebuggerNotReady: + case EngineStarting: + case AdapterStarting: + case AdapterStarted: + case AdapterStartFailed: + case InferiorPreparing: + case InferiorPreparationFailed: + case InferiorStartFailed: + case InferiorStopFailed: + case InferiorShuttingDown: + case InferiorShutDown: + case InferiorShutdownFailed: + case AdapterShuttingDown: + case AdapterShutdownFailed: + break; + } + return false; } QDebug operator<<(QDebug d, DebuggerState state) diff --git a/src/plugins/debugger/debuggermanager.h b/src/plugins/debugger/debuggermanager.h index 7579ebd722..ee7f439ba9 100644 --- a/src/plugins/debugger/debuggermanager.h +++ b/src/plugins/debugger/debuggermanager.h @@ -175,6 +175,8 @@ public: void showMessageBox(int icon, const QString &title, const QString &text); + bool debuggerActionsEnabled() const; + static DebuggerManager *instance(); public slots: diff --git a/src/plugins/debugger/moduleswindow.cpp b/src/plugins/debugger/moduleswindow.cpp index f5d48db088..6d46dda03c 100644 --- a/src/plugins/debugger/moduleswindow.cpp +++ b/src/plugins/debugger/moduleswindow.cpp @@ -105,11 +105,15 @@ void ModulesWindow::contextMenuEvent(QContextMenuEvent *ev) if (index.isValid()) name = model()->data(index).toString(); + QMenu menu; + const bool enabled = Debugger::DebuggerManager::instance()->debuggerActionsEnabled(); QAction *act0 = new QAction(tr("Update module list"), &menu); - QAction *act3 = new QAction(tr("Show source files for module \"%1\"").arg(name), - &menu); + act0->setEnabled(enabled); + QAction *act3 = new QAction(tr("Show source files for module \"%1\"").arg(name), &menu); + act3->setEnabled(enabled); QAction *act4 = new QAction(tr("Load symbols for all modules"), &menu); + act4->setEnabled(enabled); QAction *act5 = 0; QAction *act6 = 0; QAction *act7 = 0; diff --git a/src/plugins/debugger/registerwindow.cpp b/src/plugins/debugger/registerwindow.cpp index 3bc52f2945..ddaedbd808 100644 --- a/src/plugins/debugger/registerwindow.cpp +++ b/src/plugins/debugger/registerwindow.cpp @@ -177,6 +177,7 @@ void RegisterWindow::contextMenuEvent(QContextMenuEvent *ev) } else { actShowMemory->setText(tr("Open memory editor at %1").arg(address)); } + actShowMemory->setEnabled(m_manager->debuggerActionsEnabled()); menu.addSeparator(); int base = model()->data(QModelIndex(), RegisterNumberBaseRole).toInt(); diff --git a/src/plugins/debugger/sourcefileswindow.cpp b/src/plugins/debugger/sourcefileswindow.cpp index 5a9f5b5151..52341c6285 100644 --- a/src/plugins/debugger/sourcefileswindow.cpp +++ b/src/plugins/debugger/sourcefileswindow.cpp @@ -29,6 +29,7 @@ #include "sourcefileswindow.h" #include "debuggeractions.h" +#include "debuggermanager.h" #include <QtCore/QDebug> #include <QtCore/QFileInfo> @@ -199,6 +200,7 @@ void SourceFilesWindow::contextMenuEvent(QContextMenuEvent *ev) QMenu menu; QAction *act1 = new QAction(tr("Reload data"), &menu); + act1->setEnabled(Debugger::DebuggerManager::instance()->debuggerActionsEnabled()); //act1->setCheckable(true); QAction *act2 = 0; if (name.isEmpty()) { diff --git a/src/plugins/debugger/stackhandler.cpp b/src/plugins/debugger/stackhandler.cpp index a12367df9a..2d9cbea92d 100644 --- a/src/plugins/debugger/stackhandler.cpp +++ b/src/plugins/debugger/stackhandler.cpp @@ -240,6 +240,7 @@ bool StackHandler::isDebuggingDebuggingHelpers() const ThreadData::ThreadData(int threadId) : id(threadId), + address(0), line(-1) { } diff --git a/src/plugins/debugger/stackwindow.cpp b/src/plugins/debugger/stackwindow.cpp index d854a5edaf..910f69ea35 100644 --- a/src/plugins/debugger/stackwindow.cpp +++ b/src/plugins/debugger/stackwindow.cpp @@ -102,7 +102,7 @@ void StackWindow::contextMenuEvent(QContextMenuEvent *ev) actShowMemory->setEnabled(false); } else { actShowMemory->setText(tr("Open memory editor at %1").arg(address)); - } + } QAction *actShowDisassembler = menu.addAction(QString()); if (address.isEmpty()) { @@ -113,8 +113,9 @@ void StackWindow::contextMenuEvent(QContextMenuEvent *ev) } menu.addSeparator(); - +#if 0 // @TODO: not implemented menu.addAction(theDebuggerAction(UseToolTipsInStackView)); +#endif menu.addAction(theDebuggerAction(UseAddressInStackView)); QAction *actAdjust = menu.addAction(tr("Adjust column widths to contents")); diff --git a/src/plugins/debugger/watchwindow.cpp b/src/plugins/debugger/watchwindow.cpp index f40bb93085..db3f33057b 100644 --- a/src/plugins/debugger/watchwindow.cpp +++ b/src/plugins/debugger/watchwindow.cpp @@ -245,16 +245,15 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev) } QMenu menu; - //QAction *actWatchExpressionInWindow - // = theDebuggerAction(WatchExpressionInWindow); - //menu.addAction(actWatchExpressionInWindow); QAction *actInsertNewWatchItem = menu.addAction(tr("Insert new watch item")); QAction *actSelectWidgetToWatch = menu.addAction(tr("Select widget to watch")); const QString address = model()->data(mi0, AddressRole).toString(); QAction *actWatchKnownMemory = 0; - QAction *actWatchUnknownMemory = new QAction(tr("Open memory editor..."), &menu);; + QAction *actWatchUnknownMemory = new QAction(tr("Open memory editor..."), &menu); + actWatchUnknownMemory->setEnabled(m_manager->debuggerActionsEnabled()); + if (!address.isEmpty()) actWatchKnownMemory = new QAction(tr("Open memory editor at %1").arg(address), &menu); menu.addSeparator(); @@ -270,6 +269,7 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev) menu.addAction(actWatchKnownMemory); menu.addAction(actWatchUnknownMemory); menu.addSeparator(); + menu.addAction(theDebuggerAction(RecheckDebuggingHelpers)); menu.addAction(theDebuggerAction(UseDebuggingHelpers)); @@ -277,8 +277,7 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev) menu.addAction(theDebuggerAction(UseToolTipsInLocalsView)); menu.addAction(theDebuggerAction(AutoDerefPointers)); - theDebuggerAction(AutoDerefPointers)-> - setEnabled(m_manager->currentEngine()->isGdbEngine()); + QAction *actAdjustColumnWidths = menu.addAction(tr("Adjust column widths to contents")); QAction *actAlwaysAdjustColumnWidth = |