From: Tor Lillqvist Date: Fri, 19 Sep 2008 10:20:41 +0000 (+0000) Subject: glib/gutils.c (_glib_get_dll_directory) Be a bit less restrictive, look X-Git-Tag: GLIB_2_19_0~66 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bc8e1dd8c130e1aa028a8c929d43841b70540d38;p=platform%2Fupstream%2Fglib.git glib/gutils.c (_glib_get_dll_directory) Be a bit less restrictive, look 2008-09-19 Tor Lillqvist * glib/gutils.c (_glib_get_dll_directory) * glib/gspawn-win32.c (do_spawn_with_pipes): Be a bit less restrictive, look for the helper programs in the same folder where the GLib DLL is, not necessarily in a "bin" subfolder of the top GLib installation folder. svn path=/trunk/; revision=7511 --- diff --git a/ChangeLog b/ChangeLog index 1b1f034..adfe049 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2008-09-19 Tor Lillqvist + + * glib/gutils.c (_glib_get_dll_directory) + * glib/gspawn-win32.c (do_spawn_with_pipes): Be a bit less + restrictive, look for the helper programs in the same folder where + the GLib DLL is, not necessarily in a "bin" subfolder of the top + GLib installation folder. + 2008-09-18 Matthias Clasen * configure.in: Bump version to 2.19.0 diff --git a/glib/gspawn-win32.c b/glib/gspawn-win32.c index 9eb21e7..1727885 100644 --- a/glib/gspawn-win32.c +++ b/glib/gspawn-win32.c @@ -551,8 +551,8 @@ do_spawn_with_pipes (gint *exit_status, gchar *helper_process; CONSOLE_CURSOR_INFO cursor_info; wchar_t *whelper, **wargv, **wenvp; - extern gchar *_glib_get_installation_directory (void); - gchar *glib_top; + extern gchar *_glib_get_dll_directory (void); + gchar *glib_dll_directory; if (child_setup && !warned_about_child_setup) { @@ -600,11 +600,11 @@ do_spawn_with_pipes (gint *exit_status, else helper_process = HELPER_PROCESS ".exe"; - glib_top = _glib_get_installation_directory (); - if (glib_top != NULL) + glib_dll_directory = _glib_get_dll_directory (); + if (glib_dll_directory != NULL) { - helper_process = g_build_filename (glib_top, "bin", helper_process, NULL); - g_free (glib_top); + helper_process = g_build_filename (glib_dll_directory, helper_process, NULL); + g_free (glib_dll_directory); } else helper_process = g_strdup (helper_process); diff --git a/glib/gutils.c b/glib/gutils.c index df9c658..9cc7cbe 100644 --- a/glib/gutils.c +++ b/glib/gutils.c @@ -150,16 +150,40 @@ DllMain (HINSTANCE hinstDLL, #endif gchar * -_glib_get_installation_directory (void) +_glib_get_dll_directory (void) { + gchar *retval; + gchar *p; + wchar_t wc_fn[MAX_PATH]; + #ifdef DLL_EXPORT if (glib_dll == NULL) return NULL; #endif - /* In a static build of GLib just use the application's .exe file's - * installation directory... + + /* This code is different from that in + * g_win32_get_package_installation_directory_of_module() in that + * here we return the actual folder where the GLib DLL is. We don't + * do the check for it being in a "bin" or "lib" subfolder and then + * returning the parent of that. + * + * In a statically built GLib, glib_dll will be NULL and we will + * thus look up the application's .exe file's location. */ - return g_win32_get_package_installation_directory_of_module (glib_dll); + if (!GetModuleFileNameW (glib_dll, wc_fn, MAX_PATH)) + return NULL; + + retval = g_utf16_to_utf8 (wc_fn, -1, NULL, NULL, NULL); + + p = strrchr (retval, G_DIR_SEPARATOR); + if (p == NULL) + { + /* Wtf? */ + return NULL; + } + *p = '\0'; + + return retval; } #endif