From 05f47cd45107529cfb862c8c98e2dfa94d29b972 Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 28 Nov 2013 14:28:20 +0100 Subject: [PATCH] Debugger: Make also individual formats persistent I am not fully convinced this is a good idea, but it looks like the different behaviour of type formats and individual formats is unexpected. Task-number: QTCREATORBUG-7412 Change-Id: I5aae39939dfe75b3d9ff6c1025bd3d9c9222695a Reviewed-by: David Schulz --- src/plugins/debugger/watchhandler.cpp | 38 ++++++++++++++++++++------- src/plugins/debugger/watchhandler.h | 4 +-- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index 84c50ec6d65..d9df0986fbb 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -1817,21 +1817,28 @@ void WatchHandler::saveWatchers() DebuggerCore::setSessionValue("Watchers", watchedExpressions()); } -void WatchHandler::loadTypeFormats() +void WatchHandler::loadFormats() { QVariant value = DebuggerCore::sessionValue("DefaultFormats"); - QMap typeFormats = value.toMap(); - QMapIterator it(typeFormats); + QMapIterator it(value.toMap()); while (it.hasNext()) { it.next(); if (!it.key().isEmpty()) theTypeFormats.insert(it.key().toUtf8(), it.value().toInt()); } + + value = DebuggerCore::sessionValue("IndividualFormats"); + it = QMapIterator(value.toMap()); + while (it.hasNext()) { + it.next(); + if (!it.key().isEmpty()) + theIndividualFormats.insert(it.key().toUtf8(), it.value().toInt()); + } } -void WatchHandler::saveTypeFormats() +void WatchHandler::saveFormats() { - QMap typeFormats; + QMap formats; QHashIterator it(theTypeFormats); while (it.hasNext()) { it.next(); @@ -1839,21 +1846,32 @@ void WatchHandler::saveTypeFormats() if (format != DecimalFormat) { const QByteArray key = it.key().trimmed(); if (!key.isEmpty()) - typeFormats.insert(QLatin1String(key), format); + formats.insert(QString::fromLatin1(key), format); } } - DebuggerCore::setSessionValue("DefaultFormats", typeFormats); + DebuggerCore::setSessionValue("DefaultFormats", formats); + + formats.clear(); + it = QHashIterator(theIndividualFormats); + while (it.hasNext()) { + it.next(); + const int format = it.value(); + const QByteArray key = it.key().trimmed(); + if (!key.isEmpty()) + formats.insert(QString::fromLatin1(key), format); + } + DebuggerCore::setSessionValue("IndividualFormats", formats); } void WatchHandler::saveSessionData() { saveWatchers(); - saveTypeFormats(); + saveFormats(); } void WatchHandler::loadSessionData() { - loadTypeFormats(); + loadFormats(); theWatcherNames.clear(); m_watcherCounter = 0; QVariant value = DebuggerCore::sessionValue("Watchers"); @@ -1927,7 +1945,7 @@ void WatchHandler::setFormat(const QByteArray &type0, int format) theTypeFormats.remove(type); else theTypeFormats[type] = format; - saveTypeFormats(); + saveFormats(); m_model->emitDataChanged(1); } diff --git a/src/plugins/debugger/watchhandler.h b/src/plugins/debugger/watchhandler.h index 3855b5b85d3..04cba314b34 100644 --- a/src/plugins/debugger/watchhandler.h +++ b/src/plugins/debugger/watchhandler.h @@ -141,8 +141,8 @@ private: friend class WatchModel; void saveWatchers(); - static void loadTypeFormats(); - static void saveTypeFormats(); + static void loadFormats(); + static void saveFormats(); void setFormat(const QByteArray &type, int format);