forked from ShuriZma/suyu
1
0
Fork 0

Merge pull request #5028 from lioncash/final-system

core: Eliminate remaining usages of the global system instance
This commit is contained in:
Rodrigo Locatti 2020-11-27 19:29:59 -03:00 committed by GitHub
commit 1dbe39f7a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 59 additions and 1594 deletions

View File

@ -135,8 +135,6 @@ add_library(core STATIC
frontend/framebuffer_layout.cpp frontend/framebuffer_layout.cpp
frontend/framebuffer_layout.h frontend/framebuffer_layout.h
frontend/input.h frontend/input.h
gdbstub/gdbstub.cpp
gdbstub/gdbstub.h
hardware_interrupt_manager.cpp hardware_interrupt_manager.cpp
hardware_interrupt_manager.h hardware_interrupt_manager.h
hle/ipc.h hle/ipc.h

View File

@ -14,7 +14,6 @@
#include "core/arm/dynarmic/arm_exclusive_monitor.h" #include "core/arm/dynarmic/arm_exclusive_monitor.h"
#include "core/core.h" #include "core/core.h"
#include "core/core_timing.h" #include "core/core_timing.h"
#include "core/gdbstub/gdbstub.h"
#include "core/hardware_properties.h" #include "core/hardware_properties.h"
#include "core/hle/kernel/process.h" #include "core/hle/kernel/process.h"
#include "core/hle/kernel/scheduler.h" #include "core/hle/kernel/scheduler.h"
@ -96,16 +95,6 @@ public:
case Dynarmic::A64::Exception::Yield: case Dynarmic::A64::Exception::Yield:
return; return;
case Dynarmic::A64::Exception::Breakpoint: case Dynarmic::A64::Exception::Breakpoint:
if (GDBStub::IsServerEnabled()) {
parent.jit->HaltExecution();
parent.SetPC(pc);
Kernel::Thread* const thread = parent.system.CurrentScheduler().GetCurrentThread();
parent.SaveContext(thread->GetContext64());
GDBStub::Break();
GDBStub::SendTrap(thread, 5);
return;
}
[[fallthrough]];
default: default:
ASSERT_MSG(false, "ExceptionRaised(exception = {}, pc = {:08X}, code = {:08X})", ASSERT_MSG(false, "ExceptionRaised(exception = {}, pc = {:08X}, code = {:08X})",
static_cast<std::size_t>(exception), pc, MemoryReadCode(pc)); static_cast<std::size_t>(exception), pc, MemoryReadCode(pc));

View File

@ -25,7 +25,6 @@
#include "core/file_sys/sdmc_factory.h" #include "core/file_sys/sdmc_factory.h"
#include "core/file_sys/vfs_concat.h" #include "core/file_sys/vfs_concat.h"
#include "core/file_sys/vfs_real.h" #include "core/file_sys/vfs_real.h"
#include "core/gdbstub/gdbstub.h"
#include "core/hardware_interrupt_manager.h" #include "core/hardware_interrupt_manager.h"
#include "core/hle/kernel/client_port.h" #include "core/hle/kernel/client_port.h"
#include "core/hle/kernel/kernel.h" #include "core/hle/kernel/kernel.h"
@ -186,11 +185,8 @@ struct System::Impl {
} }
service_manager = std::make_shared<Service::SM::ServiceManager>(kernel); service_manager = std::make_shared<Service::SM::ServiceManager>(kernel);
services = std::make_unique<Service::Services>(service_manager, system); services = std::make_unique<Service::Services>(service_manager, system);
GDBStub::DeferStart(); interrupt_manager = std::make_unique<Hardware::InterruptManager>(system);
interrupt_manager = std::make_unique<Core::Hardware::InterruptManager>(system);
// Initialize time manager, which must happen after kernel is created // Initialize time manager, which must happen after kernel is created
time_manager.Initialize(); time_manager.Initialize();
@ -297,7 +293,6 @@ struct System::Impl {
} }
// Shutdown emulation session // Shutdown emulation session
GDBStub::Shutdown();
services.reset(); services.reset();
service_manager.reset(); service_manager.reset();
cheat_engine.reset(); cheat_engine.reset();

