From 291a36596c2ad735aa6c37ece0936f1147bdea57 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Krzysztof=20Kosi=C5=84ski?= Date: Fri, 5 Mar 2010 23:44:33 +0100 Subject: [PATCH] Patch from Fridrich - LP #520532 --- src/Makefile.am | 6 ++++-- src/color-profile.cpp | 2 +- src/dialogs/export.cpp | 2 +- src/main.cpp | 9 ++++----- src/winmain.cpp | 27 ++++++++++++++++++++++++++- 5 files changed, 36 insertions(+), 10 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 92e520e5b..ff5d20f49 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -88,7 +88,8 @@ CXXTEST_TESTSUITES = if PLATFORM_WIN32 win32_sources = winmain.cpp registrytool.cpp registrytool.h -win32ldflags = -lcomdlg32 +win32ldflags = -lcomdlg32 -lmscms +mwindows = -mwindows endif if INKJAR @@ -215,10 +216,11 @@ libinkscape_a_SOURCES = $(ink_common_sources) inkscape_SOURCES += main.cpp $(win32_sources) inkscape_LDADD = $(all_libs) -inkscape_LDFLAGS = --export-dynamic $(kdeldflags) +inkscape_LDFLAGS = --export-dynamic $(kdeldflags) $(mwindows) inkview_SOURCES += inkview.cpp $(win32_sources) inkview_LDADD = $(all_libs) +inkview_LDFLAGS = $(mwindows) # ################################################ # VERSION REPORTING diff --git a/src/color-profile.cpp b/src/color-profile.cpp index 310a37356..43709793c 100644 --- a/src/color-profile.cpp +++ b/src/color-profile.cpp @@ -35,7 +35,7 @@ #include "dom/util/digest.h" #ifdef WIN32 -#include +#include #endif // WIN32 using Inkscape::ColorProfile; diff --git a/src/dialogs/export.cpp b/src/dialogs/export.cpp index fa0fa5b6f..9e8a71c35 100644 --- a/src/dialogs/export.cpp +++ b/src/dialogs/export.cpp @@ -62,7 +62,7 @@ #ifdef WIN32 #include -#include +#include #include #endif diff --git a/src/main.cpp b/src/main.cpp index f55731be8..d11222203 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -56,6 +56,10 @@ #include "gc-core.h" +#ifdef AND +#undef AND +#endif + #include "macros.h" #include "file.h" #include "document.h" @@ -94,14 +98,9 @@ #include #ifdef WIN32 -//#define REPLACEARGS_ANSI -//#define REPLACEARGS_DEBUG - #include "registrytool.h" - #include "extension/internal/win32.h" using Inkscape::Extension::Internal::PrintWin32; - #endif // WIN32 #include "extension/init.h" 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; -- 2.30.2