[TabGame] Don't create replay dock if not replay tab (#6527)

* [TabGame] Don't create replay dock if not replay tab

* use replayDock to determine if replay tab

* null check replayManager in dtor
This commit is contained in:
RickyRister 2026-01-16 09:45:10 -08:00 committed by GitHub
parent 84483c56d7
commit c7c7bf550a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 14 deletions

View file

@ -97,12 +97,11 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor,
createMessageDock();
createPlayAreaWidget();
createDeckViewContainerWidget();
createReplayDock(nullptr);
replayDock = nullptr;
addDockWidget(Qt::RightDockWidgetArea, cardInfoDock);
addDockWidget(Qt::RightDockWidgetArea, playerListDock);
addDockWidget(Qt::RightDockWidgetArea, messageLayoutDock);
replayDock->setHidden(true);
mainWidget = new QStackedWidget(this);
mainWidget->addWidget(deckViewContainerWidget);
@ -256,13 +255,15 @@ void TabGame::emitUserEvent()
TabGame::~TabGame()
{
delete replayManager->replay;
if (replayManager) {
delete replayManager->replay;
}
}
void TabGame::updatePlayerListDockTitle()
{
QString tabText = " | " + (replayManager->replay ? tr("Replay") : tr("Game")) + " #" +
QString::number(game->getGameMetaInfo()->gameId());
QString type = replayDock ? tr("Replay") : tr("Game");
QString tabText = " | " + type + " #" + QString::number(game->getGameMetaInfo()->gameId());
QString userCountInfo =
QString(" %1/%2").arg(game->getPlayerManager()->getPlayerCount()).arg(game->getGameMetaInfo()->maxPlayers());
playerListDock->setWindowTitle(tr("Player List") + userCountInfo +
@ -271,8 +272,8 @@ void TabGame::updatePlayerListDockTitle()
void TabGame::retranslateUi()
{
QString tabText = " | " + (replayManager->replay ? tr("Replay") : tr("Game")) + " #" +
QString::number(game->getGameMetaInfo()->gameId());
QString type = replayDock ? tr("Replay") : tr("Game");
QString tabText = " | " + type + " #" + QString::number(game->getGameMetaInfo()->gameId());
updatePlayerListDockTitle();
cardInfoDock->setWindowTitle(tr("Card Info") + (cardInfoDock->isWindow() ? tabText : QString()));
@ -318,7 +319,7 @@ void TabGame::retranslateUi()
}
}
if (aLeaveGame) {
if (replayManager->replay) {
if (replayDock) {
aLeaveGame->setText(tr("C&lose replay"));
} else {
aLeaveGame->setText(tr("&Leave game"));
@ -517,7 +518,7 @@ bool TabGame::leaveGame()
return false;
}
if (!replayManager->replay)
if (!replayDock)
emit gameLeft();
}
return true;
@ -904,7 +905,7 @@ QString TabGame::getTabText() const
QString gameId(QString::number(game->getGameMetaInfo()->gameId()));
QString tabText;
if (replayManager->replay)
if (replayDock)
tabText.append(tr("Replay") + " ");
if (!gameTypeInfo.isEmpty())
tabText.append(gameTypeInfo + " ");
@ -1085,7 +1086,7 @@ void TabGame::createViewMenuItems()
void TabGame::loadLayout()
{
LayoutsSettings &layouts = SettingsCache::instance().layouts();
if (replayManager->replay) {
if (replayDock) {
restoreGeometry(layouts.getReplayPlayAreaGeometry());
restoreState(layouts.getReplayPlayAreaLayoutState());
@ -1121,7 +1122,7 @@ void TabGame::loadLayout()
aMessageLayoutDockFloating->setChecked(messageLayoutDock->isFloating());
aPlayerListDockFloating->setChecked(playerListDock->isFloating());
if (replayManager->replay) {
if (replayDock) {
aReplayDockVisible->setChecked(replayDock->isVisible());
aReplayDockFloating->setEnabled(aReplayDockVisible->isChecked());
aReplayDockFloating->setChecked(replayDock->isFloating());
@ -1380,7 +1381,7 @@ void TabGame::createMessageDock(bool bReplay)
void TabGame::hideEvent(QHideEvent *event)
{
LayoutsSettings &layouts = SettingsCache::instance().layouts();
if (replayManager->replay) {
if (replayDock) {
layouts.setReplayPlayAreaState(saveState());
layouts.setReplayPlayAreaGeometry(saveGeometry());
layouts.setReplayCardInfoSize(cardInfoDock->size());