Skip to content
Permalink
Browse files
Fix dock widget sizes are not correctly restored
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 committed Jul 18, 2021
1 parent 55485d3 commit d16d76155ed78047ea18d6eabd1edb141079cc9f
Showing with 22 additions and 1 deletion.
  1. +21 −1 src/app/qgisapp.cpp
  2. +1 −0 src/app/qgisapp.h
@@ -5159,11 +5159,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() )
{
@@ -17150,3 +17154,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" ) );
}
} );
}
@@ -1274,6 +1274,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;

0 comments on commit d16d761

Please sign in to comment.