From 7ab94d57a174425e5d6579f17a8437240b0d776c Mon Sep 17 00:00:00 2001 From: pineappleEA Date: Wed, 25 Aug 2021 04:38:35 +0200 Subject: [PATCH] early-access version 2011 --- README.md | 2 +- src/common/logging/backend.cpp | 9 +++++---- src/core/core.cpp | 10 +++++++++- src/core/core.h | 7 +------ src/yuzu/main.cpp | 2 +- 5 files changed, 17 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index a8592f508..c9f87905d 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 2010. +This is the source code for early-access 2011. ## Legal Notice diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp index 13edda9c9..949384fd3 100755 --- a/src/common/logging/backend.cpp +++ b/src/common/logging/backend.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include @@ -152,7 +153,7 @@ public: void EnableForStacktrace() override {} }; -bool initialization_in_progress_suppress_logging = false; +bool initialization_in_progress_suppress_logging = true; /** * Static state as a singleton. @@ -161,17 +162,17 @@ 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; } using namespace Common::FS; - initialization_in_progress_suppress_logging = true; const auto& log_dir = GetYuzuPath(YuzuPath::LogDir); void(CreateDir(log_dir)); Filter filter; diff --git a/src/core/core.cpp b/src/core/core.cpp index b0dc594d4..5893a86bf 100755 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include @@ -423,9 +424,16 @@ struct System::Impl { System::System() : impl{std::make_unique(*this)} {} 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) { - 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 65b447a1c..f9116ebb6 100755 --- a/src/core/core.h +++ b/src/core/core.h @@ -120,12 +120,7 @@ public: * Gets the instance of the System singleton class. * @returns Reference to the instance of the System singleton class. */ - [[deprecated("Use of the global system instance is deprecated")]] static System& GetInstance() { - if (!s_instance) { - abort(); - } - return *s_instance; - } + [[deprecated("Use of the global system instance is deprecated")]] static System& GetInstance(); static void InitializeGlobalInstance(); diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 7853c2cc7..b21ec37ef 100755 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -194,6 +194,7 @@ GMainWindow::GMainWindow() : input_subsystem{std::make_shared()}, config{std::make_unique()}, vfs{std::make_shared()}, provider{std::make_unique()} { + Common::Log::Initialize(); LoadTranslation(); setAcceptDrops(true); @@ -3446,7 +3447,6 @@ void GMainWindow::SetDiscordEnabled([[maybe_unused]] bool state) { #endif int main(int argc, char* argv[]) { - Common::Log::Initialize(); Common::DetachedTasks detached_tasks; MicroProfileOnThreadCreate("Frontend"); SCOPE_EXIT({ MicroProfileShutdown(); });