From 15ee289ee2c0aa33ce869d55371220895f391c8b Mon Sep 17 00:00:00 2001 From: hjk <qtc-committer@nokia.com> Date: Thu, 25 Nov 2010 16:32:07 +0100 Subject: [PATCH] make breakpoint and watchers view more robust when switching sessions --- src/plugins/debugger/breakhandler.cpp | 13 ++++++- src/plugins/debugger/breakhandler.h | 1 + src/plugins/debugger/debuggerplugin.cpp | 4 +-- src/plugins/debugger/watchhandler.cpp | 45 ++++++++++--------------- src/plugins/debugger/watchhandler.h | 1 - 5 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/plugins/debugger/breakhandler.cpp b/src/plugins/debugger/breakhandler.cpp index 3f0537f4878..6f9aaf8d0f6 100644 --- a/src/plugins/debugger/breakhandler.cpp +++ b/src/plugins/debugger/breakhandler.cpp @@ -781,6 +781,15 @@ void BreakHandler::loadSessionData() loadBreakpoints(); } +void BreakHandler::removeSessionData() +{ + Iterator it = m_storage.begin(), et = m_storage.end(); + for ( ; it != et; ++it) + it->destroyMarker(); + m_storage.clear(); + layoutChanged(); +} + void BreakHandler::breakByFunction(const QString &functionName) { // One breakpoint per function is enough for now. This does not handle @@ -801,7 +810,9 @@ void BreakHandler::breakByFunction(const QString &functionName) QIcon BreakHandler::icon(BreakpointId id) const { ConstIterator it = m_storage.find(id); - QTC_ASSERT(it != m_storage.end(), return pendingBreakPointIcon()); + QTC_ASSERT(it != m_storage.end(), + qDebug() << "NO ICON FOR ID" << id; + return pendingBreakPointIcon()); return it->icon(); } diff --git a/src/plugins/debugger/breakhandler.h b/src/plugins/debugger/breakhandler.h index c2e08a4ba40..5ab47f3b8e7 100644 --- a/src/plugins/debugger/breakhandler.h +++ b/src/plugins/debugger/breakhandler.h @@ -61,6 +61,7 @@ public: void loadSessionData(); void saveSessionData(); + void removeSessionData(); QAbstractItemModel *model() { return this; } diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index be7bb042005..d3557d97fd6 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -977,7 +977,7 @@ public slots: for (int i = 0, n = m_snapshotHandler->size(); i != n; ++i) { if (DebuggerRunControl *runControl = m_snapshotHandler->at(i)) { DebuggerEngine *engine = runControl->engine(); - engine->watchHandler()->synchronizeWatchers(); + engine->watchHandler()->updateWatchers(); } } } @@ -3000,11 +3000,11 @@ void DebuggerPluginPrivate::sessionLoaded() { m_breakHandler->loadSessionData(); dummyEngine()->watchHandler()->loadSessionData(); - synchronizeWatchers(); } void DebuggerPluginPrivate::aboutToUnloadSession() { + m_breakHandler->removeSessionData(); // Stop debugging the active project when switching sessions. // Note that at startup, session switches may occur, which interfere // with command-line debugging startup. diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index e222bcffbe8..f8944071b37 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -1212,8 +1212,8 @@ QByteArray WatchHandler::watcherName(const QByteArray &exp) void WatchHandler::watchExpression(const QString &exp) { QTC_ASSERT(m_engine, return); - // Do not insert multiple placeholders. - if (exp.isEmpty() && m_watcherNames.contains(QByteArray())) + // Do not insert the same entry more then once. + if (m_watcherNames.value(exp.toLatin1())) return; // FIXME: 'exp' can contain illegal characters @@ -1343,11 +1343,11 @@ void WatchHandler::removeWatchExpression(const QString &exp0) if (item->exp == exp) { m_watchers->destroyItem(item); saveWatchers(); + updateWatchersWindow(); + emitAllChanged(); break; } } - emitAllChanged(); - updateWatchersWindow(); } void WatchHandler::updateWatchersWindow() @@ -1356,27 +1356,6 @@ void WatchHandler::updateWatchersWindow() debuggerCore()->updateWatchersWindow(); } -void WatchHandler::updateWatchers() -{ - // Copy over all watchers and mark all watchers as incomplete. - foreach (const QByteArray &exp, m_watcherNames.keys()) { - WatchData data; - data.iname = watcherName(exp); - data.setAllNeeded(); - data.name = exp; - data.exp = exp; - insertData(data); - } -} - -void WatchHandler::loadWatchers() -{ - m_watcherNames.clear(); - QVariant value = debuggerCore()->sessionValue("Watchers"); - foreach (const QString &exp, value.toStringList()) - watchExpression(exp); -} - QStringList WatchHandler::watchedExpressions() { // Filter out invalid watchers. @@ -1432,16 +1411,26 @@ void WatchHandler::saveSessionData() void WatchHandler::loadSessionData() { - loadWatchers(); loadTypeFormats(); + m_watcherNames.clear(); + QVariant value = debuggerCore()->sessionValue("Watchers"); + foreach (WatchItem *item, m_watchers->rootItem()->children) + m_watchers->destroyItem(item); + foreach (const QString &exp, value.toStringList()) + watchExpression(exp); + updateWatchersWindow(); + emitAllChanged(); } -void WatchHandler::synchronizeWatchers() +void WatchHandler::updateWatchers() { + foreach (WatchItem *item, m_watchers->rootItem()->children) + m_watchers->destroyItem(item); + // Copy over all watchers and mark all watchers as incomplete. foreach (const QByteArray &exp, m_watcherNames.keys()) { WatchData data; data.iname = watcherName(exp); - data.setAllUnneeded(); + data.setAllNeeded(); data.name = exp; data.exp = exp; insertData(data); diff --git a/src/plugins/debugger/watchhandler.h b/src/plugins/debugger/watchhandler.h index cfdc9fc0cbd..38f34a41063 100644 --- a/src/plugins/debugger/watchhandler.h +++ b/src/plugins/debugger/watchhandler.h @@ -182,7 +182,6 @@ public: private: friend class WatchModel; - void loadWatchers(); void saveWatchers(); static void loadTypeFormats(); static void saveTypeFormats(); -- GitLab