View File

@ -10,7 +10,6 @@
#include "core/core.h" #include "core/core.h"
#include "core/core_timing.h" #include "core/core_timing.h"
#include "core/cpu_manager.h" #include "core/cpu_manager.h"
#include "core/gdbstub/gdbstub.h"
#include "core/hle/kernel/kernel.h" #include "core/hle/kernel/kernel.h"
#include "core/hle/kernel/physical_core.h" #include "core/hle/kernel/physical_core.h"
#include "core/hle/kernel/scheduler.h" #include "core/hle/kernel/scheduler.h"

File diff suppressed because it is too large Load Diff

View File

@ -1,114 +0,0 @@
// Copyright 2013 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
// Originally written by Sven Peter <sven@fail0verflow.com> for anergistic.
#pragma once
#include <string>
#include "common/common_types.h"
#include "core/hle/kernel/thread.h"
namespace GDBStub {
/// Breakpoint Method
enum class BreakpointType {
None, ///< None
Execute, ///< Execution Breakpoint
Read, ///< Read Breakpoint
Write, ///< Write Breakpoint
Access ///< Access (R/W) Breakpoint
};
struct BreakpointAddress {
VAddr address;
BreakpointType type;
};
/**
* Set the port the gdbstub should use to listen for connections.
*
* @param port Port to listen for connection
*/
void SetServerPort(u16 port);
/**
* Starts or stops the server if possible.
*
* @param status Set the server to enabled or disabled.
*/
void ToggleServer(bool status);
/// Start the gdbstub server.
void Init();
/**
* Defer initialization of the gdbstub to the first packet processing functions.
* This avoids a case where the gdbstub thread is frozen after initialization
* and fails to respond in time to packets.
*/
void DeferStart();
/// Stop gdbstub server.
void Shutdown();
/// Checks if the gdbstub server is enabled.
bool IsServerEnabled();
/// Returns true if there is an active socket connection.
bool IsConnected();
/// Register module.
void RegisterModule(std::string name, VAddr beg, VAddr end, bool add_elf_ext = true);
/**
* Signal to the gdbstub server that it should halt CPU execution.
*
* @param is_memory_break If true, the break resulted from a memory breakpoint.
*/
void Break(bool is_memory_break = false);
/// Determine if there was a memory breakpoint.
bool IsMemoryBreak();
/// Read and handle packet from gdb client.
void HandlePacket();
/**
* Get the nearest breakpoint of the specified type at the given address.
*
* @param addr Address to search from.
* @param type Type of breakpoint.
*/
BreakpointAddress GetNextBreakpointFromAddress(VAddr addr, GDBStub::BreakpointType type);
/**
* Check if a breakpoint of the specified type exists at the given address.
*
* @param addr Address of breakpoint.
* @param type Type of breakpoint.
*/
bool CheckBreakpoint(VAddr addr, GDBStub::BreakpointType type);
/// If set to true, the CPU will halt at the beginning of the next CPU loop.
bool GetCpuHaltFlag();
/// If set to true and the CPU is halted, the CPU will step one instruction.
bool GetCpuStepFlag();
/**
* When set to true, the CPU will step one instruction when the CPU is halted next.
*
* @param is_step
*/
void SetCpuStepFlag(bool is_step);
/**
* Send trap signal from thread back to the gdbstub server.
*
* @param thread Sending thread.
* @param trap Trap no.
*/
void SendTrap(Kernel::Thread* thread, int trap);
} // namespace GDBStub

View File

