forked from qt-creator/qt-creator
debugger: make Add to Watchwindow menu entry work again
This commit is contained in:
@@ -35,6 +35,7 @@
|
|||||||
#include "debuggerconstants.h"
|
#include "debuggerconstants.h"
|
||||||
#include "idebuggerengine.h"
|
#include "idebuggerengine.h"
|
||||||
#include "debuggerstringutils.h"
|
#include "debuggerstringutils.h"
|
||||||
|
#include "watchutils.h"
|
||||||
|
|
||||||
#include "breakwindow.h"
|
#include "breakwindow.h"
|
||||||
#include "debuggeroutputwindow.h"
|
#include "debuggeroutputwindow.h"
|
||||||
@@ -57,13 +58,16 @@
|
|||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
# include "shared/peutils.h"
|
# include "shared/peutils.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/fancymainwindow.h>
|
#include <utils/fancymainwindow.h>
|
||||||
#include <projectexplorer/toolchain.h>
|
#include <projectexplorer/toolchain.h>
|
||||||
#include <cplusplus/CppDocument.h>
|
#include <cplusplus/CppDocument.h>
|
||||||
#include <cpptools/cppmodelmanagerinterface.h>
|
#include <cpptools/cppmodelmanagerinterface.h>
|
||||||
#include <qt4projectmanager/qt4projectmanagerconstants.h>
|
#include <qt4projectmanager/qt4projectmanagerconstants.h>
|
||||||
|
#include <texteditor/itexteditor.h>
|
||||||
|
|
||||||
#include <QtCore/QDebug>
|
#include <QtCore/QDebug>
|
||||||
#include <QtCore/QDir>
|
#include <QtCore/QDir>
|
||||||
@@ -1178,14 +1182,31 @@ void DebuggerManager::dumpLog()
|
|||||||
|
|
||||||
void DebuggerManager::addToWatchWindow()
|
void DebuggerManager::addToWatchWindow()
|
||||||
{
|
{
|
||||||
|
using namespace Core;
|
||||||
|
using namespace TextEditor;
|
||||||
// requires a selection, but that's the only case we want...
|
// requires a selection, but that's the only case we want...
|
||||||
QObject *ob = 0;
|
EditorManager *editorManager = EditorManager::instance();
|
||||||
queryCurrentTextEditor(0, 0, &ob);
|
if (!editorManager)
|
||||||
QPlainTextEdit *editor = qobject_cast<QPlainTextEdit*>(ob);
|
return;
|
||||||
|
IEditor *editor = editorManager->currentEditor();
|
||||||
if (!editor)
|
if (!editor)
|
||||||
return;
|
return;
|
||||||
QTextCursor tc = editor->textCursor();
|
ITextEditor *textEditor = qobject_cast<ITextEditor*>(editor);
|
||||||
theDebuggerAction(WatchExpression)->setValue(tc.selectedText());
|
if (!textEditor)
|
||||||
|
return;
|
||||||
|
QTextCursor tc;
|
||||||
|
QPlainTextEdit *ptEdit = qobject_cast<QPlainTextEdit*>(editor->widget());
|
||||||
|
if (ptEdit)
|
||||||
|
tc = ptEdit->textCursor();
|
||||||
|
QString exp;
|
||||||
|
if (tc.hasSelection()) {
|
||||||
|
exp = tc.selectedText();
|
||||||
|
} else {
|
||||||
|
int line, column;
|
||||||
|
exp = cppExpressionAt(textEditor, tc.position(), &line, &column);
|
||||||
|
}
|
||||||
|
if (!exp.isEmpty())
|
||||||
|
d->m_watchHandler->watchExpression(exp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerManager::setBreakpoint(const QString &fileName, int lineNumber)
|
void DebuggerManager::setBreakpoint(const QString &fileName, int lineNumber)
|
||||||
@@ -1647,7 +1668,7 @@ void DebuggerManager::setState(DebuggerState state, bool forced)
|
|||||||
if (stopped)
|
if (stopped)
|
||||||
QApplication::alert(mainWindow(), 3000);
|
QApplication::alert(mainWindow(), 3000);
|
||||||
|
|
||||||
d->m_actions.watchAction->setEnabled(stopped);
|
d->m_actions.watchAction->setEnabled(true);
|
||||||
d->m_actions.breakAction->setEnabled(true);
|
d->m_actions.breakAction->setEnabled(true);
|
||||||
|
|
||||||
bool interruptIsExit = !running;
|
bool interruptIsExit = !running;
|
||||||
|
@@ -803,8 +803,14 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess
|
|||||||
|
|
||||||
cmd = am->registerAction(actions.watchAction,
|
cmd = am->registerAction(actions.watchAction,
|
||||||
Constants::ADD_TO_WATCH, cppeditorcontext);
|
Constants::ADD_TO_WATCH, cppeditorcontext);
|
||||||
//cmd->setDefaultKeySequence(QKeySequence(tr("ALT+D,ALT+W")));
|
cmd->action()->setEnabled(true);
|
||||||
|
cmd->setDefaultKeySequence(QKeySequence(tr("ALT+D,ALT+W")));
|
||||||
mdebug->addAction(cmd);
|
mdebug->addAction(cmd);
|
||||||
|
// QTCREATORBUG-342 asks for that unconditionally
|
||||||
|
//ActionContainer *editorContextMenu =
|
||||||
|
// am->actionContainer(CppEditor::Constants::M_CONTEXT);
|
||||||
|
//editorContextMenu->addAction(cmd);
|
||||||
|
//cmd->setAttribute(Command::CA_Hide);
|
||||||
|
|
||||||
// Views menu
|
// Views menu
|
||||||
cmd = am->registerAction(sep, QLatin1String("Debugger.Sep.Views"), globalcontext);
|
cmd = am->registerAction(sep, QLatin1String("Debugger.Sep.Views"), globalcontext);
|
||||||
|
Reference in New Issue
Block a user