mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-01-17 15:32:11 -08:00
hotfix: Remove menus when closing game (#5744)
Version of #5740 that doesn't leave freed `QMenu`s lying around.
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user