forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -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();
|
||||
|
@@ -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);
|
||||
|
@@ -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);
|
||||
|
||||
|
@@ -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;
|
||||
|
@@ -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()) {
|
||||
|
@@ -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());
|
||||
|
@@ -78,9 +78,6 @@ public:
|
||||
|
||||
void loadSessionDataForEngine();
|
||||
|
||||
static void loadSessionData();
|
||||
static void saveSessionData();
|
||||
|
||||
bool isExpandedIName(const QString &iname) const;
|
||||
QSet<QString> expandedINames() const;
|
||||
|
||||
|
Reference in New Issue
Block a user