forked from qt-creator/qt-creator
ProjectExplorer: Fix project mode layout issue
Window state save/restore was undermined by code that added and removed the central widget, leading to inconsistent data. Fix this by making sure that we (de-)serialize if and only if a central widget is present. Also remove the hacky workaround that was supposed to fix this, but didn't. Fixes: QTCREATORBUG-25551 Change-Id: I6e7f2aff7455db476f870ead64b09a9716f3558b Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
@@ -620,6 +620,7 @@ public:
|
||||
|
||||
void setPanel(QWidget *panel)
|
||||
{
|
||||
q->savePersistentSettings();
|
||||
if (QWidget *widget = q->centralWidget()) {
|
||||
q->takeCentralWidget();
|
||||
widget->hide(); // Don't delete.
|
||||
@@ -630,6 +631,7 @@ public:
|
||||
if (q->hasFocus()) // we get assigned focus from setFocusToCurrentMode, pass that on
|
||||
panel->setFocus();
|
||||
}
|
||||
q->loadPersistentSettings();
|
||||
}
|
||||
|
||||
ProjectWindow *q;
|
||||
@@ -670,9 +672,7 @@ void ProjectWindow::hideEvent(QHideEvent *event)
|
||||
void ProjectWindow::showEvent(QShowEvent *event)
|
||||
{
|
||||
FancyMainWindow::showEvent(event);
|
||||
|
||||
// Delay appears to be necessary for the target setup page to have the correct layout.
|
||||
QTimer::singleShot(0, this, &ProjectWindow::loadPersistentSettings);
|
||||
loadPersistentSettings();
|
||||
}
|
||||
|
||||
ProjectWindow::~ProjectWindow() = default;
|
||||
@@ -681,6 +681,8 @@ const char PROJECT_WINDOW_KEY[] = "ProjectExplorer.ProjectWindow";
|
||||
|
||||
void ProjectWindow::savePersistentSettings() const
|
||||
{
|
||||
if (!centralWidget())
|
||||
return;
|
||||
QSettings * const settings = ICore::settings();
|
||||
settings->beginGroup(PROJECT_WINDOW_KEY);
|
||||
saveSettings(settings);
|
||||
@@ -689,6 +691,8 @@ void ProjectWindow::savePersistentSettings() const
|
||||
|
||||
void ProjectWindow::loadPersistentSettings()
|
||||
{
|
||||
if (!centralWidget())
|
||||
return;
|
||||
QSettings * const settings = ICore::settings();
|
||||
settings->beginGroup(PROJECT_WINDOW_KEY);
|
||||
restoreSettings(settings);
|
||||
|
||||
Reference in New Issue
Block a user