Skip to content

Commit

Permalink
Fix addDockWidgetToContainingWindow with nested main windows
Browse files Browse the repository at this point in the history
It needs to be added to the direct parent, not to the top-level
main window.

Fixes issue #386
  • Loading branch information
iamsergio committed Apr 1, 2024
1 parent e315e70 commit e5ad0cc
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
1 change: 1 addition & 0 deletions Changelog
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
- Fixed double-click on titlebar not floating it if auto-hide flag was enabled
- Added Config::setLayoutSpacing(int)
- LayoutSaverOption::Skip now honours docked dock widgets
- Fixed DockWidget::addDockWidgetToContainingWindow() when using nested main windows (#386)

* v2.0.0 (05 December 2023)
- Architecture rewrite to support more frontends besides QtWidgets and QtQuick.
Expand Down
4 changes: 2 additions & 2 deletions src/core/DockWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ void DockWidget::addDockWidgetToContainingWindow(DockWidget *other, Location loc
if (!other)
return;

if (auto mainWindow = view()->rootView()->asMainWindowController()) {
if (auto mw = mainWindow()) {
// It's inside a main window. Simply use the main window API.
mainWindow->addDockWidget(other, location, relativeTo, initialOption);
mw->addDockWidget(other, location, relativeTo, initialOption);
return;
}

Expand Down
2 changes: 0 additions & 2 deletions tests/qtwidgets/tst_qtwidgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2805,8 +2805,6 @@ void TestQtWidgets::tst_addDockWidgetToContainingWindowNested()

QCOMPARE(d1->dockWidget()->mainWindow(), m1.get());
QCOMPARE(d2->dockWidget()->mainWindow(), nestedMainWindow.get());

QEXPECT_FAIL("", "Bug #386, to be fixed", Continue);
QCOMPARE(d3->dockWidget()->mainWindow(), nestedMainWindow.get());
}
}
Expand Down

0 comments on commit e5ad0cc

Please sign in to comment.