From f4239c5b630de6c90c2b6b0c62ae199fdd0b776d Mon Sep 17 00:00:00 2001 From: rainmakerv2 <30595646+jpau02@users.noreply.github.com> Date: Wed, 18 Dec 2024 07:46:36 +0800 Subject: [PATCH] Put extern variable in dedicated namespace --- src/qt_gui/main_window.cpp | 8 ++++++-- src/qt_gui/main_window.h | 5 ++++- src/qt_gui/settings_dialog.cpp | 5 +++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/qt_gui/main_window.cpp b/src/qt_gui/main_window.cpp index bccef11a5..aad81b585 100644 --- a/src/qt_gui/main_window.cpp +++ b/src/qt_gui/main_window.cpp @@ -26,7 +26,9 @@ #include "common/discord_rpc_handler.h" #endif -bool isGameRunning = false; +namespace QtExternal { + static bool isGameRunning = false; +} MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); @@ -554,7 +556,9 @@ void MainWindow::CreateConnects() { } void MainWindow::StartGame() { - isGameRunning = true; + using namespace QtExternal; + QtExternal::isGameRunning = true; + BackgroundMusicPlayer::getInstance().stopMusic(); QString gamePath = ""; int table_mode = Config::getTableMode(); diff --git a/src/qt_gui/main_window.h b/src/qt_gui/main_window.h index 2ea3433db..dc8cf0826 100644 --- a/src/qt_gui/main_window.h +++ b/src/qt_gui/main_window.h @@ -22,7 +22,10 @@ #include "main_window_ui.h" #include "pkg_viewer.h" -extern bool isGameRunning; +namespace QtExternal { + extern bool isGameRunning; +} + class GameListFrame; class MainWindow : public QMainWindow { diff --git a/src/qt_gui/settings_dialog.cpp b/src/qt_gui/settings_dialog.cpp index 849940964..eceb43321 100644 --- a/src/qt_gui/settings_dialog.cpp +++ b/src/qt_gui/settings_dialog.cpp @@ -376,11 +376,12 @@ void SettingsDialog::OnCursorStateChanged(s16 index) { } void SettingsDialog::GammaSliderChange(int value) { + using namespace QtExternal; float Gammafloat = static_cast((value / 1000.0f)); ui->GammaLabel->setText(QString::number(Gammafloat, 'f', 3)); - // presenter crashes if game is running, set isGameRunning to off when stop game is implemented - if (isGameRunning) { + // GetGammaRef crashes if no game is running, set isGameRunning to false when MainWindow::StopGame is implemented + if (QtExternal::isGameRunning) { presenter->GetGammaRef() = Gammafloat; } }