forked from qt-creator/qt-creator
Debugger: Fix saving (legacy) state
Since dd9f9c799b
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 <christian.stenger@qt.io>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user