@ -12,7 +12,6 @@
#include "core/file_sys/control_metadata.h" #include "core/file_sys/control_metadata.h"
#include "core/file_sys/patch_manager.h" #include "core/file_sys/patch_manager.h"
#include "core/file_sys/romfs_factory.h" #include "core/file_sys/romfs_factory.h"
#include "core/gdbstub/gdbstub.h"
#include "core/hle/kernel/kernel.h" #include "core/hle/kernel/kernel.h"
#include "core/hle/kernel/memory/page_table.h" #include "core/hle/kernel/memory/page_table.h"
#include "core/hle/kernel/process.h" #include "core/hle/kernel/process.h"
@ -180,8 +179,6 @@ AppLoader_DeconstructedRomDirectory::LoadResult AppLoader_DeconstructedRomDirect
next_load_addr = *tentative_next_load_addr; next_load_addr = *tentative_next_load_addr;
modules.insert_or_assign(load_addr, module); modules.insert_or_assign(load_addr, module);
LOG_DEBUG(Loader, "loaded module {} @ 0x{:X}", module, load_addr); LOG_DEBUG(Loader, "loaded module {} @ 0x{:X}", module, load_addr);
// Register module with GDBStub
GDBStub::RegisterModule(module, load_addr, next_load_addr - 1, false);
} }
// Find the RomFS by searching for a ".romfs" file in this directory // Find the RomFS by searching for a ".romfs" file in this directory

View File

@ -5,7 +5,6 @@
#include <cstring> #include <cstring>
#include "core/file_sys/kernel_executable.h" #include "core/file_sys/kernel_executable.h"
#include "core/file_sys/program_metadata.h" #include "core/file_sys/program_metadata.h"
#include "core/gdbstub/gdbstub.h"
#include "core/hle/kernel/code_set.h" #include "core/hle/kernel/code_set.h"
#include "core/hle/kernel/memory/page_table.h" #include "core/hle/kernel/memory/page_table.h"
#include "core/hle/kernel/process.h" #include "core/hle/kernel/process.h"
@ -91,8 +90,6 @@ AppLoader::LoadResult AppLoader_KIP::Load(Kernel::Process& process,
program_image.resize(PageAlignSize(kip->GetBSSOffset()) + kip->GetBSSSize()); program_image.resize(PageAlignSize(kip->GetBSSOffset()) + kip->GetBSSSize());
codeset.DataSegment().size += kip->GetBSSSize(); codeset.DataSegment().size += kip->GetBSSSize();
GDBStub::RegisterModule(kip->GetName(), base_address, base_address + program_image.size());
codeset.memory = std::move(program_image); codeset.memory = std::move(program_image);
process.LoadModule(std::move(codeset), base_address); process.LoadModule(std::move(codeset), base_address);

View File

@ -14,10 +14,10 @@
#include "core/file_sys/control_metadata.h" #include "core/file_sys/control_metadata.h"
#include "core/file_sys/romfs_factory.h" #include "core/file_sys/romfs_factory.h"
#include "core/file_sys/vfs_offset.h" #include "core/file_sys/vfs_offset.h"
#include "core/gdbstub/gdbstub.h"
#include "core/hle/kernel/code_set.h" #include "core/hle/kernel/code_set.h"
#include "core/hle/kernel/memory/page_table.h" #include "core/hle/kernel/memory/page_table.h"
#include "core/hle/kernel/process.h" #include "core/hle/kernel/process.h"
#include "core/hle/kernel/thread.h"
#include "core/hle/service/filesystem/filesystem.h" #include "core/hle/service/filesystem/filesystem.h"
#include "core/loader/nro.h" #include "core/loader/nro.h"
#include "core/loader/nso.h" #include "core/loader/nso.h"
@ -197,10 +197,6 @@ static bool LoadNroImpl(Kernel::Process& process, const std::vector<u8>& data,
codeset.memory = std::move(program_image); codeset.memory = std::move(program_image);
process.LoadModule(std::move(codeset), process.PageTable().GetCodeRegionStart()); process.LoadModule(std::move(codeset), process.PageTable().GetCodeRegionStart());
// Register module with GDBStub
GDBStub::RegisterModule(name, process.PageTable().GetCodeRegionStart(),
process.PageTable().GetCodeRegionEnd());
return true; return true;
} }

