hotfix: Remove menus when closing game (#5744)

Version of #5740 that doesn't leave freed `QMenu`s lying around.
This commit is contained in:
Basile Clement
2025-03-18 03:54:16 +01:00
committed by GitHub
parent 4812508afc
commit c219d8bdbb

View File

@@ -256,6 +256,12 @@ void TabSupervisor::closeEvent(QCloseEvent *event)
QSet<int> gameTabsToRemove;
for (auto it = gameTabs.begin(), end = gameTabs.end(); it != end; ++it) {
if (it.value()->close()) {
// Hotfix: the tab owns the `QMenu`s so they need to be cleared,
// otherwise we end up with use-after-free bugs.
if (it.value() == currentWidget()) {
emit setMenu();
}
gameTabsToRemove.insert(it.key());
} else {
event->ignore();