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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user