Fix DockWidget::isInMainWindow()

FloatingWindows are parented to the main window, so we need to stop
the loop once isWindow().

The tests didn't catch this because the floating window in the test
was created before the main window, so it truly didn't have a parent

Fixes #69
This commit is contained in:
Sergio Martins
2020-09-11 22:32:03 +01:00
parent 4bdfc35c8c
commit 98225ac9a3
2 changed files with 14 additions and 2 deletions

View File

@@ -79,13 +79,19 @@ public:
MainWindowBase *mainWindow() const
{
if (q->isWindow())
return nullptr;
// Note: Don't simply use window(), as the MainWindow might be embedded into something else
QObject *p = q->parent();
QWidgetOrQuick *p = q->parentWidget();
while (p) {
if (auto window = qobject_cast<MainWindowBase*>(p))
return window;
p = p->parent();
if (p->isWindow())
return nullptr;
p = p->parentWidget();
}
return nullptr;