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 authored and github-actions committed Jul 18, 2021
1 parent 5566654 commit 08a02a4d092d0785c25a1c0934437b26bc281f09
Showing with 22 additions and 1 deletion.
  1. +21 −1 src/app/qgisapp.cpp
  2. +1 −0 src/app/qgisapp.h
@@ -5210,11 +5210,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() )
{
@@ -16828,3 +16832,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" ) );
}
} );
}
@@ -1260,6 +1260,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 08a02a4

Please sign in to comment.