diff --git a/Jamulus.pro b/Jamulus.pro index a6f00b48ea..aed281b8a9 100644 --- a/Jamulus.pro +++ b/Jamulus.pro @@ -81,6 +81,7 @@ DEFINES += APP_VERSION=\\\"$$VERSION\\\" \ DEFINES += QT_NO_DEPRECATED_WARNINGS win32 { + CONFIG += console # fixes issue with app going into background DEFINES -= UNICODE # fixes issue with ASIO SDK (asiolist.cpp is not unicode compatible) DEFINES += NOMINMAX # solves a compiler error in qdatetime.h (Qt5) RC_FILE = src/res/win-mainicon.rc diff --git a/src/main.cpp b/src/main.cpp index 362dc1fdf8..b4fd6856e7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -131,14 +131,6 @@ int main ( int argc, char** argv ) Q_UNUSED ( bCustomPortNumberGiven ) #endif -#if !defined( HEADLESS ) && defined( _WIN32 ) - if ( AttachConsole ( ATTACH_PARENT_PROCESS ) ) - { - freopen ( "CONOUT$", "w", stdout ); - freopen ( "CONOUT$", "w", stderr ); - } -#endif - // When adding new options, follow the same order as --help output // QT docu: argv()[0] is the program name, argv()[1] is the first @@ -808,6 +800,14 @@ int main ( int argc, char** argv ) #endif } +#if defined( _WIN32 ) + // If we are using the GUI, minimize any attached console + if ( bUseGUI && ::GetConsoleWindow() ) + { + ::ShowWindow ( ::GetConsoleWindow(), SW_SHOWMINNOACTIVE ); + } +#endif + // Application/GUI setup --------------------------------------------------- // Application object #ifdef HEADLESS @@ -1069,6 +1069,13 @@ int main ( int argc, char** argv ) activity.EndActivity(); #endif +#if defined( _WIN32 ) + // If we are using the GUI, restore any attached console + if ( bUseGUI && ::GetConsoleWindow() ) + { + ::ShowWindow ( ::GetConsoleWindow(), SW_SHOWNORMAL ); + } +#endif return 0; }