diff --git a/cockatrice/src/client/tabs/tab_supervisor.cpp b/cockatrice/src/client/tabs/tab_supervisor.cpp index 8ba5d791a..632eae06d 100644 --- a/cockatrice/src/client/tabs/tab_supervisor.cpp +++ b/cockatrice/src/client/tabs/tab_supervisor.cpp @@ -256,6 +256,12 @@ void TabSupervisor::closeEvent(QCloseEvent *event) QSet 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();