diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index b27a436a937..71e97113b85 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -1615,8 +1615,13 @@ void WatchHandler::removeAllData() void WatchHandler::removeData(const QByteArray &iname) { WatchItem *item = m_model->findItem(iname); - if (item) - m_model->destroyItem(item); + if (!item) + return; + if (item->isWatcher()) { + theWatcherNames.remove(item->exp); + saveWatchers(); + } + m_model->destroyItem(item); updateWatchersWindow(); } diff --git a/src/plugins/debugger/watchwindow.cpp b/src/plugins/debugger/watchwindow.cpp index 0b3bed93ea0..6db85de55fa 100644 --- a/src/plugins/debugger/watchwindow.cpp +++ b/src/plugins/debugger/watchwindow.cpp @@ -131,7 +131,8 @@ public: const QString exp = index.data(LocalsExpressionRole).toString(); if (exp == value) return; - m_watchWindow->removeWatch(index.data(LocalsINameRole).toByteArray()); + WatchHandler *handler = currentEngine()->watchHandler(); + handler->removeData(index.data(LocalsINameRole).toByteArray()); m_watchWindow->watchExpression(value); } @@ -515,10 +516,9 @@ void WatchTreeView::keyPressEvent(QKeyEvent *ev) QModelIndexList indices = selectionModel()->selectedRows(); if (indices.isEmpty() && selectionModel()->currentIndex().isValid()) indices.append(selectionModel()->currentIndex()); - foreach (const QModelIndex &idx, indices) { - const QByteArray iname = idx.data(LocalsINameRole).toByteArray(); - removeWatch(iname); - } + WatchHandler *handler = currentEngine()->watchHandler(); + foreach (const QModelIndex &idx, indices) + handler->removeData(idx.data(LocalsINameRole).toByteArray()); } else if (ev->key() == Qt::Key_Return && ev->modifiers() == Qt::ControlModifier && m_type == LocalsType) { @@ -924,7 +924,7 @@ void WatchTreeView::contextMenuEvent(QContextMenuEvent *ev) } else if (act == actWatchExpression) { watchExpression(exp); } else if (act == actRemoveWatchExpression) { - removeWatch(p.data(LocalsINameRole).toByteArray()); + handler->removeData(p.data(LocalsINameRole).toByteArray()); } else if (act == actCopy) { copyToClipboard(DebuggerToolTipWidget::treeModelClipboardContents(model())); } else if (act == actEditTypeFormats) { @@ -932,7 +932,7 @@ void WatchTreeView::contextMenuEvent(QContextMenuEvent *ev) } else if (act == actCopyValue) { copyToClipboard(mi1.data().toString()); } else if (act == actRemoveWatches) { - currentEngine()->watchHandler()->clearWatches(); + handler->clearWatches(); } else if (act == clearTypeFormatAction) { setModelData(LocalsTypeFormatRole, -1, mi1); } else if (act == clearIndividualFormatAction) { @@ -1043,11 +1043,6 @@ void WatchTreeView::watchExpression(const QString &exp) currentEngine()->watchHandler()->watchExpression(exp); } -void WatchTreeView::removeWatch(const QByteArray &iname) -{ - currentEngine()->watchHandler()->removeData(iname); -} - void WatchTreeView::setModelData (int role, const QVariant &value, const QModelIndex &index) { diff --git a/src/plugins/debugger/watchwindow.h b/src/plugins/debugger/watchwindow.h index fcef494d161..60b6a1fa7ce 100644 --- a/src/plugins/debugger/watchwindow.h +++ b/src/plugins/debugger/watchwindow.h @@ -58,7 +58,6 @@ public: public slots: void watchExpression(const QString &exp); - void removeWatch(const QByteArray &iname); void handleItemIsExpanded(const QModelIndex &idx); private: