From a2dbf97205717581fdb8d98be47affed62b9d31c Mon Sep 17 00:00:00 2001 From: spycrab Date: Sun, 29 Apr 2018 22:20:03 +0200 Subject: [PATCH] Qt/Win32: Fix console output --- Source/Core/DolphinQt2/Main.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Source/Core/DolphinQt2/Main.cpp b/Source/Core/DolphinQt2/Main.cpp index 878efef2f8..1c46d4403d 100644 --- a/Source/Core/DolphinQt2/Main.cpp +++ b/Source/Core/DolphinQt2/Main.cpp @@ -2,6 +2,11 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. +#ifdef _WIN32 +#include +#include +#endif + #include #include #include @@ -67,6 +72,16 @@ static bool QtMsgAlertHandler(const char* caption, const char* text, bool yes_no // /SubSystem:Windows int main(int argc, char* argv[]) { +#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 + #if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); #endif @@ -82,6 +97,10 @@ int main(int argc, char* argv[]) const optparse::Values& options = CommandLineParse::ParseArguments(parser.get(), argc, argv); const std::vector args = parser->args(); +#ifdef _WIN32 + FreeConsole(); +#endif + UICommon::SetUserDirectory(static_cast(options.get("user"))); UICommon::CreateDirectories(); UICommon::Init();