Skip to content

Commit

Permalink
Fix dock widget sizes are not correctly restored
Browse files Browse the repository at this point in the history
Because of upstream regression https://bugreports.qt.io/browse/QTBUG-89034
we have to hack around this bug downstream

Fixes #44186
  • Loading branch information
nyalldawson authored and github-actions[bot] committed Jul 18, 2021
1 parent 935f45c commit 026dc4b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/app/qgisapp.cpp
Expand Up @@ -5142,11 +5142,15 @@ void QgisApp::restoreWindowState()
{
// restore the toolbar and dock widgets positions using Qt4 settings API
QgsSettings settings;

#if 0
// because of Qt regression: https://bugreports.qt.io/browse/QTBUG-89034
// we have to wait till dialog is first shown to try to restore dock geometry or it's not correctly restored
// so this code was moved to showEvent for now...
if ( !restoreState( settings.value( QStringLiteral( "UI/state" ), QByteArray::fromRawData( reinterpret_cast< const char * >( defaultUIstate ), sizeof defaultUIstate ) ).toByteArray() ) )
{
QgsDebugMsg( QStringLiteral( "restore of UI state failed" ) );
}
#endif

if ( settings.value( QStringLiteral( "UI/hidebrowser" ), false ).toBool() )
{
Expand Down Expand Up @@ -17349,3 +17353,19 @@ QgsAttributeEditorContext QgisApp::createAttributeEditorContext()
context.setMainMessageBar( messageBar() );
return context;
}

void QgisApp::showEvent( QShowEvent *event )
{
QMainWindow::showEvent( event );
// because of Qt regression: https://bugreports.qt.io/browse/QTBUG-89034
// we have to wait till dialog is first shown to try to restore dock geometry or it's not correctly restored
static std::once_flag firstShow;
std::call_once( firstShow, [this]
{
QgsSettings settings;
if ( !restoreState( settings.value( QStringLiteral( "UI/state" ), QByteArray::fromRawData( reinterpret_cast< const char * >( defaultUIstate ), sizeof defaultUIstate ) ).toByteArray() ) )
{
QgsDebugMsg( QStringLiteral( "restore of UI state failed" ) );
}
} );
}
1 change: 1 addition & 0 deletions src/app/qgisapp.h
Expand Up @@ -1279,6 +1279,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
QgsAttributeEditorContext createAttributeEditorContext();

protected:
void showEvent( QShowEvent *event ) override;

//! Handle state changes (WindowTitleChange)
void changeEvent( QEvent *event ) override;
Expand Down

0 comments on commit 026dc4b

Please sign in to comment.