diff options
author | hjk <hjk@qt.io> | 2018-08-23 16:39:23 +0200 |
---|---|---|
committer | hjk <hjk@qt.io> | 2018-08-29 09:38:38 +0000 |
commit | a68e8c5b699e2d40fbdb35f7e7a577a48db06b8b (patch) | |
tree | 7b751884b28af97f8842fc03509b163d2c05e6ac | |
parent | 37dbc7ba85621303655020906ef3a2befcf2c6a8 (diff) | |
download | qt-creator-a68e8c5b699e2d40fbdb35f7e7a577a48db06b8b.tar.gz |
Debugger: Move session load/restore handling
... to breakpoint and watchhandler.
More modular this way.
Change-Id: I4a45481fcc2bfde67b164bd7274fb7b2a12cb7ac
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
-rw-r--r-- | src/plugins/debugger/breakhandler.cpp | 17 | ||||
-rw-r--r-- | src/plugins/debugger/breakhandler.h | 10 | ||||
-rw-r--r-- | src/plugins/debugger/debuggercore.h | 2 | ||||
-rw-r--r-- | src/plugins/debugger/debuggerplugin.cpp | 37 | ||||
-rw-r--r-- | src/plugins/debugger/debuggertooltipmanager.cpp | 2 | ||||
-rw-r--r-- | src/plugins/debugger/watchhandler.cpp | 48 | ||||
-rw-r--r-- | src/plugins/debugger/watchhandler.h | 3 |
7 files changed, 46 insertions, 73 deletions
diff --git a/src/plugins/debugger/breakhandler.cpp b/src/plugins/debugger/breakhandler.cpp index d714ada70e..f34eebc568 100644 --- a/src/plugins/debugger/breakhandler.cpp +++ b/src/plugins/debugger/breakhandler.cpp @@ -40,6 +40,8 @@ #include <coreplugin/icore.h> #include <coreplugin/idocument.h> +#include <projectexplorer/session.h> + #include <texteditor/textmark.h> #include <texteditor/texteditor.h> @@ -69,6 +71,7 @@ #include <QMenu> using namespace Core; +using namespace ProjectExplorer; using namespace Utils; namespace Debugger { @@ -2391,6 +2394,12 @@ BreakpointManager::BreakpointManager() theBreakpointManager = this; setHeader({tr("Debuggee"), tr("Function"), tr("File"), tr("Line"), tr("Address"), tr("Condition"), tr("Ignore"), tr("Threads")}); + connect(SessionManager::instance(), &SessionManager::sessionLoaded, + this, &BreakpointManager::loadSessionData); + connect(SessionManager::instance(), &SessionManager::aboutToSaveSession, + this, &BreakpointManager::saveSessionData); + connect(SessionManager::instance(), &SessionManager::aboutToUnloadSession, + this, &BreakpointManager::aboutToUnloadSession); } QAbstractItemModel *BreakpointManager::model() @@ -2755,20 +2764,20 @@ void BreakpointManager::saveSessionData() map.insert("message", params.message); list.append(map); }); - setSessionValue("Breakpoints", list); + SessionManager::setValue("Breakpoints", list); } void BreakpointManager::aboutToUnloadSession() { saveSessionData(); - theBreakpointManager->clear(); + clear(); } void BreakpointManager::loadSessionData() { - theBreakpointManager->clear(); + clear(); - const QVariant value = sessionValue("Breakpoints"); + const QVariant value = SessionManager::value("Breakpoints"); const QList<QVariant> list = value.toList(); for (const QVariant &var : list) { const QMap<QString, QVariant> map = var.toMap(); diff --git a/src/plugins/debugger/breakhandler.h b/src/plugins/debugger/breakhandler.h index fdf3a0326d..bdbf4586ce 100644 --- a/src/plugins/debugger/breakhandler.h +++ b/src/plugins/debugger/breakhandler.h @@ -234,9 +234,6 @@ public: QAbstractItemModel *model() { return this; } const Breakpoints breakpoints() const; - void loadSessionData(); - void saveSessionData(); - bool tryClaimBreakpoint(const GlobalBreakpoint &gbp); void releaseAllBreakpoints(); @@ -297,9 +294,6 @@ public: static QAbstractItemModel *model(); static const GlobalBreakpoints globalBreakpoints(); - static void loadSessionData(); - static void saveSessionData(); - static void aboutToUnloadSession(); static GlobalBreakpoint createBreakpoint(const BreakpointParameters &data); @@ -325,6 +319,10 @@ private: QVariant data(const QModelIndex &idx, int role) const final; bool setData(const QModelIndex &idx, const QVariant &value, int role) final; + void loadSessionData(); + void saveSessionData(); + void aboutToUnloadSession(); + bool contextMenuEvent(const Utils::ItemViewEvent &ev); void gotoLocation(const GlobalBreakpoint &gbp) const; void editBreakpoints(const GlobalBreakpoints &gbps, QWidget *parent); diff --git a/src/plugins/debugger/debuggercore.h b/src/plugins/debugger/debuggercore.h index 51d5a26a6b..5902853714 100644 --- a/src/plugins/debugger/debuggercore.h +++ b/src/plugins/debugger/debuggercore.h @@ -73,8 +73,6 @@ void showModuleSections(const QString &moduleName, const QVector<Internal::Secti QSharedPointer<Internal::GlobalDebuggerOptions> globalDebuggerOptions(); -QVariant sessionValue(const QByteArray &name); -void setSessionValue(const QByteArray &name, const QVariant &value); QVariant configValue(const QString &name); void setConfigValue(const QString &name, const QVariant &value); diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index 8f7643d7bb..27bdbc1f63 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -676,10 +676,6 @@ public: void onStartupProjectChanged(Project *project); - void sessionLoaded(); - void aboutToUnloadSession(); - void aboutToSaveSession(); - void handleOperateByInstructionTriggered(bool operateByInstructionTriggered); bool parseArgument(QStringList::const_iterator &it, @@ -1330,12 +1326,6 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments, // ProjectExplorer - connect(SessionManager::instance(), &SessionManager::sessionLoaded, - this, &DebuggerPluginPrivate::sessionLoaded); - connect(SessionManager::instance(), &SessionManager::aboutToSaveSession, - this, &DebuggerPluginPrivate::aboutToSaveSession); - connect(SessionManager::instance(), &SessionManager::aboutToUnloadSession, - this, &DebuggerPluginPrivate::aboutToUnloadSession); connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::updateRunActions, this, &DebuggerPluginPrivate::updatePresetState); @@ -2073,23 +2063,6 @@ void DebuggerPluginPrivate::dumpLog() saver.finalize(ICore::mainWindow()); } -void DebuggerPluginPrivate::sessionLoaded() -{ - BreakpointManager::loadSessionData(); - WatchHandler::loadSessionData(); -} - -void DebuggerPluginPrivate::aboutToUnloadSession() -{ - BreakpointManager::aboutToUnloadSession(); -} - -void DebuggerPluginPrivate::aboutToSaveSession() -{ - WatchHandler::saveSessionData(); - BreakpointManager::saveSessionData(); -} - void DebuggerPluginPrivate::aboutToShutdown() { m_shuttingDown = true; @@ -2108,16 +2081,6 @@ void DebuggerPluginPrivate::aboutToShutdown() m_shutdownTimer.start(); } -void setSessionValue(const QByteArray &key, const QVariant &value) -{ - SessionManager::setValue(QString::fromUtf8(key), value); -} - -QVariant sessionValue(const QByteArray &key) -{ - return SessionManager::value(QString::fromUtf8(key)); -} - static void createNewDock(QWidget *widget) { auto dockWidget = new QDockWidget; diff --git a/src/plugins/debugger/debuggertooltipmanager.cpp b/src/plugins/debugger/debuggertooltipmanager.cpp index 2cc3031227..7b733c6d62 100644 --- a/src/plugins/debugger/debuggertooltipmanager.cpp +++ b/src/plugins/debugger/debuggertooltipmanager.cpp @@ -1076,7 +1076,7 @@ void DebuggerToolTipManagerPrivate::sessionAboutToChange() void DebuggerToolTipManagerPrivate::loadSessionData() { closeAllToolTips(); - const QString data = sessionValue(sessionSettingsKeyC).toString(); + const QString data = SessionManager::value(sessionSettingsKeyC).toString(); QXmlStreamReader r(data); if (r.readNextStartElement() && r.name() == QLatin1String(sessionDocumentC)) { while (!r.atEnd()) { diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index eccd1b1d7e..663c9208c6 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -45,6 +45,8 @@ #include <coreplugin/helpmanager.h> #include <coreplugin/messagebox.h> +#include <projectexplorer/session.h> + #include <texteditor/syntaxhighlighter.h> #include <app/app_version.h> @@ -81,6 +83,7 @@ #include <ctype.h> using namespace Core; +using namespace ProjectExplorer; using namespace Utils; namespace Debugger { @@ -212,12 +215,12 @@ static QString stripForFormat(const QString &ba) static void saveWatchers() { - setSessionValue("Watchers", WatchHandler::watchedExpressions()); + SessionManager::setValue("Watchers", WatchHandler::watchedExpressions()); } static void loadFormats() { - QVariant value = sessionValue("DefaultFormats"); + QVariant value = SessionManager::value("DefaultFormats"); QMapIterator<QString, QVariant> it(value.toMap()); while (it.hasNext()) { it.next(); @@ -225,7 +228,7 @@ static void loadFormats() theTypeFormats.insert(it.key(), it.value().toInt()); } - value = sessionValue("IndividualFormats"); + value = SessionManager::value("IndividualFormats"); it = QMapIterator<QString, QVariant>(value.toMap()); while (it.hasNext()) { it.next(); @@ -247,7 +250,7 @@ static void saveFormats() formats.insert(key, format); } } - setSessionValue("DefaultFormats", formats); + SessionManager::setValue("DefaultFormats", formats); formats.clear(); it = QHashIterator<QString, int>(theIndividualFormats); @@ -258,7 +261,18 @@ static void saveFormats() if (!key.isEmpty()) formats.insert(key, format); } - setSessionValue("IndividualFormats", formats); + SessionManager::setValue("IndividualFormats", formats); +} + +static void saveSessionData() +{ + saveWatchers(); + saveFormats(); +} + +static void loadSessionData() +{ + // Handled by loadSesseionDataForEngine. } /////////////////////////////////////////////////////////////////////// @@ -277,7 +291,7 @@ public: setWindowFlags(windowFlags() | Qt::Window); setWindowTitle(WatchHandler::tr("Debugger - %1").arg(Core::Constants::IDE_DISPLAY_NAME)); - QVariant geometry = sessionValue("DebuggerSeparateWidgetGeometry"); + QVariant geometry = SessionManager::value("DebuggerSeparateWidgetGeometry"); if (geometry.isValid()) { QRect rc = geometry.toRect(); if (rc.width() < 400) @@ -290,7 +304,7 @@ public: void saveGeometry() { - setSessionValue("DebuggerSeparateWidgetGeometry", geometry()); + SessionManager::setValue("DebuggerSeparateWidgetGeometry", geometry()); } ~SeparatedView() override @@ -506,6 +520,11 @@ WatchModel::WatchModel(WatchHandler *handler, DebuggerEngine *engine) m_engine, &DebuggerEngine::updateAll); connect(action(ShowQObjectNames), &SavedAction::valueChanged, m_engine, &DebuggerEngine::updateAll); + + connect(SessionManager::instance(), &SessionManager::sessionLoaded, + this, &loadSessionData); + connect(SessionManager::instance(), &SessionManager::aboutToSaveSession, + this, &saveSessionData); } void WatchModel::reinitialize(bool includeInspectData) @@ -2077,7 +2096,7 @@ void WatchHandler::resetWatchers() loadFormats(); theWatcherNames.clear(); theWatcherCount = 0; - const QStringList watchers = sessionValue("Watchers").toStringList(); + const QStringList watchers = SessionManager::value("Watchers").toStringList(); m_model->m_watchRoot->removeChildren(); for (const QString &exp : watchers) watchExpression(exp.trimmed()); @@ -2383,23 +2402,12 @@ QStringList WatchHandler::watchedExpressions() return watcherNames; } -void WatchHandler::saveSessionData() -{ - saveWatchers(); - saveFormats(); -} - -void WatchHandler::loadSessionData() -{ - // Handled by loadSesseionDataForEngine. -} - void WatchHandler::loadSessionDataForEngine() { loadFormats(); theWatcherNames.clear(); theWatcherCount = 0; - QVariant value = sessionValue("Watchers"); + QVariant value = SessionManager::value("Watchers"); m_model->m_watchRoot->removeChildren(); foreach (const QString &exp, value.toStringList()) watchExpression(exp.trimmed()); diff --git a/src/plugins/debugger/watchhandler.h b/src/plugins/debugger/watchhandler.h index 10e8825cdc..5be7c7f58e 100644 --- a/src/plugins/debugger/watchhandler.h +++ b/src/plugins/debugger/watchhandler.h @@ -78,9 +78,6 @@ public: void loadSessionDataForEngine(); - static void loadSessionData(); - static void saveSessionData(); - bool isExpandedIName(const QString &iname) const; QSet<QString> expandedINames() const; |