Commit 1fb8f60e authored by Friedemann Kleint's avatar Friedemann Kleint
Browse files

Debugger: Fix crash toggling Stack/"Derefence Pointers" without project



Enable debugger actions correctly.
Reviewed-by: default avatarhjk <qtc-committer@nokia.com>
parent e2e9c773
......@@ -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);
......
......@@ -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)
......
......@@ -175,6 +175,8 @@ public:
void showMessageBox(int icon, const QString &title, const QString &text);
bool debuggerActionsEnabled() const;
static DebuggerManager *instance();
public slots:
......
......@@ -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;
......
......@@ -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();
......
......@@ -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()) {
......
......@@ -240,6 +240,7 @@ bool StackHandler::isDebuggingDebuggingHelpers() const
ThreadData::ThreadData(int threadId) :
id(threadId),
address(0),
line(-1)
{
}
......
......@@ -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"));
......
......@@ -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 =
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment