From 739c76e862dff6d901b9238e148b752b61066a51 Mon Sep 17 00:00:00 2001 From: Richard Harrison Date: Mon, 29 Mar 2021 17:52:30 +0200 Subject: [PATCH] Win32 console; added method to ignore errors This is mainly for standalone FGCOM - because the error message is always shown because it is a console app and --console isn't required. --- simgear/debug/logstream.cxx | 11 ++++++----- simgear/debug/logstream.hxx | 4 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/simgear/debug/logstream.cxx b/simgear/debug/logstream.cxx index 92adbe34..36b5650c 100644 --- a/simgear/debug/logstream.cxx +++ b/simgear/debug/logstream.cxx @@ -712,7 +712,7 @@ void logstream::setStartupLoggingEnabled(bool enabled) d->setStartupLoggingEnabled(enabled); } -void logstream::requestConsole() +void logstream::requestConsole(bool ignoreErrors) { #if defined (SG_WINDOWS) const bool stderrAlreadyRedirected = d->m_stderr_isRedirectedAlready; @@ -751,7 +751,8 @@ void logstream::requestConsole() std::cerr.clear(); } } else { - MessageBox(0, "--console ignored because stdout or stderr redirected with > or 2>", "Simgear Error", MB_OK | MB_ICONERROR); + if (!ignoreErrors) + MessageBox(0, "--console ignored because stdout or stderr redirected with > or 2>", "Simgear Error", MB_OK | MB_ICONERROR); } #endif } @@ -767,9 +768,9 @@ logstream::setTestingMode( bool testMode ) namespace simgear { -void requestConsole() -{ - sglog().requestConsole(); +void requestConsole(bool ignoreErrors) +{ + sglog().requestConsole(ignoreErrors); } diff --git a/simgear/debug/logstream.hxx b/simgear/debug/logstream.hxx index c58c3cb0..195daeac 100644 --- a/simgear/debug/logstream.hxx +++ b/simgear/debug/logstream.hxx @@ -44,7 +44,7 @@ class LogCallback; * we need to show a console. This basically means Windows at the * moment - on other plaforms it's a no-op */ -void requestConsole(); +void requestConsole(bool ignoreErrors); void shutdownLogging(); @@ -65,7 +65,7 @@ public: * we need to show a console. This basically means Windows at the * moment - on other plaforms it's a no-op */ - void requestConsole(); + void requestConsole(bool ignoreErrors); /** * Set the global log class and priority level.