diff --git a/src/plugins/debugger/debuggeractions.cpp b/src/plugins/debugger/debuggeractions.cpp index b0211a0c328af89466d364a0328e0b8e3eef7cc9..266be5df5d6630db1db94b042af774f8757aad00 100644 --- a/src/plugins/debugger/debuggeractions.cpp +++ b/src/plugins/debugger/debuggeractions.cpp @@ -243,21 +243,6 @@ DebuggerSettings *DebuggerSettings::instance() // // Locals & Watchers // - item = new SavedAction(instance); - item->setTextPattern(tr("Watch Expression \"%1\"")); - instance->insertItem(WatchExpression, item); - - item = new SavedAction(instance); - item->setTextPattern(tr("Remove Watch Expression \"%1\"")); - instance->insertItem(RemoveWatchExpression, item); - - item = new SavedAction(instance); - item->setTextPattern(tr("Watch Expression \"%1\" in Separate Window")); - instance->insertItem(WatchExpressionInWindow, item); - - item = new SavedAction(instance); - instance->insertItem(WatchPoint, item); - item = new SavedAction(instance); item->setSettingsKey(debugModeGroup, QLatin1String("ShowStandardNamespace")); item->setText(tr("Show \"std::\" Namespace in Types")); diff --git a/src/plugins/debugger/debuggeractions.h b/src/plugins/debugger/debuggeractions.h index 86c11ac93e65c5d95076e5d621310f546c4168db..6cd956253e9846ab8267c0b7b1b9b546e91e2872 100644 --- a/src/plugins/debugger/debuggeractions.h +++ b/src/plugins/debugger/debuggeractions.h @@ -123,10 +123,6 @@ enum DebuggerActionCode CreateFullBacktrace, // Watchers & Locals - WatchExpression, - WatchExpressionInWindow, - RemoveWatchExpression, - WatchPoint, ShowStdNamespace, ShowQtNamespace, diff --git a/src/plugins/debugger/debuggerconstants.h b/src/plugins/debugger/debuggerconstants.h index 589566041839dbeb0c7b88a9cc68507e752fc2c6..bd8a9c42148d9f8eb29c8a2bfbc832a52b97dc27 100644 --- a/src/plugins/debugger/debuggerconstants.h +++ b/src/plugins/debugger/debuggerconstants.h @@ -217,6 +217,8 @@ enum ModelRoles RequestClearCppCodeModelSnapshotRole, RequestAssignValueRole, RequestAssignTypeRole, + RequestWatchExpressionRole, + RequestRemoveWatchExpressionRole, // Stack StackFrameAddressRole, diff --git a/src/plugins/debugger/debuggerengine.h b/src/plugins/debugger/debuggerengine.h index 63c3691391c650ae71d1074972eaabefadf721d3..ad7172736368a8da9784925755b0979bc4c967e8 100644 --- a/src/plugins/debugger/debuggerengine.h +++ b/src/plugins/debugger/debuggerengine.h @@ -253,7 +253,6 @@ public slots: void quitDebugger() { exitDebugger(); } protected: - friend class WatchHandler; void setState(DebuggerState state, bool forced = false); private: diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index 7ee5e70f3d2b721cf06dd6bed15cf5dbd2281d35..fd47e63794453cf228a9b6a9fa129cfcaa2cce37 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -1128,7 +1128,6 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments, QString *er m_actions.reverseDirectionAction->setCheckable(false); theDebuggerAction(OperateByInstruction)-> setProperty(Role, RequestOperatedByInstructionTriggeredRole); - theDebuggerAction(WatchPoint)->setProperty(Role, RequestWatchPointRole); connect(m_actions.continueAction, SIGNAL(triggered()), SLOT(onAction())); connect(m_actions.nextAction, SIGNAL(triggered()), SLOT(onAction())); @@ -1149,7 +1148,6 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments, QString *er connect(m_actions.resetAction, SIGNAL(triggered()), SLOT(onAction())); connect(&m_statusTimer, SIGNAL(timeout()), SLOT(clearStatusMessage())); - connect(theDebuggerAction(WatchPoint), SIGNAL(triggered()), SLOT(onAction())); connect(theDebuggerAction(ExecuteCommand), SIGNAL(triggered()), SLOT(executeDebuggerCommand())); diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index cd9fa88834902929b1a97e0a0d21949993e6ff49..572157329c6e57ef1414217647a3e28778b7523b 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -3615,7 +3615,7 @@ void GdbEngine::handleWatchPoint(const GdbResponse &response) QString ns = m_dumperHelper.qtNamespace(); QString type = ns.isEmpty() ? _("QWidget*") : _("'%1QWidget'*").arg(ns); QString exp = _("(*(%1)%2)").arg(type).arg(addr); - theDebuggerAction(WatchExpression)->trigger(exp); + watchHandler()->watchExpression(exp); } } diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index 2118ddd9ea46fb9f243725502079ad21f682f97b..92b71279f61d0e998af8dc936c41a55ce0d29ee8 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -184,7 +184,7 @@ void WatchModel::endCycle() m_fetchTriggered.clear(); emit enableUpdates(true); } - + DebuggerEngine *WatchModel::engine() const { return m_handler->m_engine; @@ -744,28 +744,49 @@ bool WatchModel::setData(const QModelIndex &index, const QVariant &value, int ro plugin()->clearCppCodeModelSnapshot(); return true; } + + case RequestWatchPointRole: { + engine()->watchPoint(value.toPoint()); + return true; + } } WatchItem &data = *watchItem(index); - if (role == LocalsExpandedRole) { - if (value.toBool()) { - // Should already have been triggered by fetchMore() - //QTC_ASSERT(m_handler->m_expandedINames.contains(data.iname), /**/); - m_handler->m_expandedINames.insert(data.iname); - } else { - m_handler->m_expandedINames.remove(data.iname); - } - } else if (role == LocalsTypeFormatRole) { - m_handler->setFormat(data.type, value.toInt()); - engine()->updateWatchData(data); - } else if (role == LocalsIndividualFormatRole) { - const int format = value.toInt(); - if (format == -1) { - m_handler->m_individualFormats.remove(data.addr); - } else { - m_handler->m_individualFormats[data.addr] = format; + + switch (role) { + case LocalsExpandedRole: + if (value.toBool()) { + // Should already have been triggered by fetchMore() + //QTC_ASSERT(m_handler->m_expandedINames.contains(data.iname), /**/); + m_handler->m_expandedINames.insert(data.iname); + } else { + m_handler->m_expandedINames.remove(data.iname); + } + break; + + case LocalsTypeFormatRole: + m_handler->setFormat(data.type, value.toInt()); + engine()->updateWatchData(data); + break; + + case LocalsIndividualFormatRole: { + const int format = value.toInt(); + if (format == -1) { + m_handler->m_individualFormats.remove(data.addr); + } else { + m_handler->m_individualFormats[data.addr] = format; + } + engine()->updateWatchData(data); + break; } - engine()->updateWatchData(data); + + case RequestRemoveWatchExpressionRole: + m_handler->removeWatchExpression(value.toString()); + break; + + case RequestWatchExpressionRole: + m_handler->watchExpression(value.toString()); + break; } emit dataChanged(index, index); return true; @@ -1065,10 +1086,6 @@ WatchHandler::WatchHandler(DebuggerEngine *engine) m_watchers = new WatchModel(this, WatchersWatch); m_tooltips = new WatchModel(this, TooltipsWatch); - connect(theDebuggerAction(WatchExpression), - SIGNAL(triggered()), this, SLOT(watchExpression())); - connect(theDebuggerAction(RemoveWatchExpression), - SIGNAL(triggered()), this, SLOT(removeWatchExpression())); connect(theDebuggerAction(ShowStdNamespace), SIGNAL(triggered()), this, SLOT(emitAllChanged())); connect(theDebuggerAction(ShowQtNamespace), @@ -1198,12 +1215,6 @@ void WatchHandler::removeData(const QByteArray &iname) model->destroyItem(item); } -void WatchHandler::watchExpression() -{ - if (QAction *action = qobject_cast<QAction *>(sender())) - watchExpression(action->data().toString()); -} - QByteArray WatchHandler::watcherName(const QByteArray &exp) { return "watch." + QByteArray::number(m_watcherNames[exp]); @@ -1323,12 +1334,6 @@ void WatchHandler::showEditValue(const WatchData &data) } } -void WatchHandler::removeWatchExpression() -{ - if (QAction *action = qobject_cast<QAction *>(sender())) - removeWatchExpression(action->data().toString()); -} - void WatchHandler::removeWatchExpression(const QString &exp0) { QByteArray exp = exp0.toLatin1(); diff --git a/src/plugins/debugger/watchhandler.h b/src/plugins/debugger/watchhandler.h index 1c37800e1891620b879d63fc7d5e2edb1798a96f..a973b8849301f636646a7727c59dd5845578ffce 100644 --- a/src/plugins/debugger/watchhandler.h +++ b/src/plugins/debugger/watchhandler.h @@ -142,10 +142,8 @@ public: WatchModel *modelForIName(const QByteArray &iname) const; void cleanup(); - Q_SLOT void watchExpression(); // Data passed in action->data().toString() - Q_SLOT void watchExpression(const QString &exp); - Q_SLOT void removeWatchExpression(); - Q_SLOT void removeWatchExpression(const QString &exp); + void watchExpression(const QString &exp); + void removeWatchExpression(const QString &exp); Q_SLOT void emitAllChanged(); void beginCycle(); // Called at begin of updateLocals() cycle diff --git a/src/plugins/debugger/watchwindow.cpp b/src/plugins/debugger/watchwindow.cpp index a39bff63dea4d5c98338993cc193df603ea1b54b..f9c55beaceebc7d4017a73b0c660a534377dc8a0 100644 --- a/src/plugins/debugger/watchwindow.cpp +++ b/src/plugins/debugger/watchwindow.cpp @@ -99,8 +99,8 @@ public: model->setData(index, QString(exp + '=' + value), RequestAssignTypeRole); } else if (index.column() == 0) { // The watcher name column. - theDebuggerAction(RemoveWatchExpression)->trigger(exp); - theDebuggerAction(WatchExpression)->trigger(value); + model->setData(index, exp, RequestRemoveWatchExpressionRole); + model->setData(index, value, RequestWatchExpressionRole); } } @@ -161,14 +161,14 @@ void WatchWindow::keyPressEvent(QKeyEvent *ev) QModelIndex idx = currentIndex(); QModelIndex idx1 = idx.sibling(idx.row(), 0); QString exp = idx1.data().toString(); - theDebuggerAction(RemoveWatchExpression)->trigger(exp); + removeWatchExpression(exp); } else if (ev->key() == Qt::Key_Return && ev->modifiers() == Qt::ControlModifier && m_type == LocalsType) { QModelIndex idx = currentIndex(); QModelIndex idx1 = idx.sibling(idx.row(), 0); QString exp = model()->data(idx1).toString(); - theDebuggerAction(WatchExpression)->trigger(exp); + watchExpression(exp); } QTreeView::keyPressEvent(ev); } @@ -194,7 +194,7 @@ void WatchWindow::dragMoveEvent(QDragMoveEvent *ev) void WatchWindow::dropEvent(QDropEvent *ev) { if (ev->mimeData()->hasFormat("text/plain")) { - theDebuggerAction(WatchExpression)->trigger(ev->mimeData()->text()); + watchExpression(ev->mimeData()->text()); //ev->acceptProposedAction(); ev->setDropAction(Qt::CopyAction); ev->accept(); @@ -313,13 +313,15 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev) const bool canSetWatchpoint = engineCapabilities & WatchpointCapability; if (canSetWatchpoint && address) { actSetWatchPointAtVariableAddress = - new QAction(tr("Break on Changes at Object's Address (0x%1)").arg(address, 0, 16), &menu); + new QAction(tr("Break on Changes at Object's Address (0x%1)") + .arg(address, 0, 16), &menu); actSetWatchPointAtVariableAddress->setCheckable(true); actSetWatchPointAtVariableAddress-> setChecked(mi0.data(LocalsIsWatchpointAtAddressRole).toBool()); if (createPointerActions) { actSetWatchPointAtPointerValue = - new QAction(tr("Break on Changes at Referenced Address (0x%1)").arg(pointerValue, 0, 16), &menu); + new QAction(tr("Break on Changes at Referenced Address (0x%1)") + .arg(pointerValue, 0, 16), &menu); actSetWatchPointAtPointerValue->setCheckable(true); actSetWatchPointAtPointerValue-> setChecked(mi0.data(LocalsIsWatchpointAtPointerValueRole).toBool()); @@ -330,16 +332,17 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev) actSetWatchPointAtVariableAddress->setEnabled(false); } - QAction *actWatchOrRemove; - if (m_type == LocalsType) { - actWatchOrRemove = theDebuggerAction(WatchExpression)->updatedAction(exp); - actWatchOrRemove->setEnabled(canHandleWatches); - } else { - actWatchOrRemove = theDebuggerAction(RemoveWatchExpression)->updatedAction(exp); - // Also for the case where the user cleared the expression. - actWatchOrRemove->setEnabled(true); - } - menu.addAction(actWatchOrRemove); + QAction *actWatchExpression = + new QAction(tr("Watch Expression \"%1\"").arg(exp), &menu); + actWatchExpression->setEnabled(canHandleWatches); + + QAction *actRemoveWatchExpression = + new QAction(tr("Remove Watch Expression \"%1\"").arg(exp), &menu); + + if (m_type == LocalsType) + menu.addAction(actWatchExpression); + else + menu.addAction(actRemoveWatchExpression); menu.addAction(actInsertNewWatchItem); menu.addAction(actSelectWidgetToWatch); @@ -388,8 +391,7 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev) } else if (act == actAlwaysAdjustColumnWidth) { setAlwaysResizeColumnsToContents(!m_alwaysResizeColumnsToContents); } else if (act == actInsertNewWatchItem) { - theDebuggerAction(WatchExpression) - ->trigger(WatchHandler::watcherEditPlaceHolder()); + watchExpression(WatchHandler::watcherEditPlaceHolder()); } else if (act == actOpenMemoryEditAtVariableAddress) { setModelData(RequestShowMemoryRole, address); } else if (act == actOpenMemoryEditAtPointerValue) { @@ -405,6 +407,10 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev) } else if (act == actSelectWidgetToWatch) { grabMouse(Qt::CrossCursor); m_grabbing = true; + } else if (act == actWatchExpression) { + watchExpression(exp); + } else if (act == actRemoveWatchExpression) { + removeWatchExpression(exp); } else if (act == actClearCodeModelSnapshot) { setModelData(RequestClearCppCodeModelSnapshotRole); } else if (act == clearTypeFormatAction) { @@ -446,7 +452,7 @@ bool WatchWindow::event(QEvent *ev) QMouseEvent *mev = static_cast<QMouseEvent *>(ev); m_grabbing = false; releaseMouse(); - theDebuggerAction(WatchPoint)->trigger(mapToGlobal(mev->pos())); + setModelData(RequestWatchPointRole, mapToGlobal(mev->pos())); } return QTreeView::event(ev); } @@ -498,6 +504,16 @@ void WatchWindow::resetHelper(const QModelIndex &idx) } } +void WatchWindow::watchExpression(const QString &exp) +{ + setModelData(RequestWatchExpressionRole, exp); +} + +void WatchWindow::removeWatchExpression(const QString &exp) +{ + setModelData(RequestRemoveWatchExpressionRole, exp); +} + void WatchWindow::setModelData (int role, const QVariant &value, const QModelIndex &index) { diff --git a/src/plugins/debugger/watchwindow.h b/src/plugins/debugger/watchwindow.h index 1970b3f8c6392b4477bd04f164715c6227159eef..e41b6580aa0b9de9313672ecb0950b9399f93c99 100644 --- a/src/plugins/debugger/watchwindow.h +++ b/src/plugins/debugger/watchwindow.h @@ -73,6 +73,8 @@ private: void editItem(const QModelIndex &idx); void resetHelper(const QModelIndex &idx); + void watchExpression(const QString &exp); + void removeWatchExpression(const QString &exp); void setModelData(int role, const QVariant &value = QVariant(), const QModelIndex &index = QModelIndex());