Commit 15ee289e authored by hjk's avatar hjk

make breakpoint and watchers view more robust when switching sessions

parent 28b3fa11
......@@ -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();
}
......
......@@ -61,6 +61,7 @@ public:
void loadSessionData();
void saveSessionData();
void removeSessionData();
QAbstractItemModel *model() { return this; }
......
......@@ -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.
......
......@@ -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);
......
......@@ -182,7 +182,6 @@ public:
private:
friend class WatchModel;
void loadWatchers();
void saveWatchers();
static void loadTypeFormats();
static void saveTypeFormats();
......
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