#9935 Avoid storing dock layout if window never has been visible

Do not save the state if the window never has been visible. This will write out a state that is not valid.
This commit is contained in:
Magne Sjaastad
2024-09-11 15:56:35 +02:00
parent 9e41db33f5
commit eb0b02ae46
2 changed files with 18 additions and 0 deletions

View File

@@ -63,6 +63,7 @@ RiuMainWindowBase::RiuMainWindowBase()
, m_showFirstVisibleWindowMaximized( true )
, m_blockSubWindowActivation( false )
, m_blockSubWindowProjectTreeSelection( false )
, m_hasBeenVisible( false )
, m_windowMenu( nullptr )
, m_mdiArea( nullptr )
{
@@ -214,6 +215,10 @@ QString mainWindowDockWidgetSettingsKey( const QString& settingsFolderName )
//--------------------------------------------------------------------------------------------------
void RiuMainWindowBase::saveWinGeoAndDockToolBarLayout()
{
// Do not save the state if the window never has been visible. This will write out a state that is not valid.
// https://github.com/OPM/ResInsight/issues/9935
if ( !m_hasBeenVisible ) return;
// Company and appname set through QCoreApplication
QSettings settings;
@@ -787,3 +792,13 @@ void RiuMainWindowBase::addDefaultEntriesToWindowsMenu()
m_windowMenu->addAction( cascadeWindowsAction );
m_windowMenu->addAction( closeAllSubWindowsAction );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMainWindowBase::showEvent( QShowEvent* event )
{
m_hasBeenVisible = true;
QMainWindow::showEvent( event );
}

View File

@@ -117,6 +117,8 @@ protected:
virtual QStringList windowsMenuFeatureNames() = 0;
void showEvent( QShowEvent* event ) override;
protected slots:
void slotDockWidgetToggleViewActionTriggered();
void slotRefreshHelpActions();
@@ -156,6 +158,7 @@ private:
bool m_showFirstVisibleWindowMaximized;
bool m_blockSubWindowActivation;
bool m_blockSubWindowProjectTreeSelection;
bool m_hasBeenVisible;
ads::CDockManager* m_dockManager;
};