diff options
Diffstat (limited to 'launcher/Application.cpp')
-rw-r--r-- | launcher/Application.cpp | 35 |
1 files changed, 7 insertions, 28 deletions
diff --git a/launcher/Application.cpp b/launcher/Application.cpp index 7bfcce5f..e89b7659 100644 --- a/launcher/Application.cpp +++ b/launcher/Application.cpp @@ -135,13 +135,8 @@ #include "updater/MacSparkleUpdater.h" #endif - #if defined Q_OS_WIN32 -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN -#endif -#include <windows.h> -#include <stdio.h> +#include "WindowsConsole.h" #endif #define STRINGIFY(x) #x @@ -168,31 +163,15 @@ void appDebugOutput(QtMsgType type, const QMessageLogContext &context, const QSt fflush(stderr); } -} +} // namespace -Application::Application(int &argc, char **argv) : QApplication(argc, argv) + + +Application::Application(int& argc, char** argv) : QApplication(argc, argv) { #if defined Q_OS_WIN32 - // attach the parent console - if(AttachConsole(ATTACH_PARENT_PROCESS)) - { - // if attach succeeds, reopen and sync all the i/o - if(freopen("CON", "w", stdout)) - { - std::cout.sync_with_stdio(); - } - if(freopen("CON", "w", stderr)) - { - std::cerr.sync_with_stdio(); - } - if(freopen("CON", "r", stdin)) - { - std::cin.sync_with_stdio(); - } - auto out = GetStdHandle (STD_OUTPUT_HANDLE); - DWORD written; - const char * endline = "\n"; - WriteConsole(out, endline, strlen(endline), &written, NULL); + // attach the parent console if stdout not already captured + if (AttachWindowsConsole()) { consoleAttached = true; } #endif |