Refactor SystemBootParameters ownership

This commit is contained in:
Silent
2021-06-08 18:38:12 +02:00
parent 4e282cd172
commit e21f2644d0
9 changed files with 32 additions and 41 deletions

View File

@ -168,13 +168,13 @@ void CommonHostInterface::InitializeUserDirectory()
ReportError("Failed to create one or more user directories. This may cause issues at runtime.");
}
bool CommonHostInterface::BootSystem(const SystemBootParameters& parameters)
bool CommonHostInterface::BootSystem(std::shared_ptr<SystemBootParameters> parameters)
{
// If the fullscreen UI is enabled, make sure it's finished loading the game list so we don't race it.
if (m_display && m_fullscreen_ui_enabled)
FullscreenUI::EnsureGameListLoaded();
ApplyRendererFromGameSettings(parameters.filename);
ApplyRendererFromGameSettings(parameters->filename);
if (!HostInterface::BootSystem(parameters))
{
@ -186,8 +186,8 @@ bool CommonHostInterface::BootSystem(const SystemBootParameters& parameters)
}
// enter fullscreen if requested in the parameters
if (!g_settings.start_paused && ((parameters.override_fullscreen.has_value() && *parameters.override_fullscreen) ||
(!parameters.override_fullscreen.has_value() && g_settings.start_fullscreen)))
if (!g_settings.start_paused && ((parameters->override_fullscreen.has_value() && *parameters->override_fullscreen) ||
(!parameters->override_fullscreen.has_value() && g_settings.start_fullscreen)))
{
SetFullscreen(true);
}
@ -739,9 +739,7 @@ bool CommonHostInterface::CanResumeSystemFromFile(const char* filename)
bool CommonHostInterface::ResumeSystemFromState(const char* filename, bool boot_on_failure)
{
SystemBootParameters boot_params;
boot_params.filename = filename;
if (!BootSystem(boot_params))
if (!BootSystem(std::make_shared<SystemBootParameters>(filename)))
return false;
const bool global = System::GetRunningCode().empty();

View File

@ -129,7 +129,7 @@ public:
virtual void Shutdown() override;
virtual bool BootSystem(const SystemBootParameters& parameters) override;
virtual bool BootSystem(std::shared_ptr<SystemBootParameters> parameters) override;
virtual void ResetSystem() override;
virtual void DestroySystem() override;

View File

@ -551,9 +551,7 @@ static void DoStartPath(const std::string& path, bool allow_resume)
return;
}
SystemBootParameters params;
params.filename = path;
s_host_interface->BootSystem(params);
s_host_interface->BootSystem(std::make_shared<SystemBootParameters>(path));
}
static void DoStartFile()
@ -571,10 +569,7 @@ static void DoStartFile()
static void DoStartBIOS()
{
s_host_interface->RunLater([]() {
SystemBootParameters boot_params;
s_host_interface->BootSystem(boot_params);
});
s_host_interface->RunLater([]() { s_host_interface->BootSystem(std::make_shared<SystemBootParameters>()); });
ClearImGuiFocus();
}