diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2018-02-16 12:15:33 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2018-02-16 12:56:49 +0100 |
commit | 7ea413f202d5716de7155df46e708ce5825771d1 (patch) | |
tree | bb2690ed8dd676e42eaca832605592a7398ce2be /gui | |
parent | 007d70579c60308130c8f3a98d73330c477eda62 (diff) |
gui: attach parent console harder
Diffstat (limited to 'gui')
-rw-r--r-- | gui/init.cpp | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/gui/init.cpp b/gui/init.cpp index 1de98f60..5879c6c0 100644 --- a/gui/init.cpp +++ b/gui/init.cpp @@ -143,7 +143,26 @@ void add_win32_path() } } -void attach_parent_console(); +#include <windows.h> + +void attach_parent_console() +{ + std::fflush(stdin); + std::fflush(stderr); + + (void)qInstallMessageHandler(qdebug_to_console); + + if (AttachConsole(ATTACH_PARENT_PROCESS)) + { + _wfreopen(L"CON", L"w", stdout); + _wfreopen(L"CON", L"w", stderr); + _wfreopen(L"CON", L"r", stdin); + + freopen("CON", "w", stdout); + freopen("CON", "w", stderr); + freopen("CON", "w", stderr); + } +} #endif @@ -214,19 +233,3 @@ int otr_main(int argc, char** argv, std::function<QWidget*()> make_main_window) return ret; } -#if defined _WIN32 -#include <windows.h> - -void attach_parent_console() -{ - if (AttachConsole(ATTACH_PARENT_PROCESS)) - { - // XXX c++ iostreams aren't reopened - - _wfreopen(L"CON", L"w", stdout); - _wfreopen(L"CON", L"w", stderr); - _wfreopen(L"CON", L"r", stdin); - } - (void)qInstallMessageHandler(qdebug_to_console); -} -#endif |