mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-21 22:33:54 -07: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:
parent
4812508afc
commit
c219d8bdbb
1 changed files with 6 additions and 0 deletions
|
|
@ -256,6 +256,12 @@ void TabSupervisor::closeEvent(QCloseEvent *event)
|
||||||
QSet<int> gameTabsToRemove;
|
QSet<int> gameTabsToRemove;
|
||||||
for (auto it = gameTabs.begin(), end = gameTabs.end(); it != end; ++it) {
|
for (auto it = gameTabs.begin(), end = gameTabs.end(); it != end; ++it) {
|
||||||
if (it.value()->close()) {
|
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());
|
gameTabsToRemove.insert(it.key());
|
||||||
} else {
|
} else {
|
||||||
event->ignore();
|
event->ignore();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue