don't emit signals in dtors

This commit is contained in:
RickyRister 2025-01-11 16:11:07 -08:00
parent 48414986f8
commit b4d7b2cd22
8 changed files with 34 additions and 45 deletions

View file

@ -358,7 +358,7 @@ void TabDeckEditor::createMenus()
analyzeDeckMenu->addAction(aAnalyzeDeckTappedout); analyzeDeckMenu->addAction(aAnalyzeDeckTappedout);
aClose = new QAction(QString(), this); aClose = new QAction(QString(), this);
connect(aClose, SIGNAL(triggered()), this, SLOT(closeRequest())); connect(aClose, &QAction::triggered, this, [this](bool) { closeRequest(); });
aClearFilterAll = new QAction(QString(), this); aClearFilterAll = new QAction(QString(), this);
aClearFilterAll->setIcon(QPixmap("theme:icons/clearsearch")); aClearFilterAll->setIcon(QPixmap("theme:icons/clearsearch"));
@ -721,11 +721,6 @@ TabDeckEditor::TabDeckEditor(TabSupervisor *_tabSupervisor, QWidget *parent)
loadLayout(); loadLayout();
} }
TabDeckEditor::~TabDeckEditor()
{
emit deckEditorClosing(this);
}
void TabDeckEditor::retranslateUi() void TabDeckEditor::retranslateUi()
{ {
cardInfo->retranslateUi(); cardInfo->retranslateUi();
@ -982,7 +977,11 @@ bool TabDeckEditor::confirmClose()
void TabDeckEditor::closeRequest(bool forced) void TabDeckEditor::closeRequest(bool forced)
{ {
if (confirmClose()) if (!forced && !confirmClose()) {
return;
}
emit deckEditorClosing(this);
deleteLater(); deleteLater();
} }

View file

@ -164,7 +164,6 @@ private:
public: public:
explicit TabDeckEditor(TabSupervisor *_tabSupervisor, QWidget *parent = nullptr); explicit TabDeckEditor(TabSupervisor *_tabSupervisor, QWidget *parent = nullptr);
~TabDeckEditor() override;
void retranslateUi() override; void retranslateUi() override;
QString getTabText() const override; QString getTabText() const override;
void setDeck(DeckLoader *_deckLoader); void setDeck(DeckLoader *_deckLoader);

View file

@ -581,16 +581,14 @@ void TabGame::emitUserEvent()
TabGame::~TabGame() TabGame::~TabGame()
{ {
scene->clearViews();
delete replay; delete replay;
QMapIterator<int, Player *> i(players); QMapIterator<int, Player *> i(players);
while (i.hasNext()) { while (i.hasNext()) {
delete i.next().value(); delete i.next().value();
} }
players.clear();
emit gameClosing(this);
} }
void TabGame::updatePlayerListDockTitle() void TabGame::updatePlayerListDockTitle()
@ -703,7 +701,13 @@ void TabGame::retranslateUi()
void TabGame::closeRequest(bool forced) void TabGame::closeRequest(bool forced)
{ {
actLeaveGame(); if (!forced && !leaveGame()) {
return;
}
emit gameClosing(this);
deleteLater();
} }
void TabGame::replayNextEvent(Player::EventProcessingOptions options) void TabGame::replayNextEvent(Player::EventProcessingOptions options)
@ -794,19 +798,23 @@ void TabGame::actConcede()
} }
} }
void TabGame::actLeaveGame() /**
* Confirms the leave game and sends the leave game command, if applicable.
*
* @return True if the leave game is confirmed
*/
bool TabGame::leaveGame()
{ {
if (!gameClosed) { if (!gameClosed) {
if (!spectator) if (!spectator)
if (QMessageBox::question(this, tr("Leave game"), tr("Are you sure you want to leave this game?"), if (QMessageBox::question(this, tr("Leave game"), tr("Are you sure you want to leave this game?"),
QMessageBox::Yes | QMessageBox::No, QMessageBox::No) != QMessageBox::Yes) QMessageBox::Yes | QMessageBox::No, QMessageBox::No) != QMessageBox::Yes)
return; return false;
if (!replay) if (!replay)
sendGameCommand(Command_LeaveGame()); sendGameCommand(Command_LeaveGame());
} }
scene->clearViews(); return true;
deleteLater();
} }
void TabGame::actSay() void TabGame::actSay()
@ -1598,7 +1606,7 @@ void TabGame::createMenuItems()
aConcede = new QAction(this); aConcede = new QAction(this);
connect(aConcede, SIGNAL(triggered()), this, SLOT(actConcede())); connect(aConcede, SIGNAL(triggered()), this, SLOT(actConcede()));
aLeaveGame = new QAction(this); aLeaveGame = new QAction(this);
connect(aLeaveGame, SIGNAL(triggered()), this, SLOT(actLeaveGame())); connect(aLeaveGame, &QAction::triggered, this, [this](bool) { closeRequest(); });
aFocusChat = new QAction(this); aFocusChat = new QAction(this);
connect(aFocusChat, SIGNAL(triggered()), sayEdit, SLOT(setFocus())); connect(aFocusChat, SIGNAL(triggered()), sayEdit, SLOT(setFocus()));
aCloseReplay = nullptr; aCloseReplay = nullptr;
@ -1648,7 +1656,7 @@ void TabGame::createReplayMenuItems()
aFocusChat = nullptr; aFocusChat = nullptr;
aLeaveGame = nullptr; aLeaveGame = nullptr;
aCloseReplay = new QAction(this); aCloseReplay = new QAction(this);
connect(aCloseReplay, SIGNAL(triggered()), this, SLOT(actLeaveGame())); connect(aCloseReplay, &QAction::triggered, this, [this](bool) { closeRequest(); });
phasesMenu = nullptr; phasesMenu = nullptr;
gameMenu = new QMenu(this); gameMenu = new QMenu(this);

