From f85c6efcd164c4fde1b8f8a7edabb726c8a0816e Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 29 Nov 2016 11:30:39 +0100 Subject: [PATCH] Debugger: Consolidate watcher insertion code paths All were targeting the same running engine, doing the same thing. Change-Id: If1186f6467cde6b44a051ea5845d4528917ca8f9 Reviewed-by: David Schulz --- src/plugins/debugger/watchhandler.cpp | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index 6fb3acea8e7..33a8cc7d58c 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -428,8 +428,6 @@ public: QString editorContents(const QModelIndexList &list = QModelIndexList()); void clearWatches(); void removeWatchItem(WatchItem *item); - void watchExpression(const QString &exp); - void watchExpression(const QString &exp, const QString &name); void inputNewExpression(); public: @@ -1095,7 +1093,7 @@ bool WatchModel::setData(const QModelIndex &idx, const QVariant &value, int role if (item && kev->key() == Qt::Key_Return && kev->modifiers() == Qt::ControlModifier && item->isLocal()) { - watchExpression(item->expression()); + m_handler->watchExpression(item->expression(), QString()); return true; } } @@ -1531,16 +1529,6 @@ static QString removeWatchActionText(QString exp) .arg(exp.replace('&', "&&")); } -void WatchModel::watchExpression(const QString &exp) -{ - watchExpression(exp, QString()); -} - -void WatchModel::watchExpression(const QString &exp, const QString &name) -{ - currentEngine()->watchHandler()->watchExpression(exp, name); -} - static void copyToClipboard(const QString &clipboardText) { QClipboard *clipboard = QApplication::clipboard(); @@ -1582,11 +1570,8 @@ void WatchModel::inputNewExpression() connect(hint, &QLabel::linkActivated, [](const QString &link) { HelpManager::handleHelpRequest(link); }); - if (dlg.exec() == QDialog::Accepted) { - const QString exp = lineEdit->text().trimmed(); - if (!exp.isEmpty()) - m_handler->watchExpression(exp, exp); - } + if (dlg.exec() == QDialog::Accepted) + m_handler->watchExpression(lineEdit->text().trimmed()); } bool WatchModel::contextMenuEvent(const ItemViewEvent &ev) @@ -2096,6 +2081,7 @@ QString WatchHandler::watcherName(const QString &exp) return "watch." + QString::number(theWatcherNames[exp]); } +// If \a name is empty, \a exp will be used as name. void WatchHandler::watchExpression(const QString &exp, const QString &name) { // Do not insert the same entry more then once.