From 77b389bf997e3816f50b08d89ade9e347c002a19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Wed, 22 Mar 2017 12:42:49 +0100 Subject: [PATCH 1/2] WX: Move init mutex lock to after command line Calling std::exit while having a mutex locked leads to an assertion. Moving the lock is fine, since all it protects against is really just UICommon. --- Source/Core/DolphinWX/Main.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/Core/DolphinWX/Main.cpp b/Source/Core/DolphinWX/Main.cpp index 934697ddab..37bd1b63bd 100644 --- a/Source/Core/DolphinWX/Main.cpp +++ b/Source/Core/DolphinWX/Main.cpp @@ -91,7 +91,6 @@ bool DolphinApp::OnCmdLineParsed(wxCmdLineParser& parser) bool DolphinApp::OnInit() { - std::lock_guard lk(s_init_mutex); if (!wxApp::OnInit()) return false; @@ -110,6 +109,8 @@ bool DolphinApp::OnInit() ParseCommandLine(); + std::lock_guard lk(s_init_mutex); + UICommon::SetUserDirectory(m_user_path.ToStdString()); UICommon::CreateDirectories(); InitLanguageSupport(); // The language setting is loaded from the user directory From c1cd7d9c0ea54cc2d11b27ee9f207f04bbcd75cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Wed, 22 Mar 2017 13:32:24 +0100 Subject: [PATCH 2/2] WX: Redirect stdout to console output Thank Windows for its default console handling. This fixes std::cout not working on Windows. --- Source/Core/DolphinWX/Main.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Source/Core/DolphinWX/Main.cpp b/Source/Core/DolphinWX/Main.cpp index 37bd1b63bd..91133a4e57 100644 --- a/Source/Core/DolphinWX/Main.cpp +++ b/Source/Core/DolphinWX/Main.cpp @@ -107,6 +107,16 @@ bool DolphinApp::OnInit() wxHandleFatalExceptions(true); #endif +#ifdef _WIN32 + const bool console_attached = AttachConsole(ATTACH_PARENT_PROCESS) != FALSE; + HANDLE stdout_handle = ::GetStdHandle(STD_OUTPUT_HANDLE); + if (console_attached && stdout_handle) + { + freopen("CONOUT$", "w", stdout); + freopen("CONOUT$", "w", stderr); + } +#endif + ParseCommandLine(); std::lock_guard lk(s_init_mutex);