From b2199ec59d1f851df35401bdaf0ed2157d2f5226 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Fri, 15 Dec 2023 11:44:11 +0100 Subject: [PATCH] Debugger: Fix saving (legacy) state Since dd9f9c799b7d638287f78121f6699ce34f82bb40 we not only save the dock widget state as the state of Perspectives, but the whole FancyMainwindow state, so other properties from FancyMainWindow like the side bar state is saved too. The conversion from "legacy" to "new" state information was only done when saving the state of perspectives when switching them (and for the active Perspective at shutdown). The code that serialized that into settings was expecting "new" state information, which was not true and lead to soft asserts. Do the conversion directly when reading settings instead. Change-Id: I588fcf49bb7195100030266e5752358b7e734113 Reviewed-by: Christian Stenger --- src/plugins/debugger/debuggermainwindow.cpp | 4 +--- src/plugins/debugger/debuggermainwindow.h | 14 ++++++++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/plugins/debugger/debuggermainwindow.cpp b/src/plugins/debugger/debuggermainwindow.cpp index 16f0f8dface..deff925fc8e 100644 --- a/src/plugins/debugger/debuggermainwindow.cpp +++ b/src/plugins/debugger/debuggermainwindow.cpp @@ -1078,15 +1078,13 @@ const char *PerspectiveState::savesHeaderKey() bool PerspectiveState::hasWindowState() const { - return !mainWindowState.isEmpty() || !mainWindowStateLegacy.isEmpty(); + return !mainWindowState.isEmpty(); } bool PerspectiveState::restoreWindowState(FancyMainWindow * mainWindow) { if (!mainWindowState.isEmpty()) return mainWindow->restoreSettings(mainWindowState); - if (!mainWindowStateLegacy.isEmpty()) - return mainWindow->restoreFancyState(mainWindowStateLegacy); return false; } diff --git a/src/plugins/debugger/debuggermainwindow.h b/src/plugins/debugger/debuggermainwindow.h index ed53e30db78..e92e342397f 100644 --- a/src/plugins/debugger/debuggermainwindow.h +++ b/src/plugins/debugger/debuggermainwindow.h @@ -45,19 +45,25 @@ public: Store mainWindowState; QVariantHash headerViewStates; - QByteArray mainWindowStateLegacy; // legacy for up to QtC 12 - Store toSettings() const; static PerspectiveState fromSettings(const Store &settings); // legacy for up to QtC 12, operators for direct QVariant conversion friend QDataStream &operator>>(QDataStream &ds, PerspectiveState &state) { - return ds >> state.mainWindowStateLegacy >> state.headerViewStates; + QByteArray mainWindowStateLegacy; + ds >> mainWindowStateLegacy >> state.headerViewStates; + // the "legacy" state is just the QMainWindow::saveState(), which is + // saved under "State" in the FancyMainWindow state + state.mainWindowState.clear(); + state.mainWindowState.insert("State", mainWindowStateLegacy); + return ds; } friend QDataStream &operator<<(QDataStream &ds, const PerspectiveState &state) { - return ds << state.mainWindowStateLegacy << state.headerViewStates; + // the "legacy" state is just the QMainWindow::saveState(), which is + // saved under "State" in the FancyMainWindow state + return ds << state.mainWindowState.value("State") << state.headerViewStates; } };