Console is now only initialized when the emulator is started with the -D / --debug parameter.

This commit is contained in:
OBattler
2020-04-22 13:19:28 +02:00
parent 21f979a748
commit 15dcd63e72

View File

@@ -233,7 +233,8 @@ CreateConsole(int init)
int i; int i;
if (! init) { if (! init) {
FreeConsole(); if (force_debug)
FreeConsole();
return; return;
} }
@@ -271,6 +272,13 @@ CreateConsole(int init)
} }
static void
CloseConsole(void)
{
CreateConsole(0);
}
/* Process the commandline, and create standard argc/argv array. */ /* Process the commandline, and create standard argc/argv array. */
static int static int
ProcessCommandLine(wchar_t ***argw) ProcessCommandLine(wchar_t ***argw)
@@ -362,7 +370,8 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpszArg, int nCmdShow)
set_language(0x0409); set_language(0x0409);
/* Create console window. */ /* Create console window. */
CreateConsole(1); if (force_debug)
CreateConsole(1);
/* Process the command line for options. */ /* Process the command line for options. */
argc = ProcessCommandLine(&argw); argc = ProcessCommandLine(&argw);
@@ -370,7 +379,8 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpszArg, int nCmdShow)
/* Pre-initialize the system, this loads the config file. */ /* Pre-initialize the system, this loads the config file. */
if (! pc_init(argc, argw)) { if (! pc_init(argc, argw)) {
/* Detach from console. */ /* Detach from console. */
CreateConsole(0); if (force_debug)
CreateConsole(0);
if (source_hwnd) if (source_hwnd)
PostMessage((HWND) (uintptr_t) source_hwnd, WM_HAS_SHUTDOWN, (WPARAM) 0, (LPARAM) hwndMain); PostMessage((HWND) (uintptr_t) source_hwnd, WM_HAS_SHUTDOWN, (WPARAM) 0, (LPARAM) hwndMain);
@@ -380,9 +390,8 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpszArg, int nCmdShow)
return(1); return(1);
} }
/* Cleanup: we may no longer need the console. */ if (force_debug)
if (! force_debug) atexit(CloseConsole);
CreateConsole(0);
/* Handle our GUI. */ /* Handle our GUI. */
i = ui_init(nCmdShow); i = ui_init(nCmdShow);