Commit cc6a3b4f authored by hjk's avatar hjk Committed by hjk

debugger: fix regression when trying to remove watched expressions

Change-Id: I0d12339ab1903dc78eec699e07fc0c17daab0e5d
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent e11a3a76
......@@ -1609,6 +1609,7 @@ void WatchHandler::insertData(const QList<WatchData> &list)
void WatchHandler::removeAllData()
{
m_model->reinitialize();
updateWatchersWindow();
}
void WatchHandler::removeData(const QByteArray &iname)
......@@ -1616,6 +1617,7 @@ void WatchHandler::removeData(const QByteArray &iname)
WatchItem *item = m_model->findItem(iname);
if (item)
m_model->destroyItem(item);
updateWatchersWindow();
}
void WatchHandler::removeChildren(const QByteArray &iname)
......@@ -1623,6 +1625,7 @@ void WatchHandler::removeChildren(const QByteArray &iname)
WatchItem *item = m_model->findItem(iname);
if (item)
m_model->destroyChildren(item);
updateWatchersWindow();
}
QByteArray WatchHandler::watcherName(const QByteArray &exp)
......@@ -1766,22 +1769,6 @@ void WatchHandler::clearWatches()
saveWatchers();
}
void WatchHandler::removeWatchExpression(const QString &exp0)
{
QByteArray exp = exp0.toLatin1();
MODEL_DEBUG("REMOVE WATCH: " << exp);
theWatcherNames.remove(exp);
foreach (WatchItem *item, m_model->m_watchRoot->children) {
if (item->exp == exp) {
m_model->destroyItem(item);
saveWatchers();
updateWatchersWindow();
break;
}
}
}
void WatchHandler::updateWatchersWindow()
{
// Force show/hide of watchers and return view.
......
......@@ -89,7 +89,6 @@ public:
void cleanup();
void watchExpression(const QString &exp);
void removeWatchExpression(const QString &exp);
Q_SLOT void clearWatches();
void updateWatchers(); // Called after locals are fetched
......
......@@ -131,7 +131,7 @@ public:
const QString exp = index.data(LocalsExpressionRole).toString();
if (exp == value)
return;
m_watchWindow->removeWatchExpression(exp);
m_watchWindow->removeWatch(index.data(LocalsINameRole).toByteArray());
m_watchWindow->watchExpression(value);
}
......@@ -515,13 +515,10 @@ void WatchTreeView::keyPressEvent(QKeyEvent *ev)
QModelIndexList indices = selectionModel()->selectedRows();
if (indices.isEmpty() && selectionModel()->currentIndex().isValid())
indices.append(selectionModel()->currentIndex());
QStringList exps;
foreach (const QModelIndex &idx, indices) {
QModelIndex idx1 = idx.sibling(idx.row(), 0);
exps.append(idx1.data(LocalsRawExpressionRole).toString());
const QByteArray iname = idx.data(LocalsINameRole).toByteArray();
removeWatch(iname);
}
foreach (const QString &exp, exps)
removeWatchExpression(exp);
} else if (ev->key() == Qt::Key_Return
&& ev->modifiers() == Qt::ControlModifier
&& m_type == LocalsType) {
......@@ -780,8 +777,12 @@ void WatchTreeView::contextMenuEvent(QContextMenuEvent *ev)
// Can remove watch if engine can handle it or session engine.
QModelIndex p = mi0;
while (p.parent().isValid())
p = p.parent();
while (true) {
QModelIndex pp = p.parent();
if (!pp.isValid() || !pp.parent().isValid())
break;
p = pp;
}
QString removeExp = p.data(LocalsExpressionRole).toString();
QAction *actRemoveWatchExpression = new QAction(removeWatchActionText(removeExp), &menu);
actRemoveWatchExpression->setEnabled(
......@@ -923,7 +924,7 @@ void WatchTreeView::contextMenuEvent(QContextMenuEvent *ev)
} else if (act == actWatchExpression) {
watchExpression(exp);
} else if (act == actRemoveWatchExpression) {
removeWatchExpression(removeExp);
removeWatch(p.data(LocalsINameRole).toByteArray());
} else if (act == actCopy) {
copyToClipboard(DebuggerToolTipWidget::treeModelClipboardContents(model()));
} else if (act == actEditTypeFormats) {
......@@ -1042,9 +1043,9 @@ void WatchTreeView::watchExpression(const QString &exp)
currentEngine()->watchHandler()->watchExpression(exp);
}
void WatchTreeView::removeWatchExpression(const QString &exp)
void WatchTreeView::removeWatch(const QByteArray &iname)
{
currentEngine()->watchHandler()->removeWatchExpression(exp);
currentEngine()->watchHandler()->removeData(iname);
}
void WatchTreeView::setModelData
......
......@@ -58,7 +58,7 @@ public:
public slots:
void watchExpression(const QString &exp);
void removeWatchExpression(const QString &exp);
void removeWatch(const QByteArray &iname);
void handleItemIsExpanded(const QModelIndex &idx);
private:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment