Core::IsRunning: Avoid Global System Accessor

This commit is contained in:
mitaclaw 2024-04-08 20:33:55 -07:00
parent b71fdef356
commit 0df401b164
25 changed files with 90 additions and 74 deletions

View file

@ -118,7 +118,7 @@ void Host_Message(HostMessageID id)
} }
else if (id == HostMessageID::WMUserStop) else if (id == HostMessageID::WMUserStop)
{ {
if (Core::IsRunning()) if (Core::IsRunning(Core::System::GetInstance()))
Core::QueueHostJob(&Core::Stop); Core::QueueHostJob(&Core::Stop);
} }
} }
@ -272,7 +272,8 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetIsBooting
JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_IsRunning(JNIEnv*, jclass) JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_IsRunning(JNIEnv*, jclass)
{ {
return s_is_booting.IsSet() || static_cast<jboolean>(Core::IsRunning()); return s_is_booting.IsSet() ||
static_cast<jboolean>(Core::IsRunning(Core::System::GetInstance()));
} }
JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_IsRunningAndStarted(JNIEnv*, JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_IsRunningAndStarted(JNIEnv*,
@ -589,7 +590,7 @@ static void Run(JNIEnv* env, std::unique_ptr<BootParameters>&& boot, bool riivol
s_need_nonblocking_alert_msg = false; s_need_nonblocking_alert_msg = false;
surface_guard.unlock(); surface_guard.unlock();
while (Core::IsRunning()) while (Core::IsRunning(Core::System::GetInstance()))
{ {
host_identity_guard.Unlock(); host_identity_guard.Unlock();
s_update_main_frame_event.Wait(); s_update_main_frame_event.Wait();

View file

@ -27,12 +27,13 @@
#include "Core/IOS/IOS.h" #include "Core/IOS/IOS.h"
#include "Core/IOS/USB/Bluetooth/BTBase.h" #include "Core/IOS/USB/Bluetooth/BTBase.h"
#include "Core/SysConf.h" #include "Core/SysConf.h"
#include "Core/System.h"
namespace ConfigLoaders namespace ConfigLoaders
{ {
void SaveToSYSCONF(Config::LayerType layer, std::function<bool(const Config::Location&)> predicate) void SaveToSYSCONF(Config::LayerType layer, std::function<bool(const Config::Location&)> predicate)
{ {
if (Core::IsRunning()) if (Core::IsRunning(Core::System::GetInstance()))
return; return;
IOS::HLE::Kernel ios; IOS::HLE::Kernel ios;
@ -182,7 +183,7 @@ public:
private: private:
void LoadFromSYSCONF(Config::Layer* layer) void LoadFromSYSCONF(Config::Layer* layer)
{ {
if (Core::IsRunning()) if (Core::IsRunning(Core::System::GetInstance()))
return; return;
IOS::HLE::Kernel ios; IOS::HLE::Kernel ios;

View file

@ -188,7 +188,7 @@ void SConfig::SetRunningGameMetadata(const std::string& game_id, const std::stri
m_title_description = title_database.Describe(m_gametdb_id, language); m_title_description = title_database.Describe(m_gametdb_id, language);
NOTICE_LOG_FMT(CORE, "Active title: {}", m_title_description); NOTICE_LOG_FMT(CORE, "Active title: {}", m_title_description);
Host_TitleChanged(); Host_TitleChanged();
if (Core::IsRunning()) if (Core::IsRunning(system))
{ {
Core::UpdateTitle(system); Core::UpdateTitle(system);
} }
@ -196,16 +196,16 @@ void SConfig::SetRunningGameMetadata(const std::string& game_id, const std::stri
Config::AddLayer(ConfigLoaders::GenerateGlobalGameConfigLoader(game_id, revision)); Config::AddLayer(ConfigLoaders::GenerateGlobalGameConfigLoader(game_id, revision));
Config::AddLayer(ConfigLoaders::GenerateLocalGameConfigLoader(game_id, revision)); Config::AddLayer(ConfigLoaders::GenerateLocalGameConfigLoader(game_id, revision));
if (Core::IsRunning()) if (Core::IsRunning(system))
DolphinAnalytics::Instance().ReportGameStart(); DolphinAnalytics::Instance().ReportGameStart();
} }
void SConfig::OnNewTitleLoad(const Core::CPUThreadGuard& guard) void SConfig::OnNewTitleLoad(const Core::CPUThreadGuard& guard)
{ {
if (!Core::IsRunning()) auto& system = guard.GetSystem();
if (!Core::IsRunning(system))
return; return;
auto& system = guard.GetSystem();
auto& ppc_symbol_db = system.GetPPCSymbolDB(); auto& ppc_symbol_db = system.GetPPCSymbolDB();
if (!ppc_symbol_db.IsEmpty()) if (!ppc_symbol_db.IsEmpty())
{ {

View file

@ -190,7 +190,7 @@ std::string StopMessage(bool main_thread, std::string_view message)
void DisplayMessage(std::string message, int time_in_ms) void DisplayMessage(std::string message, int time_in_ms)
{ {
if (!IsRunning()) if (!IsRunning(Core::System::GetInstance()))
return; return;
// Actually displaying non-ASCII could cause things to go pear-shaped // Actually displaying non-ASCII could cause things to go pear-shaped
@ -200,9 +200,8 @@ void DisplayMessage(std::string message, int time_in_ms)
OSD::AddMessage(std::move(message), time_in_ms); OSD::AddMessage(std::move(message), time_in_ms);
} }
bool IsRunning() bool IsRunning(Core::System& system)
{ {
auto& system = Core::System::GetInstance();
return (GetState(system) != State::Uninitialized || s_hardware_initialized) && !s_is_stopping; return (GetState(system) != State::Uninitialized || s_hardware_initialized) && !s_is_stopping;
} }
@ -237,7 +236,7 @@ bool Init(Core::System& system, std::unique_ptr<BootParameters> boot, const Wind
{ {
if (s_emu_thread.joinable()) if (s_emu_thread.joinable())
{ {
if (IsRunning()) if (IsRunning(system))
{ {
PanicAlertFmtT("Emu Thread already running"); PanicAlertFmtT("Emu Thread already running");
return false; return false;
@ -842,7 +841,7 @@ static bool PauseAndLock(Core::System& system, bool do_lock, bool unpause_on_unl
void RunOnCPUThread(Core::System& system, std::function<void()> function, bool wait_for_completion) void RunOnCPUThread(Core::System& system, std::function<void()> function, bool wait_for_completion)
{ {
// If the CPU thread is not running, assume there is no active CPU thread we can race against. // If the CPU thread is not running, assume there is no active CPU thread we can race against.
if (!IsRunning() || IsCPUThread()) if (!IsRunning(system) || IsCPUThread())
{ {
function(); function();
return; return;
@ -1038,7 +1037,7 @@ void HostDispatchJobs(Core::System& system)
// Core::State::Uninitialized: s_is_booting -> s_hardware_initialized // Core::State::Uninitialized: s_is_booting -> s_hardware_initialized
// We need to check variables in the same order as the state // We need to check variables in the same order as the state
// transition, otherwise we race and get transient failures. // transition, otherwise we race and get transient failures.
if (!job.run_after_stop && !s_is_booting.IsSet() && !IsRunning()) if (!job.run_after_stop && !s_is_booting.IsSet() && !IsRunning(system))
continue; continue;
guard.unlock(); guard.unlock();

View file

@ -134,7 +134,7 @@ void UndeclareAsHostThread();
std::string StopMessage(bool main_thread, std::string_view message); std::string StopMessage(bool main_thread, std::string_view message);
bool IsRunning(); bool IsRunning(Core::System& system);
bool IsRunningAndStarted(); // is running and the CPU loop has been entered bool IsRunningAndStarted(); // is running and the CPU loop has been entered
bool IsCPUThread(); // this tells us whether we are the CPU thread. bool IsCPUThread(); // this tells us whether we are the CPU thread.
bool IsGPUThread(); bool IsGPUThread();

View file

@ -55,10 +55,11 @@ static void WalkTheStack(const Core::CPUThreadGuard& guard,
// instead of "pointing ahead" // instead of "pointing ahead"
bool GetCallstack(const Core::CPUThreadGuard& guard, std::vector<CallstackEntry>& output) bool GetCallstack(const Core::CPUThreadGuard& guard, std::vector<CallstackEntry>& output)
{ {
auto& power_pc = guard.GetSystem().GetPowerPC(); auto& system = guard.GetSystem();
auto& power_pc = system.GetPowerPC();
const auto& ppc_state = power_pc.GetPPCState(); const auto& ppc_state = power_pc.GetPPCState();
if (!Core::IsRunning() || !PowerPC::MMU::HostIsRAMAddress(guard, ppc_state.gpr[1])) if (!Core::IsRunning(system) || !PowerPC::MMU::HostIsRAMAddress(guard, ppc_state.gpr[1]))
return false; return false;
if (LR(ppc_state) == 0) if (LR(ppc_state) == 0)

View file

@ -212,7 +212,7 @@ void FifoPlayer::Close()
bool FifoPlayer::IsPlaying() const bool FifoPlayer::IsPlaying() const
{ {
return GetFile() != nullptr && Core::IsRunning(); return GetFile() != nullptr && Core::IsRunning(m_system);
} }
class FifoPlayer::CPUCore final : public CPUCoreBase class FifoPlayer::CPUCore final : public CPUCoreBase

View file

@ -255,7 +255,7 @@ void ProcessorInterfaceManager::IOSNotifyPowerButtonCallback(Core::System& syste
void ProcessorInterfaceManager::ResetButton_Tap() void ProcessorInterfaceManager::ResetButton_Tap()
{ {
if (!Core::IsRunning()) if (!Core::IsRunning(m_system))
return; return;
auto& core_timing = m_system.GetCoreTiming(); auto& core_timing = m_system.GetCoreTiming();
@ -268,7 +268,7 @@ void ProcessorInterfaceManager::ResetButton_Tap()
void ProcessorInterfaceManager::PowerButton_Tap() void ProcessorInterfaceManager::PowerButton_Tap()
{ {
if (!Core::IsRunning()) if (!Core::IsRunning(m_system))
return; return;
auto& core_timing = m_system.GetCoreTiming(); auto& core_timing = m_system.GetCoreTiming();

View file

@ -533,7 +533,7 @@ bool EmulationKernel::BootIOS(const u64 ios_title_id, HangPPC hang_ppc,
void EmulationKernel::InitIPC() void EmulationKernel::InitIPC()
{ {
if (!Core::IsRunning()) if (!Core::IsRunning(m_system))
return; return;
INFO_LOG_FMT(IOS, "IPC initialised."); INFO_LOG_FMT(IOS, "IPC initialised.");

View file

@ -424,7 +424,7 @@ bool MovieManager::IsNetPlayRecording() const
// NOTE: Host Thread // NOTE: Host Thread
void MovieManager::ChangePads() void MovieManager::ChangePads()
{ {
if (!Core::IsRunning()) if (!Core::IsRunning(m_system))
return; return;
ControllerTypeArray controllers{}; ControllerTypeArray controllers{};
@ -571,7 +571,7 @@ bool MovieManager::BeginRecordingInput(const ControllerTypeArray& controllers,
ConfigLoaders::SaveToDTM(&header); ConfigLoaders::SaveToDTM(&header);
Config::AddLayer(ConfigLoaders::GenerateMovieConfigLoader(&header)); Config::AddLayer(ConfigLoaders::GenerateMovieConfigLoader(&header));
if (Core::IsRunning()) if (Core::IsRunning(m_system))
Core::UpdateWantDeterminism(m_system); Core::UpdateWantDeterminism(m_system);
}; };
Core::RunOnCPUThread(m_system, start_recording, true); Core::RunOnCPUThread(m_system, start_recording, true);

View file

@ -856,7 +856,7 @@ static void LoadFileStateData(const std::string& filename, std::vector<u8>& ret_
void LoadAs(Core::System& system, const std::string& filename) void LoadAs(Core::System& system, const std::string& filename)
{ {
if (!Core::IsRunning()) if (!Core::IsRunning(system))
return; return;
if (NetPlay::IsNetPlayRunning()) if (NetPlay::IsNetPlayRunning())

View file

@ -171,7 +171,8 @@ void AchievementSettingsWidget::LoadSettings()
SignalBlocking(m_common_password_input)->setVisible(logged_out); SignalBlocking(m_common_password_input)->setVisible(logged_out);
SignalBlocking(m_common_password_input)->setEnabled(enabled); SignalBlocking(m_common_password_input)->setEnabled(enabled);
SignalBlocking(m_common_login_button)->setVisible(logged_out); SignalBlocking(m_common_login_button)->setVisible(logged_out);
SignalBlocking(m_common_login_button)->setEnabled(enabled && !Core::IsRunning()); SignalBlocking(m_common_login_button)
->setEnabled(enabled && !Core::IsRunning(Core::System::GetInstance()));
SignalBlocking(m_common_logout_button)->setVisible(!logged_out); SignalBlocking(m_common_logout_button)->setVisible(!logged_out);
SignalBlocking(m_common_logout_button)->setEnabled(enabled); SignalBlocking(m_common_logout_button)->setEnabled(enabled);

View file

@ -11,6 +11,7 @@
#include "Core/ConfigManager.h" #include "Core/ConfigManager.h"
#include "Core/Core.h" #include "Core/Core.h"
#include "Core/System.h"
#include "DolphinQt/Settings.h" #include "DolphinQt/Settings.h"
@ -22,11 +23,11 @@ CheatWarningWidget::CheatWarningWidget(const std::string& game_id, bool restart_
ConnectWidgets(); ConnectWidgets();
connect(&Settings::Instance(), &Settings::EnableCheatsChanged, this, connect(&Settings::Instance(), &Settings::EnableCheatsChanged, this,
[this] { Update(Core::IsRunning()); }); [this] { Update(Core::IsRunning(Core::System::GetInstance())); });
connect(&Settings::Instance(), &Settings::EmulationStateChanged, this, connect(&Settings::Instance(), &Settings::EmulationStateChanged, this,
[this](Core::State state) { Update(state == Core::State::Running); }); [this](Core::State state) { Update(state == Core::State::Running); });
Update(Core::IsRunning()); Update(Core::IsRunning(Core::System::GetInstance()));
} }
void CheatWarningWidget::CreateWidgets() void CheatWarningWidget::CreateWidgets()

View file

@ -191,16 +191,16 @@ void GamecubeControllersWidget::SaveSettings()
{ {
Config::ConfigChangeCallbackGuard config_guard; Config::ConfigChangeCallbackGuard config_guard;
auto& system = Core::System::GetInstance();
for (size_t i = 0; i < m_gc_groups.size(); ++i) for (size_t i = 0; i < m_gc_groups.size(); ++i)
{ {
const SerialInterface::SIDevices si_device = const SerialInterface::SIDevices si_device =
FromGCMenuIndex(m_gc_controller_boxes[i]->currentIndex()); FromGCMenuIndex(m_gc_controller_boxes[i]->currentIndex());
Config::SetBaseOrCurrent(Config::GetInfoForSIDevice(static_cast<int>(i)), si_device); Config::SetBaseOrCurrent(Config::GetInfoForSIDevice(static_cast<int>(i)), si_device);
if (Core::IsRunning()) if (Core::IsRunning(system))
{ {
Core::System::GetInstance().GetSerialInterface().ChangeDevice(si_device, system.GetSerialInterface().ChangeDevice(si_device, static_cast<s32>(i));
static_cast<s32>(i));
} }
} }
} }

View file

@ -361,7 +361,7 @@ void GeneralWidget::OnBackendChanged(const QString& backend_name)
const bool supports_adapters = !adapters.empty(); const bool supports_adapters = !adapters.empty();
m_adapter_combo->setCurrentIndex(g_Config.iAdapter); m_adapter_combo->setCurrentIndex(g_Config.iAdapter);
m_adapter_combo->setEnabled(supports_adapters && !Core::IsRunning()); m_adapter_combo->setEnabled(supports_adapters && !Core::IsRunning(Core::System::GetInstance()));
static constexpr char TR_ADAPTER_AVAILABLE_DESCRIPTION[] = static constexpr char TR_ADAPTER_AVAILABLE_DESCRIPTION[] =
QT_TR_NOOP("Selects a hardware adapter to use.<br><br>" QT_TR_NOOP("Selects a hardware adapter to use.<br><br>"

View file

@ -629,7 +629,7 @@ QByteArray MemoryWidget::GetInputData() const
void MemoryWidget::OnSetValue() void MemoryWidget::OnSetValue()
{ {
if (!Core::IsRunning()) if (!Core::IsRunning(m_system))
return; return;
auto target_addr = GetTargetAddress(); auto target_addr = GetTargetAddress();
@ -675,7 +675,7 @@ void MemoryWidget::OnSetValue()
void MemoryWidget::OnSetValueFromFile() void MemoryWidget::OnSetValueFromFile()
{ {
if (!Core::IsRunning()) if (!Core::IsRunning(m_system))
return; return;
auto target_addr = GetTargetAddress(); auto target_addr = GetTargetAddress();

View file

@ -143,7 +143,7 @@ void WatchWidget::UpdateButtonsEnabled()
if (!isVisible()) if (!isVisible())
return; return;
const bool is_enabled = Core::IsRunning(); const bool is_enabled = Core::IsRunning(m_system);
m_new->setEnabled(is_enabled); m_new->setEnabled(is_enabled);
m_delete->setEnabled(is_enabled); m_delete->setEnabled(is_enabled);
m_clear->setEnabled(is_enabled); m_clear->setEnabled(is_enabled);
@ -195,10 +195,10 @@ void WatchWidget::Update()
QBrush brush = QPalette().brush(QPalette::Text); QBrush brush = QPalette().brush(QPalette::Text);
if (!Core::IsRunning() || !PowerPC::MMU::HostIsRAMAddress(guard, entry.address)) if (!Core::IsRunning(m_system) || !PowerPC::MMU::HostIsRAMAddress(guard, entry.address))
brush.setColor(Qt::red); brush.setColor(Qt::red);
if (Core::IsRunning()) if (Core::IsRunning(m_system))
{ {
if (PowerPC::MMU::HostIsRAMAddress(guard, entry.address)) if (PowerPC::MMU::HostIsRAMAddress(guard, entry.address))
{ {

View file

@ -23,6 +23,7 @@
#include "Core/FifoPlayer/FifoDataFile.h" #include "Core/FifoPlayer/FifoDataFile.h"
#include "Core/FifoPlayer/FifoPlayer.h" #include "Core/FifoPlayer/FifoPlayer.h"
#include "Core/FifoPlayer/FifoRecorder.h" #include "Core/FifoPlayer/FifoRecorder.h"
#include "Core/System.h"
#include "DolphinQt/Config/ToolTipControls/ToolTipCheckBox.h" #include "DolphinQt/Config/ToolTipControls/ToolTipCheckBox.h"
#include "DolphinQt/FIFO/FIFOAnalyzer.h" #include "DolphinQt/FIFO/FIFOAnalyzer.h"
@ -316,7 +317,7 @@ void FIFOPlayerWindow::UpdateInfo()
return; return;
} }
if (Core::IsRunning() && m_fifo_recorder.IsRecording()) if (Core::IsRunning(Core::System::GetInstance()) && m_fifo_recorder.IsRecording())
{ {
m_info_label->setText(tr("Recording...")); m_info_label->setText(tr("Recording..."));
return; return;
@ -375,7 +376,7 @@ void FIFOPlayerWindow::UpdateLimits()
void FIFOPlayerWindow::UpdateControls() void FIFOPlayerWindow::UpdateControls()
{ {
bool running = Core::IsRunning(); bool running = Core::IsRunning(Core::System::GetInstance());
bool is_recording = m_fifo_recorder.IsRecording(); bool is_recording = m_fifo_recorder.IsRecording();
bool is_playing = m_fifo_player.IsPlaying(); bool is_playing = m_fifo_player.IsPlaying();

View file

@ -370,6 +370,7 @@ void GameList::ShowContextMenu(const QPoint&)
{ {
if (!GetSelectedGame()) if (!GetSelectedGame())
return; return;
auto& system = Core::System::GetInstance();
QMenu* menu = new QMenu(this); QMenu* menu = new QMenu(this);
@ -421,8 +422,8 @@ void GameList::ShowContextMenu(const QPoint&)
QAction* change_disc = menu->addAction(tr("Change &Disc"), this, &GameList::ChangeDisc); QAction* change_disc = menu->addAction(tr("Change &Disc"), this, &GameList::ChangeDisc);
connect(&Settings::Instance(), &Settings::EmulationStateChanged, change_disc, connect(&Settings::Instance(), &Settings::EmulationStateChanged, change_disc,
[change_disc] { change_disc->setEnabled(Core::IsRunning()); }); [&system, change_disc] { change_disc->setEnabled(Core::IsRunning(system)); });
change_disc->setEnabled(Core::IsRunning()); change_disc->setEnabled(Core::IsRunning(system));
menu->addSeparator(); menu->addSeparator();
} }
@ -436,7 +437,7 @@ void GameList::ShowContextMenu(const QPoint&)
// system menu, trigger a refresh. // system menu, trigger a refresh.
Settings::Instance().NANDRefresh(); Settings::Instance().NANDRefresh();
}); });
perform_disc_update->setEnabled(!Core::IsRunning() || !Core::System::GetInstance().IsWii()); perform_disc_update->setEnabled(!Core::IsRunning(system) || !system.IsWii());
} }
if (!is_mod_descriptor && platform == DiscIO::Platform::WiiWAD) if (!is_mod_descriptor && platform == DiscIO::Platform::WiiWAD)
@ -449,10 +450,10 @@ void GameList::ShowContextMenu(const QPoint&)
for (QAction* a : {wad_install_action, wad_uninstall_action}) for (QAction* a : {wad_install_action, wad_uninstall_action})
{ {
a->setEnabled(!Core::IsRunning()); a->setEnabled(!Core::IsRunning(system));
menu->addAction(a); menu->addAction(a);
} }
if (!Core::IsRunning()) if (!Core::IsRunning(system))
wad_uninstall_action->setEnabled(WiiUtils::IsTitleInstalled(game->GetTitleID())); wad_uninstall_action->setEnabled(WiiUtils::IsTitleInstalled(game->GetTitleID()));
connect(&Settings::Instance(), &Settings::EmulationStateChanged, menu, connect(&Settings::Instance(), &Settings::EmulationStateChanged, menu,
@ -473,8 +474,8 @@ void GameList::ShowContextMenu(const QPoint&)
QAction* export_wii_save = QAction* export_wii_save =
menu->addAction(tr("Export Wii Save"), this, &GameList::ExportWiiSave); menu->addAction(tr("Export Wii Save"), this, &GameList::ExportWiiSave);
open_wii_save_folder->setEnabled(!Core::IsRunning()); open_wii_save_folder->setEnabled(!Core::IsRunning(system));
export_wii_save->setEnabled(!Core::IsRunning()); export_wii_save->setEnabled(!Core::IsRunning(system));
menu->addSeparator(); menu->addSeparator();
} }
@ -531,7 +532,7 @@ void GameList::ShowContextMenu(const QPoint&)
connect(&Settings::Instance(), &Settings::EmulationStateChanged, menu, [=](Core::State state) { connect(&Settings::Instance(), &Settings::EmulationStateChanged, menu, [=](Core::State state) {
netplay_host->setEnabled(state == Core::State::Uninitialized); netplay_host->setEnabled(state == Core::State::Uninitialized);
}); });
netplay_host->setEnabled(!Core::IsRunning()); netplay_host->setEnabled(!Core::IsRunning(system));
menu->addAction(netplay_host); menu->addAction(netplay_host);
} }

View file

@ -901,7 +901,7 @@ void MainWindow::OnStopComplete()
bool MainWindow::RequestStop() bool MainWindow::RequestStop()
{ {
if (!Core::IsRunning()) if (!Core::IsRunning(Core::System::GetInstance()))
{ {
Core::QueueHostJob([this](Core::System&) { OnStopComplete(); }, true); Core::QueueHostJob([this](Core::System&) { OnStopComplete(); }, true);
return true; return true;
@ -1532,7 +1532,7 @@ void MainWindow::NetPlayInit()
bool MainWindow::NetPlayJoin() bool MainWindow::NetPlayJoin()
{ {
if (Core::IsRunning()) if (Core::IsRunning(Core::System::GetInstance()))
{ {
ModalMessageBox::critical(nullptr, tr("Error"), ModalMessageBox::critical(nullptr, tr("Error"),
tr("Can't start a NetPlay Session while a game is still running!")); tr("Can't start a NetPlay Session while a game is still running!"));
@ -1599,7 +1599,7 @@ bool MainWindow::NetPlayJoin()
bool MainWindow::NetPlayHost(const UICommon::GameFile& game) bool MainWindow::NetPlayHost(const UICommon::GameFile& game)
{ {
if (Core::IsRunning()) if (Core::IsRunning(Core::System::GetInstance()))
{ {
ModalMessageBox::critical(nullptr, tr("Error"), ModalMessageBox::critical(nullptr, tr("Error"),
tr("Can't start a NetPlay Session while a game is still running!")); tr("Can't start a NetPlay Session while a game is still running!"));
@ -1846,7 +1846,7 @@ void MainWindow::OnImportNANDBackup()
result.wait(); result.wait();
m_menu_bar->UpdateToolsMenu(Core::IsRunning()); m_menu_bar->UpdateToolsMenu(Core::IsRunning(Core::System::GetInstance()));
} }
void MainWindow::OnPlayRecording() void MainWindow::OnPlayRecording()
@ -1876,8 +1876,9 @@ void MainWindow::OnPlayRecording()
void MainWindow::OnStartRecording() void MainWindow::OnStartRecording()
{ {
auto& movie = Core::System::GetInstance().GetMovie(); auto& system = Core::System::GetInstance();
if ((!Core::IsRunningAndStarted() && Core::IsRunning()) || movie.IsRecordingInput() || auto& movie = system.GetMovie();
if ((!Core::IsRunningAndStarted() && Core::IsRunning(system)) || movie.IsRecordingInput() ||
movie.IsPlayingInput()) movie.IsPlayingInput())
{ {
return; return;
@ -1909,7 +1910,7 @@ void MainWindow::OnStartRecording()
{ {
emit RecordingStatusChanged(true); emit RecordingStatusChanged(true);
if (!Core::IsRunning()) if (!Core::IsRunning(system))
Play(); Play();
} }
} }
@ -1970,10 +1971,11 @@ void MainWindow::ShowTASInput()
} }
} }
auto& system = Core::System::GetInstance();
for (int i = 0; i < num_wii_controllers; i++) for (int i = 0; i < num_wii_controllers; i++)
{ {
if (Config::Get(Config::GetInfoForWiimoteSource(i)) == WiimoteSource::Emulated && if (Config::Get(Config::GetInfoForWiimoteSource(i)) == WiimoteSource::Emulated &&
(!Core::IsRunning() || Core::System::GetInstance().IsWii())) (!Core::IsRunning(system) || system.IsWii()))
{ {
SetQWidgetWindowDecorations(m_wii_tas_input_windows[i]); SetQWidgetWindowDecorations(m_wii_tas_input_windows[i]);
m_wii_tas_input_windows[i]->show(); m_wii_tas_input_windows[i]->show();

View file

@ -1265,14 +1265,17 @@ void MenuBar::OnSelectionChanged(std::shared_ptr<const UICommon::GameFile> game_
{ {
m_game_selected = !!game_file; m_game_selected = !!game_file;
m_recording_play->setEnabled(m_game_selected && !Core::IsRunning()); auto& system = Core::System::GetInstance();
m_recording_start->setEnabled((m_game_selected || Core::IsRunning()) && const bool core_is_running = Core::IsRunning(system);
!Core::System::GetInstance().GetMovie().IsPlayingInput()); m_recording_play->setEnabled(m_game_selected && !core_is_running);
m_recording_start->setEnabled((m_game_selected || core_is_running) &&
!system.GetMovie().IsPlayingInput());
} }
void MenuBar::OnRecordingStatusChanged(bool recording) void MenuBar::OnRecordingStatusChanged(bool recording)
{ {
m_recording_start->setEnabled(!recording && (m_game_selected || Core::IsRunning())); auto& system = Core::System::GetInstance();
m_recording_start->setEnabled(!recording && (m_game_selected || Core::IsRunning(system)));
m_recording_stop->setEnabled(recording); m_recording_stop->setEnabled(recording);
m_recording_export->setEnabled(recording); m_recording_export->setEnabled(recording);
} }

View file

@ -43,6 +43,7 @@
#include "Core/IOS/FS/FileSystem.h" #include "Core/IOS/FS/FileSystem.h"
#include "Core/NetPlayServer.h" #include "Core/NetPlayServer.h"
#include "Core/SyncIdentifier.h" #include "Core/SyncIdentifier.h"
#include "Core/System.h"
#include "DolphinQt/NetPlay/ChunkedProgressDialog.h" #include "DolphinQt/NetPlay/ChunkedProgressDialog.h"
#include "DolphinQt/NetPlay/GameDigestDialog.h" #include "DolphinQt/NetPlay/GameDigestDialog.h"
@ -578,7 +579,7 @@ void NetPlayDialog::UpdateDiscordPresence()
m_current_game_name); m_current_game_name);
}; };
if (Core::IsRunning()) if (Core::IsRunning(Core::System::GetInstance()))
return use_default(); return use_default();
if (IsHosting()) if (IsHosting())
@ -802,7 +803,7 @@ void NetPlayDialog::DisplayMessage(const QString& msg, const std::string& color,
QColor c(color.empty() ? QStringLiteral("white") : QString::fromStdString(color)); QColor c(color.empty() ? QStringLiteral("white") : QString::fromStdString(color));
if (g_ActiveConfig.bShowNetPlayMessages && Core::IsRunning()) if (g_ActiveConfig.bShowNetPlayMessages && Core::IsRunning(Core::System::GetInstance()))
g_netplay_chat_ui->AppendChat(msg.toStdString(), g_netplay_chat_ui->AppendChat(msg.toStdString(),
{static_cast<float>(c.redF()), static_cast<float>(c.greenF()), {static_cast<float>(c.redF()), static_cast<float>(c.greenF()),
static_cast<float>(c.blueF())}); static_cast<float>(c.blueF())});
@ -902,7 +903,7 @@ void NetPlayDialog::OnMsgStopGame()
void NetPlayDialog::OnMsgPowerButton() void NetPlayDialog::OnMsgPowerButton()
{ {
if (!Core::IsRunning()) if (!Core::IsRunning(Core::System::GetInstance()))
return; return;
QueueOnObject(this, [] { UICommon::TriggerSTMPowerEvent(); }); QueueOnObject(this, [] { UICommon::TriggerSTMPowerEvent(); });
} }

View file

@ -514,7 +514,8 @@ bool GameCubePane::SetMemcard(ExpansionInterface::Slot slot, const QString& file
const std::string old_eu_path = Config::GetMemcardPath(slot, DiscIO::Region::PAL); const std::string old_eu_path = Config::GetMemcardPath(slot, DiscIO::Region::PAL);
Config::SetBase(Config::GetInfoForMemcardPath(slot), raw_path); Config::SetBase(Config::GetInfoForMemcardPath(slot), raw_path);
if (Core::IsRunning()) auto& system = Core::System::GetInstance();
if (Core::IsRunning(system))
{ {
// If emulation is running and the new card is different from the old one, notify the system to // If emulation is running and the new card is different from the old one, notify the system to
// eject the old and insert the new card. // eject the old and insert the new card.
@ -523,8 +524,8 @@ bool GameCubePane::SetMemcard(ExpansionInterface::Slot slot, const QString& file
{ {
// ChangeDevice unplugs the device for 1 second, which means that games should notice that // ChangeDevice unplugs the device for 1 second, which means that games should notice that
// the path has changed and thus the memory card contents have changed // the path has changed and thus the memory card contents have changed
Core::System::GetInstance().GetExpansionInterface().ChangeDevice( system.GetExpansionInterface().ChangeDevice(slot,
slot, ExpansionInterface::EXIDeviceType::MemoryCard); ExpansionInterface::EXIDeviceType::MemoryCard);
} }
} }
@ -620,7 +621,8 @@ bool GameCubePane::SetGCIFolder(ExpansionInterface::Slot slot, const QString& pa
Config::SetBase(Config::GetInfoForGCIPath(slot), raw_path); Config::SetBase(Config::GetInfoForGCIPath(slot), raw_path);
if (Core::IsRunning()) auto& system = Core::System::GetInstance();
if (Core::IsRunning(system))
{ {
// If emulation is running and the new card is different from the old one, notify the system to // If emulation is running and the new card is different from the old one, notify the system to
// eject the old and insert the new card. // eject the old and insert the new card.
@ -629,7 +631,7 @@ bool GameCubePane::SetGCIFolder(ExpansionInterface::Slot slot, const QString& pa
{ {
// ChangeDevice unplugs the device for 1 second, which means that games should notice that // ChangeDevice unplugs the device for 1 second, which means that games should notice that
// the path has changed and thus the memory card contents have changed // the path has changed and thus the memory card contents have changed
Core::System::GetInstance().GetExpansionInterface().ChangeDevice( system.GetExpansionInterface().ChangeDevice(
slot, ExpansionInterface::EXIDeviceType::MemoryCardFolder); slot, ExpansionInterface::EXIDeviceType::MemoryCardFolder);
} }
} }
@ -660,14 +662,14 @@ void GameCubePane::SetAGPRom(ExpansionInterface::Slot slot, const QString& filen
Config::SetBase(Config::GetInfoForAGPCartPath(slot), path_abs.toStdString()); Config::SetBase(Config::GetInfoForAGPCartPath(slot), path_abs.toStdString());
if (Core::IsRunning() && path_abs != path_old) auto& system = Core::System::GetInstance();
if (Core::IsRunning(system) && path_abs != path_old)
{ {
// ChangeDevice unplugs the device for 1 second. For an actual AGP, you can remove the // ChangeDevice unplugs the device for 1 second. For an actual AGP, you can remove the
// cartridge without unplugging it, and it's not clear if the AGP software actually notices // cartridge without unplugging it, and it's not clear if the AGP software actually notices
// that it's been unplugged or the cartridge has changed, but this was done for memcards so // that it's been unplugged or the cartridge has changed, but this was done for memcards so
// we might as well do it for the AGP too. // we might as well do it for the AGP too.
Core::System::GetInstance().GetExpansionInterface().ChangeDevice( system.GetExpansionInterface().ChangeDevice(slot, ExpansionInterface::EXIDeviceType::AGP);
slot, ExpansionInterface::EXIDeviceType::AGP);
} }
LoadSettings(); LoadSettings();
@ -781,6 +783,7 @@ void GameCubePane::SaveSettings()
Config::SetBaseOrCurrent(Config::MAIN_SKIP_IPL, m_skip_main_menu->isChecked()); Config::SetBaseOrCurrent(Config::MAIN_SKIP_IPL, m_skip_main_menu->isChecked());
Config::SetBaseOrCurrent(Config::MAIN_GC_LANGUAGE, m_language_combo->currentData().toInt()); Config::SetBaseOrCurrent(Config::MAIN_GC_LANGUAGE, m_language_combo->currentData().toInt());
auto& system = Core::System::GetInstance();
// Device Settings // Device Settings
for (ExpansionInterface::Slot slot : ExpansionInterface::SLOTS) for (ExpansionInterface::Slot slot : ExpansionInterface::SLOTS)
{ {
@ -789,9 +792,9 @@ void GameCubePane::SaveSettings()
const ExpansionInterface::EXIDeviceType current_exi_device = const ExpansionInterface::EXIDeviceType current_exi_device =
Config::Get(Config::GetInfoForEXIDevice(slot)); Config::Get(Config::GetInfoForEXIDevice(slot));
if (Core::IsRunning() && current_exi_device != dev) if (Core::IsRunning(system) && current_exi_device != dev)
{ {
Core::System::GetInstance().GetExpansionInterface().ChangeDevice(slot, dev); system.GetExpansionInterface().ChangeDevice(slot, dev);
} }
Config::SetBaseOrCurrent(Config::GetInfoForEXIDevice(slot), dev); Config::SetBaseOrCurrent(Config::GetInfoForEXIDevice(slot), dev);

View file

@ -25,6 +25,7 @@
#include "Core/HW/WiimoteEmu/MotionPlus.h" #include "Core/HW/WiimoteEmu/MotionPlus.h"
#include "Core/HW/WiimoteEmu/WiimoteEmu.h" #include "Core/HW/WiimoteEmu/WiimoteEmu.h"
#include "Core/HW/WiimoteReal/WiimoteReal.h" #include "Core/HW/WiimoteReal/WiimoteReal.h"
#include "Core/System.h"
#include "DolphinQt/QtUtils/AspectRatioWidget.h" #include "DolphinQt/QtUtils/AspectRatioWidget.h"
#include "DolphinQt/QtUtils/QueueOnObject.h" #include "DolphinQt/QtUtils/QueueOnObject.h"
@ -347,7 +348,7 @@ WiiTASInputWindow::WiiTASInputWindow(QWidget* parent, int num) : TASInputWindow(
setLayout(layout); setLayout(layout);
if (Core::IsRunning()) if (Core::IsRunning(Core::System::GetInstance()))
{ {
m_active_extension = GetWiimote()->GetActiveExtensionNumber(); m_active_extension = GetWiimote()->GetActiveExtensionNumber();
m_is_motion_plus_attached = GetWiimote()->IsMotionPlusAttached(); m_is_motion_plus_attached = GetWiimote()->IsMotionPlusAttached();

View file

@ -299,7 +299,7 @@ void VideoBackendBase::PopulateBackendInfoFromUI(const WindowSystemInfo& wsi)
{ {
// If the core is running, the backend info will have been populated already. // If the core is running, the backend info will have been populated already.
// If we did it here, the UI thread can race with the with the GPU thread. // If we did it here, the UI thread can race with the with the GPU thread.
if (!Core::IsRunning()) if (!Core::IsRunning(Core::System::GetInstance()))
PopulateBackendInfo(wsi); PopulateBackendInfo(wsi);
} }