View File

@ -14,10 +14,10 @@
#include "common/swap.h" #include "common/swap.h"
#include "core/core.h" #include "core/core.h"
#include "core/file_sys/patch_manager.h" #include "core/file_sys/patch_manager.h"
#include "core/gdbstub/gdbstub.h"
#include "core/hle/kernel/code_set.h" #include "core/hle/kernel/code_set.h"
#include "core/hle/kernel/memory/page_table.h" #include "core/hle/kernel/memory/page_table.h"
#include "core/hle/kernel/process.h" #include "core/hle/kernel/process.h"
#include "core/hle/kernel/thread.h"
#include "core/loader/nso.h" #include "core/loader/nso.h"
#include "core/memory.h" #include "core/memory.h"
#include "core/settings.h" #include "core/settings.h"
@ -159,9 +159,6 @@ std::optional<VAddr> AppLoader_NSO::LoadModule(Kernel::Process& process, Core::S
codeset.memory = std::move(program_image); codeset.memory = std::move(program_image);
process.LoadModule(std::move(codeset), load_base); process.LoadModule(std::move(codeset), load_base);
// Register module with GDBStub
GDBStub::RegisterModule(file.GetName(), load_base, load_base);
return load_base + image_size; return load_base + image_size;
} }

View File

@ -4,9 +4,10 @@
#include <string_view> #include <string_view>
#include "common/assert.h"
#include "common/file_util.h" #include "common/file_util.h"
#include "common/logging/log.h"
#include "core/core.h" #include "core/core.h"
#include "core/gdbstub/gdbstub.h"
#include "core/hle/service/hid/hid.h" #include "core/hle/service/hid/hid.h"
#include "core/settings.h" #include "core/settings.h"
#include "video_core/renderer_base.h" #include "video_core/renderer_base.h"
@ -31,13 +32,9 @@ std::string GetTimeZoneString() {
return timezones[time_zone_index]; return timezones[time_zone_index];
} }
void Apply() { void Apply(Core::System& system) {
GDBStub::SetServerPort(values.gdbstub_port); if (system.IsPoweredOn()) {
GDBStub::ToggleServer(values.use_gdbstub); system.Renderer().RefreshBaseSettings();
auto& system_instance = Core::System::GetInstance();
if (system_instance.IsPoweredOn()) {
system_instance.Renderer().RefreshBaseSettings();
} }
Service::HID::ReloadInputDevices(); Service::HID::ReloadInputDevices();
@ -106,9 +103,9 @@ float Volume() {
return values.volume.GetValue(); return values.volume.GetValue();
} }
void RestoreGlobalState() { void RestoreGlobalState(bool is_powered_on) {
// If a game is running, DO NOT restore the global settings state // If a game is running, DO NOT restore the global settings state
if (Core::System::GetInstance().IsPoweredOn()) { if (is_powered_on) {
return; return;
} }

View File

@ -14,6 +14,10 @@
#include "common/common_types.h" #include "common/common_types.h"
#include "input_common/settings.h" #include "input_common/settings.h"
namespace Core {
class System;
}
namespace Settings { namespace Settings {
enum class RendererBackend { enum class RendererBackend {
@ -247,11 +251,11 @@ float Volume();
std::string GetTimeZoneString(); std::string GetTimeZoneString();
void Apply(); void Apply(Core::System& system);
void LogSettings(); void LogSettings();
// Restore the global state of all applicable settings in the Values struct // Restore the global state of all applicable settings in the Values struct
void RestoreGlobalState(); void RestoreGlobalState(bool is_powered_on);
// Fixes settings that are known to cause issues with the emulator // Fixes settings that are known to cause issues with the emulator
void Sanitize(); void Sanitize();

View File

@ -7,6 +7,7 @@
#include <QSettings> #include <QSettings>
#include "common/common_paths.h" #include "common/common_paths.h"
#include "common/file_util.h" #include "common/file_util.h"
#include "core/core.h"
#include "core/hle/service/acc/profile_manager.h" #include "core/hle/service/acc/profile_manager.h"
#include "core/hle/service/hid/controllers/npad.h" #include "core/hle/service/hid/controllers/npad.h"
#include "input_common/main.h" #include "input_common/main.h"
@ -1598,7 +1599,7 @@ void Config::Reload() {
Settings::Sanitize(); Settings::Sanitize();
// To apply default value changes // To apply default value changes
SaveValues(); SaveValues();
Settings::Apply(); Settings::Apply(Core::System::GetInstance());
} }
void Config::Save() { void Config::Save() {

View File

@ -5,6 +5,7 @@
#include <QHash> #include <QHash>
#include <QListWidgetItem> #include <QListWidgetItem>
#include <QSignalBlocker> #include <QSignalBlocker>
#include "core/core.h"
#include "core/settings.h" #include "core/settings.h"
#include "ui_configure.h" #include "ui_configure.h"
#include "yuzu/configuration/config.h" #include "yuzu/configuration/config.h"
@ -54,7 +55,7 @@ void ConfigureDialog::ApplyConfiguration() {
ui->debugTab->ApplyConfiguration(); ui->debugTab->ApplyConfiguration();
ui->webTab->ApplyConfiguration(); ui->webTab->ApplyConfiguration();
ui->serviceTab->ApplyConfiguration(); ui->serviceTab->ApplyConfiguration();
Settings::Apply(); Settings::Apply(Core::System::GetInstance());
Settings::LogSettings(); Settings::LogSettings();
} }

View File

@ -57,7 +57,7 @@ void ConfigurePerGame::ApplyConfiguration() {
ui->graphicsAdvancedTab->ApplyConfiguration(); ui->graphicsAdvancedTab->ApplyConfiguration();
ui->audioTab->ApplyConfiguration(); ui->audioTab->ApplyConfiguration();
Settings::Apply(); Settings::Apply(Core::System::GetInstance());
Settings::LogSettings(); Settings::LogSettings();
game_config->Save(); game_config->Save();

View File

@ -180,7 +180,7 @@ void ConfigureProfileManager::ApplyConfiguration() {
return; return;
} }
Settings::Apply(); Settings::Apply(Core::System::GetInstance());
} }
void ConfigureProfileManager::SelectUser(const QModelIndex& index) { void ConfigureProfileManager::SelectUser(const QModelIndex& index) {

View File

@ -105,16 +105,18 @@ void ConfigureSystem::SetConfiguration() {
void ConfigureSystem::ReadSystemSettings() {} void ConfigureSystem::ReadSystemSettings() {}
void ConfigureSystem::ApplyConfiguration() { void ConfigureSystem::ApplyConfiguration() {
// Allow setting custom RTC even if system is powered on, to allow in-game time to be fast auto& system = Core::System::GetInstance();
// forwared
// Allow setting custom RTC even if system is powered on,
// to allow in-game time to be fast forwarded
if (Settings::values.custom_rtc.UsingGlobal()) { if (Settings::values.custom_rtc.UsingGlobal()) {
if (ui->custom_rtc_checkbox->isChecked()) { if (ui->custom_rtc_checkbox->isChecked()) {
Settings::values.custom_rtc.SetValue( Settings::values.custom_rtc.SetValue(
std::chrono::seconds(ui->custom_rtc_edit->dateTime().toSecsSinceEpoch())); std::chrono::seconds(ui->custom_rtc_edit->dateTime().toSecsSinceEpoch()));
if (Core::System::GetInstance().IsPoweredOn()) { if (system.IsPoweredOn()) {
const s64 posix_time{Settings::values.custom_rtc.GetValue()->count() + const s64 posix_time{Settings::values.custom_rtc.GetValue()->count() +
Service::Time::TimeManager::GetExternalTimeZoneOffset()}; Service::Time::TimeManager::GetExternalTimeZoneOffset()};
Core::System::GetInstance().GetTimeManager().UpdateLocalSystemClockTime(posix_time); system.GetTimeManager().UpdateLocalSystemClockTime(posix_time);
} }
} else { } else {
Settings::values.custom_rtc.SetValue(std::nullopt); Settings::values.custom_rtc.SetValue(std::nullopt);
@ -197,7 +199,7 @@ void ConfigureSystem::ApplyConfiguration() {
} }
} }
Settings::Apply(); Settings::Apply(system);
} }
void ConfigureSystem::RefreshConsoleID() { void ConfigureSystem::RefreshConsoleID() {

View File

@ -9,6 +9,7 @@
#include <QDirIterator> #include <QDirIterator>
#include "common/common_types.h" #include "common/common_types.h"
#include "common/file_util.h" #include "common/file_util.h"
#include "core/core.h"
#include "core/settings.h" #include "core/settings.h"
#include "ui_configure_ui.h" #include "ui_configure_ui.h"
#include "yuzu/configuration/configure_ui.h" #include "yuzu/configuration/configure_ui.h"
@ -84,7 +85,7 @@ void ConfigureUi::ApplyConfiguration() {
UISettings::values.enable_screenshot_save_as = ui->enable_screenshot_save_as->isChecked(); UISettings::values.enable_screenshot_save_as = ui->enable_screenshot_save_as->isChecked();
Common::FS::GetUserPath(Common::FS::UserPath::ScreenshotsDir, Common::FS::GetUserPath(Common::FS::UserPath::ScreenshotsDir,
ui->screenshot_path_edit->text().toStdString()); ui->screenshot_path_edit->text().toStdString());
Settings::Apply(); Settings::Apply(Core::System::GetInstance());
} }
void ConfigureUi::RequestGameListUpdate() { void ConfigureUi::RequestGameListUpdate() {

View File

@ -172,7 +172,7 @@ void GMainWindow::ShowTelemetryCallout() {
"<br/><br/>Would you like to share your usage data with us?"); "<br/><br/>Would you like to share your usage data with us?");
if (QMessageBox::question(this, tr("Telemetry"), telemetry_message) != QMessageBox::Yes) { if (QMessageBox::question(this, tr("Telemetry"), telemetry_message) != QMessageBox::Yes) {
Settings::values.enable_telemetry = false; Settings::values.enable_telemetry = false;
Settings::Apply(); Settings::Apply(Core::System::GetInstance());
} }
} }
@ -302,7 +302,7 @@ void GMainWindow::ControllerSelectorReconfigureControllers(
emit ControllerSelectorReconfigureFinished(); emit ControllerSelectorReconfigureFinished();
// Don't forget to apply settings. // Don't forget to apply settings.
Settings::Apply(); Settings::Apply(Core::System::GetInstance());
config->Save(); config->Save();
UpdateStatusButtons(); UpdateStatusButtons();
@ -571,11 +571,11 @@ void GMainWindow::InitializeWidgets() {
if (emulation_running) { if (emulation_running) {
return; return;
} }
bool is_async = !Settings::values.use_asynchronous_gpu_emulation.GetValue() || const bool is_async = !Settings::values.use_asynchronous_gpu_emulation.GetValue() ||
Settings::values.use_multi_core.GetValue(); Settings::values.use_multi_core.GetValue();
Settings::values.use_asynchronous_gpu_emulation.SetValue(is_async); Settings::values.use_asynchronous_gpu_emulation.SetValue(is_async);
async_status_button->setChecked(Settings::values.use_asynchronous_gpu_emulation.GetValue()); async_status_button->setChecked(Settings::values.use_asynchronous_gpu_emulation.GetValue());
Settings::Apply(); Settings::Apply(Core::System::GetInstance());
}); });
async_status_button->setText(tr("ASYNC")); async_status_button->setText(tr("ASYNC"));
async_status_button->setCheckable(true); async_status_button->setCheckable(true);
@ -590,12 +590,12 @@ void GMainWindow::InitializeWidgets() {
return; return;
} }
Settings::values.use_multi_core.SetValue(!Settings::values.use_multi_core.GetValue()); Settings::values.use_multi_core.SetValue(!Settings::values.use_multi_core.GetValue());
bool is_async = Settings::values.use_asynchronous_gpu_emulation.GetValue() || const bool is_async = Settings::values.use_asynchronous_gpu_emulation.GetValue() ||
Settings::values.use_multi_core.GetValue(); Settings::values.use_multi_core.GetValue();
Settings::values.use_asynchronous_gpu_emulation.SetValue(is_async); Settings::values.use_asynchronous_gpu_emulation.SetValue(is_async);
async_status_button->setChecked(Settings::values.use_asynchronous_gpu_emulation.GetValue()); async_status_button->setChecked(Settings::values.use_asynchronous_gpu_emulation.GetValue());
multicore_status_button->setChecked(Settings::values.use_multi_core.GetValue()); multicore_status_button->setChecked(Settings::values.use_multi_core.GetValue());
Settings::Apply(); Settings::Apply(Core::System::GetInstance());
}); });
multicore_status_button->setText(tr("MULTICORE")); multicore_status_button->setText(tr("MULTICORE"));
multicore_status_button->setCheckable(true); multicore_status_button->setCheckable(true);
@ -630,7 +630,7 @@ void GMainWindow::InitializeWidgets() {
Settings::values.renderer_backend.SetValue(Settings::RendererBackend::OpenGL); Settings::values.renderer_backend.SetValue(Settings::RendererBackend::OpenGL);
} }
Settings::Apply(); Settings::Apply(Core::System::GetInstance());
}); });
#endif // HAS_VULKAN #endif // HAS_VULKAN
statusBar()->insertPermanentWidget(0, renderer_status_button); statusBar()->insertPermanentWidget(0, renderer_status_button);
@ -2130,14 +2130,14 @@ void GMainWindow::OnPauseGame() {
} }
void GMainWindow::OnStopGame() { void GMainWindow::OnStopGame() {
Core::System& system{Core::System::GetInstance()}; auto& system{Core::System::GetInstance()};
if (system.GetExitLock() && !ConfirmForceLockedExit()) { if (system.GetExitLock() && !ConfirmForceLockedExit()) {
return; return;
} }
ShutdownGame(); ShutdownGame();
Settings::RestoreGlobalState(); Settings::RestoreGlobalState(system.IsPoweredOn());
UpdateStatusButtons(); UpdateStatusButtons();
} }
@ -2312,10 +2312,11 @@ void GMainWindow::OnConfigurePerGame() {
void GMainWindow::OpenPerGameConfiguration(u64 title_id, const std::string& file_name) { void GMainWindow::OpenPerGameConfiguration(u64 title_id, const std::string& file_name) {
const auto v_file = Core::GetGameFileFromPath(vfs, file_name); const auto v_file = Core::GetGameFileFromPath(vfs, file_name);
const auto& system = Core::System::GetInstance();
ConfigurePerGame dialog(this, title_id); ConfigurePerGame dialog(this, title_id);
dialog.LoadFromFile(v_file); dialog.LoadFromFile(v_file);
auto result = dialog.exec(); const auto result = dialog.exec();
if (result == QDialog::Accepted) { if (result == QDialog::Accepted) {
dialog.ApplyConfiguration(); dialog.ApplyConfiguration();
@ -2325,13 +2326,14 @@ void GMainWindow::OpenPerGameConfiguration(u64 title_id, const std::string& file
} }
// Do not cause the global config to write local settings into the config file // Do not cause the global config to write local settings into the config file
Settings::RestoreGlobalState(); const bool is_powered_on = system.IsPoweredOn();
Settings::RestoreGlobalState(is_powered_on);
if (!Core::System::GetInstance().IsPoweredOn()) { if (!is_powered_on) {
config->Save(); config->Save();
} }
} else { } else {
Settings::RestoreGlobalState(); Settings::RestoreGlobalState(system.IsPoweredOn());
} }
} }
@ -2602,7 +2604,7 @@ void GMainWindow::OnCoreError(Core::System::ResultStatus result, std::string det
if (emu_thread) { if (emu_thread) {
ShutdownGame(); ShutdownGame();
Settings::RestoreGlobalState(); Settings::RestoreGlobalState(Core::System::GetInstance().IsPoweredOn());
UpdateStatusButtons(); UpdateStatusButtons();
} }
} else { } else {
@ -2774,7 +2776,7 @@ void GMainWindow::closeEvent(QCloseEvent* event) {
if (emu_thread != nullptr) { if (emu_thread != nullptr) {
ShutdownGame(); ShutdownGame();
Settings::RestoreGlobalState(); Settings::RestoreGlobalState(Core::System::GetInstance().IsPoweredOn());
UpdateStatusButtons(); UpdateStatusButtons();
} }

View File

@ -25,7 +25,6 @@
#include "core/crypto/key_manager.h" #include "core/crypto/key_manager.h"
#include "core/file_sys/registered_cache.h" #include "core/file_sys/registered_cache.h"
#include "core/file_sys/vfs_real.h" #include "core/file_sys/vfs_real.h"
#include "core/gdbstub/gdbstub.h"
#include "core/hle/kernel/process.h" #include "core/hle/kernel/process.h"
#include "core/hle/service/filesystem/filesystem.h" #include "core/hle/service/filesystem/filesystem.h"
#include "core/loader/loader.h" #include "core/loader/loader.h"
@ -174,13 +173,13 @@ int main(int argc, char** argv) {
return -1; return -1;
} }
auto& system{Core::System::GetInstance()};
InputCommon::InputSubsystem input_subsystem;
// Apply the command line arguments // Apply the command line arguments
Settings::values.gdbstub_port = gdb_port; Settings::values.gdbstub_port = gdb_port;
Settings::values.use_gdbstub = use_gdbstub; Settings::values.use_gdbstub = use_gdbstub;
Settings::Apply(); Settings::Apply(system);
Core::System& system{Core::System::GetInstance()};
InputCommon::InputSubsystem input_subsystem;
std::unique_ptr<EmuWindow_SDL2> emu_window; std::unique_ptr<EmuWindow_SDL2> emu_window;
switch (Settings::values.renderer_backend.GetValue()) { switch (Settings::values.renderer_backend.GetValue()) {

View File

@ -160,10 +160,12 @@ int main(int argc, char** argv) {
return -1; return -1;
} }
Settings::values.use_gdbstub = false; Core::System& system{Core::System::GetInstance()};
Settings::Apply();
std::unique_ptr<EmuWindow_SDL2_Hide> emu_window{std::make_unique<EmuWindow_SDL2_Hide>()}; Settings::values.use_gdbstub = false;
Settings::Apply(system);
const auto emu_window{std::make_unique<EmuWindow_SDL2_Hide>()};
bool finished = false; bool finished = false;
int return_value = 0; int return_value = 0;
@ -212,7 +214,6 @@ int main(int argc, char** argv) {
return_value = -1; return_value = -1;
}; };
Core::System& system{Core::System::GetInstance()};
system.SetContentProvider(std::make_unique<FileSys::ContentProviderUnion>()); system.SetContentProvider(std::make_unique<FileSys::ContentProviderUnion>());
system.SetFilesystem(std::make_shared<FileSys::RealVfsFilesystem>()); system.SetFilesystem(std::make_shared<FileSys::RealVfsFilesystem>());
system.GetFileSystemController().CreateFactories(*system.GetFilesystem()); system.GetFileSystemController().CreateFactories(*system.GetFilesystem());