From 50d4043003935f945a730e513fd4c64d9778d7df Mon Sep 17 00:00:00 2001 From: Bruno Lopes Date: Tue, 24 Feb 2026 20:39:17 -0300 Subject: [PATCH] libgimp: Set _NT_SYMBOL_PATH for plug-ins when relocatable This concludes 63f5ea9d by adding support to CodeView symbols from plug-ins with DrMingw. (Should not be needed but DrMingw is buggy). --- libgimp/gimp.c | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/libgimp/gimp.c b/libgimp/gimp.c index ae14b0e217..b117ae49d9 100644 --- a/libgimp/gimp.c +++ b/libgimp/gimp.c @@ -241,7 +241,9 @@ gimp_main (GType plug_in_type, { time_t t; #ifdef ENABLE_RELOCATABLE_RESOURCES - gchar *plugin_dir; + gchar *plugin_dir = NULL; + WCHAR plugin_dir_utf16[MAX_PATH]; + gchar *plugin_exe; size_t codeview_path_len; gchar *codeview_path; #endif @@ -250,22 +252,30 @@ gimp_main (GType plug_in_type, wchar_t *plug_in_backtrace_path_utf16; #ifdef ENABLE_RELOCATABLE_RESOURCES - /* FIXME: https://github.com/jrfonseca/drmingw/issues/91 - * FIXME: This needs to take into account the plugin path - plugin_dir = ??? - codeview_path_len = strlen (g_getenv ("_NT_SYMBOL_PATH") ? g_getenv ("_NT_SYMBOL_PATH") : "") + strlen (plugin_dir) + 2; - codeview_path = g_try_malloc (codeview_path_len); - if (codeview_path == NULL) + /* FIXME: https://github.com/jrfonseca/drmingw/issues/91 */ + if (GetModuleFileNameW (NULL, plugin_dir_utf16, MAX_PATH) != 0) { - g_warning ("Failed to allocate memory"); + plugin_exe = g_utf16_to_utf8 ((const guint16 *)plugin_dir_utf16, -1, + NULL, NULL, NULL); + plugin_dir = g_path_get_dirname (plugin_exe); + g_free (plugin_exe); } - if (g_getenv ("_NT_SYMBOL_PATH")) - g_snprintf (codeview_path, codeview_path_len, "%s;%s", plugin_dir, g_getenv ("_NT_SYMBOL_PATH")); - else - g_snprintf (codeview_path, codeview_path_len, "%s", plugin_dir); - g_setenv ("_NT_SYMBOL_PATH", codeview_path, TRUE); - g_free (codeview_path); - g_free (plugin_dir);*/ + if (plugin_dir && (!g_getenv ("_NT_SYMBOL_PATH") || !strstr(g_getenv ("_NT_SYMBOL_PATH"), plugin_dir))) + { + codeview_path_len = strlen (g_getenv ("_NT_SYMBOL_PATH") ? g_getenv ("_NT_SYMBOL_PATH") : "") + strlen (plugin_dir) + 2; + codeview_path = g_try_malloc (codeview_path_len); + if (codeview_path == NULL) + { + g_warning ("Failed to allocate memory"); + } + if (g_getenv ("_NT_SYMBOL_PATH")) + g_snprintf (codeview_path, codeview_path_len, "%s;%s", plugin_dir, g_getenv ("_NT_SYMBOL_PATH")); + else + g_snprintf (codeview_path, codeview_path_len, "%s", plugin_dir); + g_setenv ("_NT_SYMBOL_PATH", codeview_path, TRUE); + g_free (codeview_path); + } + g_free (plugin_dir); #endif /* This has to be the non-roaming directory (i.e., the local