From 9b997ea1f7369bc667d0aaa06ab2406288ee9f7c Mon Sep 17 00:00:00 2001 From: James Turner Date: Fri, 2 Sep 2016 00:05:13 +0100 Subject: [PATCH] Only reopen the streams if AllocConsole succeeds. Avoid a crash with FGRun when OSG tries to use the console. --- simgear/debug/logstream.cxx | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/simgear/debug/logstream.cxx b/simgear/debug/logstream.cxx index 453ad067..2dea0fba 100644 --- a/simgear/debug/logstream.cxx +++ b/simgear/debug/logstream.cxx @@ -232,13 +232,11 @@ public: if (AttachConsole(ATTACH_PARENT_PROCESS) == 0) { // attach failed, don't install the callback addStderr = false; - } - - if (!isFile) { - // No - OK! now set streams to attached console - freopen("conout$", "w", stdout); - freopen("conout$", "w", stderr); - } + } else if (!isFile) { + // No - OK! now set streams to attached console + freopen("conout$", "w", stdout); + freopen("conout$", "w", stderr); + } #endif if (addStderr) { m_callbacks.push_back(new StderrLogCallback(m_logClass, m_logPriority));