From e10dd4ef42a6a7ac3c88d1775b9a6da595810d2e Mon Sep 17 00:00:00 2001 From: RickyRister <42636155+RickyRister@users.noreply.github.com> Date: Fri, 1 Aug 2025 05:53:06 -0700 Subject: [PATCH] Refactor: Don't call stop in TabSupervisor dtor (#6061) --- cockatrice/src/client/tabs/tab_supervisor.cpp | 31 ++++++------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/cockatrice/src/client/tabs/tab_supervisor.cpp b/cockatrice/src/client/tabs/tab_supervisor.cpp index 4ed0e5a6b..e75a5ca9c 100644 --- a/cockatrice/src/client/tabs/tab_supervisor.cpp +++ b/cockatrice/src/client/tabs/tab_supervisor.cpp @@ -182,7 +182,16 @@ TabSupervisor::TabSupervisor(AbstractClient *_client, QMenu *tabsMenu, QWidget * TabSupervisor::~TabSupervisor() { - stop(); + // Note: this used to call stop(), but stop() is doing a bunch of stuff including emitting some signals, + // and we don't want to do that in a destructor. + + for (auto &localClient : localClients) { + localClient->deleteLater(); + } + localClients.clear(); + + delete userInfo; + userInfo = nullptr; } void TabSupervisor::retranslateUi() @@ -268,26 +277,6 @@ void TabSupervisor::closeEvent(QCloseEvent *event) event->ignore(); } } - - // Close the game tabs in order to make sure they store their layout. - 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(); - } - } - - for (auto tabId : gameTabsToRemove) { - gameTabs.remove(tabId); - } } AbstractClient *TabSupervisor::getClient() const