diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp index 71f293785..ee1102a21 100644 --- a/src/citra_qt/main.cpp +++ b/src/citra_qt/main.cpp @@ -171,6 +171,7 @@ static QString PrettyProductName() { GMainWindow::GMainWindow(Core::System& system_) : ui{std::make_unique()}, system{system_}, movie{Core::Movie::GetInstance()}, config{std::make_unique()}, emu_thread{nullptr} { + Common::Log::Initialize(); Debugger::ToggleConsole(); Settings::LogSettings(); @@ -2853,7 +2854,6 @@ static Qt::HighDpiScaleFactorRoundingPolicy GetHighDpiRoundingPolicy() { } int main(int argc, char* argv[]) { - Common::Log::Initialize(); Common::DetachedTasks detached_tasks; MicroProfileOnThreadCreate("Frontend"); SCOPE_EXIT({ MicroProfileShutdown(); }); diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp index 58cffa33b..c835a0d85 100644 --- a/src/common/logging/backend.cpp +++ b/src/common/logging/backend.cpp @@ -3,6 +3,7 @@ // Refer to the license.txt file included. #include +#include #include #include #include "common/common_paths.h" @@ -177,7 +178,7 @@ public: }; #endif -bool initialization_in_progress_suppress_logging = false; +bool initialization_in_progress_suppress_logging = true; #ifdef CITRA_LINUX_GCC_BACKTRACE [[noreturn]] void SleepForever() { @@ -194,14 +195,15 @@ class Impl { public: static Impl& Instance() { if (!instance) { - abort(); + throw std::runtime_error("Using Logging instance before its initialization"); } return *instance; } static void Initialize() { if (instance) { - abort(); + LOG_WARNING(Log, "Reinitializing logging backend"); + return; } initialization_in_progress_suppress_logging = true; const auto& log_dir = FileUtil::GetUserPath(FileUtil::UserPath::LogDir); diff --git a/src/core/core.cpp b/src/core/core.cpp index e9aff1a12..4d4d567e9 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -2,6 +2,7 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include #include #include #include @@ -68,9 +69,16 @@ Core::Timing& Global() { System::~System() = default; +System& System::GetInstance() { + if (!s_instance) { + throw std::runtime_error("Using System instance before its initialization"); + } + return *s_instance; +} + void System::InitializeGlobalInstance() { if (s_instance) { - std::abort(); + throw std::runtime_error("Reinitializing Global System instance."); } s_instance = std::unique_ptr(new System); } diff --git a/src/core/core.h b/src/core/core.h index b85febf26..9bc49c9c3 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -73,12 +73,7 @@ public: * Gets the instance of the System singleton class. * @returns Reference to the instance of the System singleton class. */ - [[nodiscard]] static System& GetInstance() { - if (!s_instance) { - std::abort(); - } - return *s_instance; - } + [[nodiscard]] static System& GetInstance(); static void InitializeGlobalInstance();