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)
|
void setPanel(QWidget *panel)
|
||||||
{
|
{
|
||||||
|
q->savePersistentSettings();
|
||||||
if (QWidget *widget = q->centralWidget()) {
|
if (QWidget *widget = q->centralWidget()) {
|
||||||
q->takeCentralWidget();
|
q->takeCentralWidget();
|
||||||
widget->hide(); // Don't delete.
|
widget->hide(); // Don't delete.
|
||||||
@@ -630,6 +631,7 @@ public:
|
|||||||
if (q->hasFocus()) // we get assigned focus from setFocusToCurrentMode, pass that on
|
if (q->hasFocus()) // we get assigned focus from setFocusToCurrentMode, pass that on
|
||||||
panel->setFocus();
|
panel->setFocus();
|
||||||
}
|
}
|
||||||
|
q->loadPersistentSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectWindow *q;
|
ProjectWindow *q;
|
||||||
@@ -670,9 +672,7 @@ void ProjectWindow::hideEvent(QHideEvent *event)
|
|||||||
void ProjectWindow::showEvent(QShowEvent *event)
|
void ProjectWindow::showEvent(QShowEvent *event)
|
||||||
{
|
{
|
||||||
FancyMainWindow::showEvent(event);
|
FancyMainWindow::showEvent(event);
|
||||||
|
loadPersistentSettings();
|
||||||
// Delay appears to be necessary for the target setup page to have the correct layout.
|
|
||||||
QTimer::singleShot(0, this, &ProjectWindow::loadPersistentSettings);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectWindow::~ProjectWindow() = default;
|
ProjectWindow::~ProjectWindow() = default;
|
||||||
@@ -681,6 +681,8 @@ const char PROJECT_WINDOW_KEY[] = "ProjectExplorer.ProjectWindow";
|
|||||||
|
|
||||||
void ProjectWindow::savePersistentSettings() const
|
void ProjectWindow::savePersistentSettings() const
|
||||||
{
|
{
|
||||||
|
if (!centralWidget())
|
||||||
|
return;
|
||||||
QSettings * const settings = ICore::settings();
|
QSettings * const settings = ICore::settings();
|
||||||
settings->beginGroup(PROJECT_WINDOW_KEY);
|
settings->beginGroup(PROJECT_WINDOW_KEY);
|
||||||
saveSettings(settings);
|
saveSettings(settings);
|
||||||
@@ -689,6 +691,8 @@ void ProjectWindow::savePersistentSettings() const
|
|||||||
|
|
||||||
void ProjectWindow::loadPersistentSettings()
|
void ProjectWindow::loadPersistentSettings()
|
||||||
{
|
{
|
||||||
|
if (!centralWidget())
|
||||||
|
return;
|
||||||
QSettings * const settings = ICore::settings();
|
QSettings * const settings = ICore::settings();
|
||||||
settings->beginGroup(PROJECT_WINDOW_KEY);
|
settings->beginGroup(PROJECT_WINDOW_KEY);
|
||||||
restoreSettings(settings);
|
restoreSettings(settings);
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ class ProjectWindowPrivate;
|
|||||||
|
|
||||||
class ProjectWindow : public Utils::FancyMainWindow
|
class ProjectWindow : public Utils::FancyMainWindow
|
||||||
{
|
{
|
||||||
|
friend class ProjectWindowPrivate;
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|||||||
Reference in New Issue
Block a user