[LyX/master] Fix bug 11998

Eugene Chornyi yu_jin at lyx.org
Mon Mar 8 18:30:10 UTC 2021


commit 167dfbc92c3543bb3833222e67f7b55c9a93a5e3
Author: Eugene Chornyi <yu_jin at lyx.org>
Date:   Mon Mar 8 19:35:18 2021 +0100

    Fix bug 11998
    
    If started from console, the console is the parent process, which can be attached. If started not from console, parent process does not exist and the block is skipped.
---
 src/main.cpp |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/src/main.cpp b/src/main.cpp
index 5c4fb46..94b1ccd 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -21,6 +21,11 @@
 #include <ios>
 #endif
 
+#ifdef WIN32
+#include <Windows.h>
+#endif
+
+
 using namespace std;
 
 
@@ -30,6 +35,13 @@ int main(int argc, char * argv[])
 	ios_base::sync_with_stdio(false);
 #endif
 
+#ifdef WIN32
+	if (AttachConsole(ATTACH_PARENT_PROCESS)) {
+		freopen("CONOUT$", "w", stdout);
+		freopen("CONOUT$", "w", stderr);
+	}
+#endif
+
 	// To avoid ordering of global object problems with some
 	// stdlibs we do the initialization here, but still as
 	// early as possible.


More information about the lyx-cvs mailing list