When loading a layout, force close any orphaned windows

An orphaned window has a NULL parent.
An orphaned window is unable to be re-opened if it already exists in m_ToolWindows because when it tries to raise the existing window it does not have a valid parent
This commit is contained in:
Jake Turner
2023-11-09 11:23:48 +00:00
parent 063a92d930
commit 769a2612d9
+14 -1
View File
@@ -3101,7 +3101,20 @@ bool MainWindow::LoadLayout(int layout)
if(!success)
return false;
return restoreState(state);
if(restoreState(state))
{
// Close any windows which have now become orphaned
foreach(QWidget *toolWindow, ui->toolWindowManager->toolWindows())
{
if(ui->toolWindowManager->areaOf(toolWindow) == NULL)
{
qInfo() << "Manually closing orphaned window " << toolWindow->objectName();
ui->toolWindowManager->forceCloseToolWindow(toolWindow);
}
}
return true;
}
return false;
}
qInfo() << "Couldn't load layout from " << path << " " << f.errorString();