summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/logging/backend.cpp9
-rw-r--r--src/core/core.cpp10
-rw-r--r--src/core/core.h7
-rw-r--r--src/yuzu/main.cpp2
4 files changed, 16 insertions, 12 deletions
diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp
index 13edda9c9..949384fd3 100644
--- a/src/common/logging/backend.cpp
+++ b/src/common/logging/backend.cpp
@@ -5,6 +5,7 @@
5#include <atomic> 5#include <atomic>
6#include <chrono> 6#include <chrono>
7#include <climits> 7#include <climits>
8#include <exception>
8#include <thread> 9#include <thread>
9#include <vector> 10#include <vector>
10 11
@@ -152,7 +153,7 @@ public:
152 void EnableForStacktrace() override {} 153 void EnableForStacktrace() override {}
153}; 154};
154 155
155bool initialization_in_progress_suppress_logging = false; 156bool initialization_in_progress_suppress_logging = true;
156 157
157/** 158/**
158 * Static state as a singleton. 159 * Static state as a singleton.
@@ -161,17 +162,17 @@ class Impl {
161public: 162public:
162 static Impl& Instance() { 163 static Impl& Instance() {
163 if (!instance) { 164 if (!instance) {
164 abort(); 165 throw std::runtime_error("Using Logging instance before its initialization");
165 } 166 }
166 return *instance; 167 return *instance;
167 } 168 }
168 169
169 static void Initialize() { 170 static void Initialize() {
170 if (instance) { 171 if (instance) {
171 abort(); 172 LOG_WARNING(Log, "Reinitializing logging backend");
173 return;
172 } 174 }
173 using namespace Common::FS; 175 using namespace Common::FS;
174 initialization_in_progress_suppress_logging = true;
175 const auto& log_dir = GetYuzuPath(YuzuPath::LogDir); 176 const auto& log_dir = GetYuzuPath(YuzuPath::LogDir);
176 void(CreateDir(log_dir)); 177 void(CreateDir(log_dir));
177 Filter filter; 178 Filter filter;
diff --git a/src/core/core.cpp b/src/core/core.cpp
index b0dc594d4..5893a86bf 100644
--- a/src/core/core.cpp
+++ b/src/core/core.cpp
@@ -4,6 +4,7 @@
4 4
5#include <array> 5#include <array>
6#include <atomic> 6#include <atomic>
7#include <exception>
7#include <memory> 8#include <memory>
8#include <utility> 9#include <utility>
9 10
@@ -423,9 +424,16 @@ struct System::Impl {
423System::System() : impl{std::make_unique<Impl>(*this)} {} 424System::System() : impl{std::make_unique<Impl>(*this)} {}
424System::~System() = default; 425System::~System() = default;
425 426
427System& System::GetInstance() {
428 if (!s_instance) {
429 throw std::runtime_error("Using System instance before its initialization");
430 }
431 return *s_instance;
432}
433
426void System::InitializeGlobalInstance() { 434void System::InitializeGlobalInstance() {
427 if (s_instance) { 435 if (s_instance) {
428 abort(); 436 throw std::runtime_error("Reinitializing Global System instance.");
429 } 437 }
430 s_instance = std::unique_ptr<System>(new System); 438 s_instance = std::unique_ptr<System>(new System);
431} 439}
diff --git a/src/core/core.h b/src/core/core.h
index 65b447a1c..f9116ebb6 100644
--- a/src/core/core.h
+++ b/src/core/core.h
@@ -120,12 +120,7 @@ public:
120 * Gets the instance of the System singleton class. 120 * Gets the instance of the System singleton class.
121 * @returns Reference to the instance of the System singleton class. 121 * @returns Reference to the instance of the System singleton class.
122 */ 122 */
123 [[deprecated("Use of the global system instance is deprecated")]] static System& GetInstance() { 123 [[deprecated("Use of the global system instance is deprecated")]] static System& GetInstance();
124 if (!s_instance) {
125 abort();
126 }
127 return *s_instance;
128 }
129 124
130 static void InitializeGlobalInstance(); 125 static void InitializeGlobalInstance();
131 126
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index 1bae1489f..e36774cc6 100644
--- a/src/yuzu/main.cpp
+++ b/src/yuzu/main.cpp
@@ -192,6 +192,7 @@ GMainWindow::GMainWindow()
192 : input_subsystem{std::make_shared<InputCommon::InputSubsystem>()}, 192 : input_subsystem{std::make_shared<InputCommon::InputSubsystem>()},
193 config{std::make_unique<Config>()}, vfs{std::make_shared<FileSys::RealVfsFilesystem>()}, 193 config{std::make_unique<Config>()}, vfs{std::make_shared<FileSys::RealVfsFilesystem>()},
194 provider{std::make_unique<FileSys::ManualContentProvider>()} { 194 provider{std::make_unique<FileSys::ManualContentProvider>()} {
195 Common::Log::Initialize();
195 LoadTranslation(); 196 LoadTranslation();
196 197
197 setAcceptDrops(true); 198 setAcceptDrops(true);
@@ -3381,7 +3382,6 @@ void GMainWindow::SetDiscordEnabled([[maybe_unused]] bool state) {
3381#endif 3382#endif
3382 3383
3383int main(int argc, char* argv[]) { 3384int main(int argc, char* argv[]) {
3384 Common::Log::Initialize();
3385 Common::DetachedTasks detached_tasks; 3385 Common::DetachedTasks detached_tasks;
3386 MicroProfileOnThreadCreate("Frontend"); 3386 MicroProfileOnThreadCreate("Frontend");
3387 SCOPE_EXIT({ MicroProfileShutdown(); }); 3387 SCOPE_EXIT({ MicroProfileShutdown(); });