Commit 28bf7186 authored by Patrick Storz's avatar Patrick Storz 🦄

append_inkscape_datadir: Canonicalize inkscape_datadir separately

g_canonicalize_filename() needs the second parameter to be absolute
which INKSCAPE_DATADIR is not guaranteed to be (e.g. when supplied
via environment variable).

(follow up to 812f50f7)
parent 370c52d1
Pipeline #66318948 passed with stages
in 116 minutes and 35 seconds
...@@ -37,18 +37,30 @@ char *append_inkscape_datadir(const char *relative_path) ...@@ -37,18 +37,30 @@ char *append_inkscape_datadir(const char *relative_path)
{ {
static gchar const *inkscape_datadir; static gchar const *inkscape_datadir;
if (!inkscape_datadir) { if (!inkscape_datadir) {
gchar *datadir;
gchar const *datadir_env = g_getenv("INKSCAPE_DATADIR"); gchar const *datadir_env = g_getenv("INKSCAPE_DATADIR");
if (datadir_env) { if (datadir_env) {
inkscape_datadir = g_strdup(datadir_env); datadir = g_strdup(datadir_env);
} else { } else {
#ifdef _WIN32 #ifdef _WIN32
gchar *module_path = g_win32_get_package_installation_directory_of_module(NULL); gchar *module_path = g_win32_get_package_installation_directory_of_module(NULL);
inkscape_datadir = g_build_filename(module_path, "share", NULL); datadir = g_build_filename(module_path, "share", NULL);
g_free(module_path); g_free(module_path);
#else #else
inkscape_datadir = INKSCAPE_DATADIR; datadir = g_strdup(INKSCAPE_DATADIR);
#endif #endif
} }
#if GLIB_CHECK_VERSION(2,58,0)
inkscape_datadir = g_canonicalize_filename(datadir, NULL);
g_free(datadir);
#else
inkscape_datadir = datadir;
#endif
}
if (!relative_path) {
relative_path = "";
} }
#if GLIB_CHECK_VERSION(2,58,0) #if GLIB_CHECK_VERSION(2,58,0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment