From 378a6384e55bdb8c5750c051fd91302f64d2b69a Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Fri, 5 Mar 2010 23:44:33 +0100 Subject: Patch from Fridrich - LP #520532 Fixed bugs: - https://launchpad.net/bugs/520532 (bzr r9149) --- src/winmain.cpp | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'src/winmain.cpp') diff --git a/src/winmain.cpp b/src/winmain.cpp index dc6b7e008..4fde2c574 100644 --- a/src/winmain.cpp +++ b/src/winmain.cpp @@ -6,8 +6,11 @@ #include #ifdef G_OS_WIN32 - #undef DATADIR + +#include +#include +#define _WIN32_WINNT 0x0501 #include extern int main (int argc, char **argv); @@ -26,6 +29,28 @@ WinMain (struct HINSTANCE__ *hInstance, char *lpszCmdLine, int nCmdShow) { + if (fileno (stdout) != -1 && + _get_osfhandle (fileno (stdout)) != -1) + { + /* stdout is fine, presumably redirected to a file or pipe */ + } + else + { + typedef BOOL (* WINAPI AttachConsole_t) (DWORD); + + AttachConsole_t p_AttachConsole = + (AttachConsole_t) GetProcAddress (GetModuleHandle ("kernel32.dll"), "AttachConsole"); + + if (p_AttachConsole != NULL && p_AttachConsole (ATTACH_PARENT_PROCESS)) + { + freopen ("CONOUT$", "w", stdout); + dup2 (fileno (stdout), 1); + freopen ("CONOUT$", "w", stderr); + dup2 (fileno (stderr), 2); + + } + } + int ret; ret = main (__argc, __argv); return ret; -- cgit v1.2.3 From ffaa723f87d973a6c05be0765a2caf98b1b3a9b4 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Fri, 5 Mar 2010 23:52:15 +0100 Subject: Adjust Windows build after fixing LP #520532 (bzr r9150) --- src/winmain.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/winmain.cpp') diff --git a/src/winmain.cpp b/src/winmain.cpp index 4fde2c574..752ab8e6b 100644 --- a/src/winmain.cpp +++ b/src/winmain.cpp @@ -8,6 +8,7 @@ #ifdef G_OS_WIN32 #undef DATADIR +#include #include #include #define _WIN32_WINNT 0x0501 -- cgit v1.2.3