hotfix: Remove menus when closing game

Version of #5740 that doesn't leave freed `QMenu`s lying around.
This commit is contained in:
Basile Clément 2025-03-17 21:47:59 +01:00
parent 57b9f0e54c
commit 84fd779bfb
No known key found for this signature in database

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();