Refactor: Don't call stop in TabSupervisor dtor (#6061)

This commit is contained in:
RickyRister 2025-08-01 05:53:06 -07:00 committed by GitHub
parent 62c02e3fce
commit e10dd4ef42
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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<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();
}
}
for (auto tabId : gameTabsToRemove) {
gameTabs.remove(tabId);
}
}
AbstractClient *TabSupervisor::getClient() const