diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index b27a436a937610bc97aa24f450a9d23c4c4b7446..71e97113b852c4e27823201511bb81679b77672f 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 0b3bed93ea044c18470ae47df5767a97703075fc..6db85de55fa50f7de85101add6148d5e18bc8caa 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 fcef494d1614d13394f12ca95c9661a2d5f6dbfa..60b6a1fa7ce86acd0a05ade48110215e9d4d29a7 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: