BootManager: Avoid Global System Accessor

This commit is contained in:
mitaclaw 2024-03-01 23:39:04 -08:00
parent 5a81916ee9
commit 16c609dcd4
5 changed files with 12 additions and 6 deletions

View File

@ -570,7 +570,7 @@ static void Run(JNIEnv* env, std::unique_ptr<BootParameters>&& boot, bool riivol
s_need_nonblocking_alert_msg = true; s_need_nonblocking_alert_msg = true;
std::unique_lock<std::mutex> surface_guard(s_surface_lock); std::unique_lock<std::mutex> surface_guard(s_surface_lock);
if (BootManager::BootCore(std::move(boot), wsi)) if (BootManager::BootCore(Core::System::GetInstance(), std::move(boot), wsi))
{ {
static constexpr int WAIT_STEP = 25; static constexpr int WAIT_STEP = 25;
while (Core::GetState() == Core::State::Starting) while (Core::GetState() == Core::State::Starting)

View File

@ -55,12 +55,12 @@
namespace BootManager namespace BootManager
{ {
// Boot the ISO or file // Boot the ISO or file
bool BootCore(std::unique_ptr<BootParameters> boot, const WindowSystemInfo& wsi) bool BootCore(Core::System& system, std::unique_ptr<BootParameters> boot,
const WindowSystemInfo& wsi)
{ {
if (!boot) if (!boot)
return false; return false;
auto& system = Core::System::GetInstance();
SConfig& StartUp = SConfig::GetInstance(); SConfig& StartUp = SConfig::GetInstance();
if (!StartUp.SetPathsAndGameMetadata(system, *boot)) if (!StartUp.SetPathsAndGameMetadata(system, *boot))

View File

@ -5,12 +5,17 @@
#include <memory> #include <memory>
namespace Core
{
class System;
}
struct BootParameters; struct BootParameters;
struct WindowSystemInfo; struct WindowSystemInfo;
namespace BootManager namespace BootManager
{ {
bool BootCore(std::unique_ptr<BootParameters> parameters, const WindowSystemInfo& wsi); bool BootCore(Core::System& system, std::unique_ptr<BootParameters> parameters,
const WindowSystemInfo& wsi);
// Synchronise Dolphin's configuration with the SYSCONF (which may have changed during emulation), // Synchronise Dolphin's configuration with the SYSCONF (which may have changed during emulation),
// and restore settings that were overriden by per-game INIs or for some other reason. // and restore settings that were overriden by per-game INIs or for some other reason.

View File

@ -24,6 +24,7 @@
#include "Core/Core.h" #include "Core/Core.h"
#include "Core/DolphinAnalytics.h" #include "Core/DolphinAnalytics.h"
#include "Core/Host.h" #include "Core/Host.h"
#include "Core/System.h"
#include "UICommon/CommandLineParse.h" #include "UICommon/CommandLineParse.h"
#ifdef USE_DISCORD_PRESENCE #ifdef USE_DISCORD_PRESENCE
@ -304,7 +305,7 @@ int main(int argc, char* argv[])
DolphinAnalytics::Instance().ReportDolphinStart("nogui"); DolphinAnalytics::Instance().ReportDolphinStart("nogui");
if (!BootManager::BootCore(std::move(boot), wsi)) if (!BootManager::BootCore(Core::System::GetInstance(), std::move(boot), wsi))
{ {
fprintf(stderr, "Could not boot the specified file\n"); fprintf(stderr, "Could not boot the specified file\n");
return 1; return 1;

View File

@ -1126,7 +1126,7 @@ void MainWindow::StartGame(std::unique_ptr<BootParameters>&& parameters)
ShowRenderWidget(); ShowRenderWidget();
// Boot up, show an error if it fails to load the game. // Boot up, show an error if it fails to load the game.
if (!BootManager::BootCore(std::move(parameters), if (!BootManager::BootCore(Core::System::GetInstance(), std::move(parameters),
::GetWindowSystemInfo(m_render_widget->windowHandle()))) ::GetWindowSystemInfo(m_render_widget->windowHandle())))
{ {
ModalMessageBox::critical(this, tr("Error"), tr("Failed to init core"), QMessageBox::Ok); ModalMessageBox::critical(this, tr("Error"), tr("Failed to init core"), QMessageBox::Ok);