View file

@ -189,6 +189,7 @@ private:
void startGame(bool resuming); void startGame(bool resuming);
void stopGame(); void stopGame();
void closeGame(); void closeGame();
bool leaveGame();
void eventSpectatorSay(const Event_GameSay &event, int eventPlayerId, const GameEventContext &context); void eventSpectatorSay(const Event_GameSay &event, int eventPlayerId, const GameEventContext &context);
void eventSpectatorLeave(const Event_Leave &event, int eventPlayerId, const GameEventContext &context); void eventSpectatorLeave(const Event_Leave &event, int eventPlayerId, const GameEventContext &context);
@ -242,7 +243,6 @@ private slots:
void actGameInfo(); void actGameInfo();
void actConcede(); void actConcede();
void actLeaveGame();
void actRemoveLocalArrows(); void actRemoveLocalArrows();
void actRotateViewCW(); void actRotateViewCW();
void actRotateViewCCW(); void actRotateViewCCW();

View file

@ -38,7 +38,7 @@ TabMessage::TabMessage(TabSupervisor *_tabSupervisor,
vbox->addWidget(sayEdit); vbox->addWidget(sayEdit);
aLeave = new QAction(this); aLeave = new QAction(this);
connect(aLeave, SIGNAL(triggered()), this, SLOT(actLeave())); connect(aLeave, &QAction::triggered, this, [this](bool) { closeRequest(); });
messageMenu = new QMenu(this); messageMenu = new QMenu(this);
messageMenu->addAction(aLeave); messageMenu->addAction(aLeave);
@ -53,7 +53,6 @@ TabMessage::TabMessage(TabSupervisor *_tabSupervisor,
TabMessage::~TabMessage() TabMessage::~TabMessage()
{ {
emit talkClosing(this);
delete ownUserInfo; delete ownUserInfo;
delete otherUserInfo; delete otherUserInfo;
} }
@ -88,7 +87,8 @@ QString TabMessage::getTabText() const
void TabMessage::closeRequest(bool forced) void TabMessage::closeRequest(bool forced)
{ {
actLeave(); emit talkClosing(this);
deleteLater();
} }
void TabMessage::sendMessage() void TabMessage::sendMessage()
@ -114,11 +114,6 @@ void TabMessage::messageSent(const Response &response)
"This user is ignoring you, they cannot see your messages in main chat and you cannot join their games.")); "This user is ignoring you, they cannot see your messages in main chat and you cannot join their games."));
} }
void TabMessage::actLeave()
{
deleteLater();
}
void TabMessage::processUserMessageEvent(const Event_UserMessage &event) void TabMessage::processUserMessageEvent(const Event_UserMessage &event)
{ {
auto userInfo = event.sender_name() == otherUserInfo->name() ? otherUserInfo : ownUserInfo; auto userInfo = event.sender_name() == otherUserInfo->name() ? otherUserInfo : ownUserInfo;

View file

@ -29,7 +29,6 @@ signals:
void maximizeClient(); void maximizeClient();
private slots: private slots:
void sendMessage(); void sendMessage();
void actLeave();
void messageSent(const Response &response); void messageSent(const Response &response);
void addMentionTag(QString mentionTag); void addMentionTag(QString mentionTag);
void messageClicked(); void messageClicked();

View file

@ -101,7 +101,7 @@ TabRoom::TabRoom(TabSupervisor *_tabSupervisor,
hbox->addWidget(userList, 1); hbox->addWidget(userList, 1);
aLeaveRoom = new QAction(this); aLeaveRoom = new QAction(this);
connect(aLeaveRoom, SIGNAL(triggered()), this, SLOT(actLeaveRoom())); connect(aLeaveRoom, &QAction::triggered, this, [this](bool) { closeRequest(); });
roomMenu = new QMenu(this); roomMenu = new QMenu(this);
roomMenu->addAction(aLeaveRoom); roomMenu->addAction(aLeaveRoom);
@ -135,11 +135,6 @@ TabRoom::TabRoom(TabSupervisor *_tabSupervisor,
setCentralWidget(mainWidget); setCentralWidget(mainWidget);
} }
TabRoom::~TabRoom()
{
emit roomClosing(this);
}
void TabRoom::retranslateUi() void TabRoom::retranslateUi()
{ {
gameSelector->retranslateUi(); gameSelector->retranslateUi();
@ -177,7 +172,9 @@ void TabRoom::actShowPopup(const QString &message)
void TabRoom::closeRequest(bool forced) void TabRoom::closeRequest(bool forced)
{ {
actLeaveRoom(); sendRoomCommand(prepareRoomCommand(Command_LeaveRoom()));
emit roomClosing(this);
deleteLater();
} }
void TabRoom::tabActivated() void TabRoom::tabActivated()
@ -216,12 +213,6 @@ void TabRoom::sayFinished(const Response &response)
chatView->appendMessage(tr("You are flooding the chat. Please wait a couple of seconds.")); chatView->appendMessage(tr("You are flooding the chat. Please wait a couple of seconds."));
} }
void TabRoom::actLeaveRoom()
{
sendRoomCommand(prepareRoomCommand(Command_LeaveRoom()));
deleteLater();
}
void TabRoom::actClearChat() void TabRoom::actClearChat()
{ {
chatView->clearChat(); chatView->clearChat();

View file

@ -70,7 +70,6 @@ signals:
private slots: private slots:
void sendMessage(); void sendMessage();
void sayFinished(const Response &response); void sayFinished(const Response &response);
void actLeaveRoom();
void actClearChat(); void actClearChat();
void actOpenChatSettings(); void actOpenChatSettings();
void addMentionTag(QString mentionTag); void addMentionTag(QString mentionTag);
@ -91,7 +90,6 @@ public:
AbstractClient *_client, AbstractClient *_client,
ServerInfo_User *_ownUser, ServerInfo_User *_ownUser,
const ServerInfo_Room &info); const ServerInfo_Room &info);
~TabRoom() override;
void retranslateUi() override; void retranslateUi() override;
void closeRequest(bool forced = false) override; void closeRequest(bool forced = false) override;
void tabActivated() override; void tabActivated() override;