diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index 05afb7c0610..ceb28fd5eb5 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -41,10 +41,13 @@ #include "imageviewer.h" #include "watchutils.h" +#include + #include #include #include #include +#include #include #include @@ -1883,6 +1886,14 @@ void WatchHandler::clearWatches() { if (theWatcherNames.isEmpty()) return; + + const QDialogButtonBox::StandardButton ret = Utils::CheckableMessageBox::doNotAskAgainQuestion( + Core::ICore::mainWindow(), tr("Remove All Expression Evaluators"), + tr("Are you sure you want to remove all expression evaluators?"), + Core::ICore::settings(), QLatin1String("RemoveAllWatchers")); + if (ret != QDialogButtonBox::Yes) + return; + m_model->destroyChildren(m_model->m_watchRoot); theWatcherNames.clear(); m_watcherCounter = 0; diff --git a/src/plugins/debugger/watchwindow.cpp b/src/plugins/debugger/watchwindow.cpp index 67da4b32465..02737482e8d 100644 --- a/src/plugins/debugger/watchwindow.cpp +++ b/src/plugins/debugger/watchwindow.cpp @@ -810,11 +810,16 @@ void WatchTreeView::contextMenuEvent(QContextMenuEvent *ev) break; p = pp; } + + bool showExpressionActions = (canHandleWatches || state == DebuggerNotReady) && m_type == WatchersType; + QString removeExp = p.data(LocalsExpressionRole).toString(); QAction actRemoveWatchExpression(removeWatchActionText(removeExp), 0); - actRemoveWatchExpression.setEnabled( - (canHandleWatches || state == DebuggerNotReady) - && !exp.isEmpty() && m_type == WatchersType); + actRemoveWatchExpression.setEnabled(showExpressionActions && !exp.isEmpty()); + + QAction actRemoveAllWatchExpression(tr("Remove All Expression Evaluators"), 0); + actRemoveAllWatchExpression.setEnabled(showExpressionActions + && !handler->watchedExpressions().isEmpty()); QMenu formatMenu(tr("Change Local Display Format...")); if (mi0.isValid()) @@ -891,6 +896,7 @@ void WatchTreeView::contextMenuEvent(QContextMenuEvent *ev) menu.addAction(&actInsertNewWatchItem); menu.addAction(&actWatchExpression); menu.addAction(&actRemoveWatchExpression); + menu.addAction(&actRemoveAllWatchExpression); menu.addAction(&actSelectWidgetToWatch); menu.addSeparator(); @@ -950,6 +956,8 @@ void WatchTreeView::contextMenuEvent(QContextMenuEvent *ev) watchExpression(exp, name); } else if (act == &actRemoveWatchExpression) { handler->removeData(p.data(LocalsINameRole).toByteArray()); + } else if (act == &actRemoveAllWatchExpression) { + handler->clearWatches(); } else if (act == &actCopy) { copyToClipboard(DebuggerToolTipManager::treeModelClipboardContents(model())); } else if (act == &actCopyValue) {