From c6bd22aa12c6b0ea1566a8337cee234aef4a59c1 Mon Sep 17 00:00:00 2001 From: Janek Bevendorff Date: Sat, 21 Nov 2020 01:03:23 +0100 Subject: [PATCH] Attach console in debug mode on Windows --- src/gui/osutils/winutils/WinUtils.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/gui/osutils/winutils/WinUtils.cpp b/src/gui/osutils/winutils/WinUtils.cpp index 61e913c93..67b272922 100644 --- a/src/gui/osutils/winutils/WinUtils.cpp +++ b/src/gui/osutils/winutils/WinUtils.cpp @@ -30,6 +30,14 @@ WinUtils* WinUtils::instance() { if (!m_instance) { m_instance = new WinUtils(qApp); + +#ifdef QT_DEBUG + // Attach console to enable debug output + if (AttachConsole(ATTACH_PARENT_PROCESS)) { + freopen("CONOUT$", "w", stdout); + freopen("CONOUT$", "w", stderr); + } +#endif } return m_instance;