From 04c82a42eb2257e7129fe825c50db4d19ef251e6 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 2 Feb 2023 01:12:19 +0300 Subject: [PATCH] Add KICAD_ALLOC_CONSOLE environment variable to show console in GUI apps on Windows. For debugging purposes, currently. --- libs/kiplatform/msw/app.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libs/kiplatform/msw/app.cpp b/libs/kiplatform/msw/app.cpp index b3c28e800b..dc45442efa 100644 --- a/libs/kiplatform/msw/app.cpp +++ b/libs/kiplatform/msw/app.cpp @@ -59,9 +59,11 @@ bool KIPLATFORM::APP::Init() SetSearchPathMode( BASE_SEARCH_PATH_ENABLE_SAFE_SEARCHMODE | BASE_SEARCH_PATH_PERMANENT ); // In order to support GUI and CLI - // Let's attach to console when it's possible + // Let's attach to console when it's possible, or allocate if requested. + bool tryAlloc = wxGetEnv( wxS( "KICAD_ALLOC_CONSOLE" ), nullptr ); + HANDLE handle; - if( AttachConsole( ATTACH_PARENT_PROCESS ) ) + if( AttachConsole( ATTACH_PARENT_PROCESS ) || ( tryAlloc && AllocConsole() ) ) { #if !defined( __MINGW32__ ) // These redirections create problems on mingw: // Nothing is printed to the console