From e17b4ad27fa4f13915af895604534786e99cfc90 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Krzysztof=20Kosi=C5=84ski?= Date: Sat, 3 Apr 2010 01:47:43 +0200 Subject: [PATCH] Fix command line invocation on Windows (LP #167455). --- src/main.cpp | 21 +-------------------- src/prefix.cpp | 8 ++++---- src/prefix.h | 15 +++++++-------- src/ui/dialog/glyphs.cpp | 4 ++-- src/ui/dialog/glyphs.h | 2 +- 5 files changed, 15 insertions(+), 35 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 5aa164df8..9f7bc9ad3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -593,22 +593,7 @@ main(int argc, char **argv) #endif #ifdef WIN32 - /* - Set the current directory to the directory of the - executable. This seems redundant, but is needed for - when inkscape.exe is executed from another directory. - We use relative paths on win32. - HKCR\svgfile\shell\open\command is a good example - - TODO: this breaks the CLI on Windows, see LP #167455 - */ - const int pathbuf = 2048; - gunichar2 *path = g_new(gunichar2, pathbuf); - GetModuleFileNameW(NULL, (WCHAR*) path, pathbuf); - gchar *inkscape = g_utf16_to_utf8(path, -1, NULL, NULL, NULL); - gchar *exedir = g_path_get_dirname(inkscape); - gunichar2 *dirw = g_utf8_to_utf16(exedir, -1, NULL, NULL, NULL); - SetCurrentDirectoryW((WCHAR*) dirw); + gchar *exedir = g_strdup(win32_getExePath().data()); _win32_set_inkscape_env(exedir); # ifdef ENABLE_NLS @@ -620,11 +605,7 @@ main(int argc, char **argv) g_free(shortexedir); g_free(localepath); # endif - - g_free(path); - g_free(inkscape); g_free(exedir); - g_free(dirw); // Don't touch the registry (works fine without it) for Inkscape Portable gchar const *val = g_getenv("INKSCAPE_PORTABLE_PROFILE_DIR"); diff --git a/src/prefix.cpp b/src/prefix.cpp index 8c1dd4f00..92409a7d2 100644 --- a/src/prefix.cpp +++ b/src/prefix.cpp @@ -435,11 +435,11 @@ br_extract_prefix (const char *path) /** * Return the directory of the .exe that is currently running */ -static Glib::ustring win32_getExePath() +Glib::ustring win32_getExePath() { gunichar2 path[2048]; - GetModuleFileNameW(NULL, (WCHAR*) path, 2048); - gchar *exe = g_utf16_to_utf8(path, -1, NULL, NULL, NULL); + GetModuleFileNameW(0, (WCHAR*) path, 2048); + gchar *exe = g_utf16_to_utf8(path, -1, 0,0,0); gchar *dir = g_path_get_dirname(exe); Glib::ustring ret = dir; g_free(dir); @@ -481,7 +481,7 @@ static Glib::ustring win32_getResourcePath(const Glib::ustring &childPath) */ char *win32_relative_path(const char *childPath) { - static char *returnPath = NULL; + static char *returnPath = 0; if (!childPath) childPath = ""; Glib::ustring resourcePath = win32_getResourcePath(childPath); diff --git a/src/prefix.h b/src/prefix.h index 0c2db5b58..af96fa746 100644 --- a/src/prefix.h +++ b/src/prefix.h @@ -114,20 +114,19 @@ char *br_strcat (const char *str1, const char *str2); char *br_extract_dir (const char *path); char *br_extract_prefix(const char *path); +#ifdef __cplusplus +} +#endif /* __cplusplus */ + #ifdef __WIN32__ -/** - * Win32 version of a relocatable function - */ +#include + +Glib::ustring win32_getExePath(); char *win32_relative_path(const char *childPath); #define WIN32_DATADIR(suffix) (win32_relative_path(suffix)) #endif - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - #endif /* _PREFIX_H_ */ diff --git a/src/ui/dialog/glyphs.cpp b/src/ui/dialog/glyphs.cpp index 1c875e8cc..bc96b0575 100644 --- a/src/ui/dialog/glyphs.cpp +++ b/src/ui/dialog/glyphs.cpp @@ -159,8 +159,8 @@ GlyphColumns *GlyphsPanel::getColumns() /** * Constructor */ -GlyphsPanel::GlyphsPanel(gchar const *prefsPath) : - Inkscape::UI::Widget::Panel("", prefsPath, SP_VERB_DIALOG_GLYPHS, "", false), +GlyphsPanel::GlyphsPanel() : + Inkscape::UI::Widget::Panel("", "/dialogs/glyphs", SP_VERB_DIALOG_GLYPHS, "", false), store(Gtk::ListStore::create(*getColumns())), iconView(0), entry(0), diff --git a/src/ui/dialog/glyphs.h b/src/ui/dialog/glyphs.h index 49ead3d6b..b4876f3c1 100644 --- a/src/ui/dialog/glyphs.h +++ b/src/ui/dialog/glyphs.h @@ -43,7 +43,7 @@ class GlyphColumns; class GlyphsPanel : public Inkscape::UI::Widget::Panel { public: - GlyphsPanel(gchar const *prefsPath = "/dialogs/glyphs"); + GlyphsPanel(); virtual ~GlyphsPanel(); static GlyphsPanel& getInstance(); -- 2.30.2