diff --git a/src/main.c b/src/main.c index 98f1df6bd..88dad1e99 100644 --- a/src/main.c +++ b/src/main.c @@ -376,6 +376,18 @@ static void get_line_and_column_from_filename(gchar *filename, gint *line, gint } +#ifdef G_OS_WIN32 +static void change_working_directory_on_windows(const gchar *install_dir) +{ + /* On Windows, change the working directory to the Geany installation path to not lock + * the directory of a file passed as command line argument (see bug #2626124). + * This also helps if plugins or other code uses relative paths to load + * any additional resources (e.g. share/geany-plugins/...). */ + win32_set_working_directory(install_dir); +} +#endif + + static void setup_paths(void) { gchar *data_dir; @@ -390,6 +402,8 @@ static void setup_paths(void) data_dir = g_build_filename(install_dir, "data", NULL); /* e.g. C:\Program Files\geany\data */ doc_dir = g_build_filename(install_dir, "doc", NULL); + change_working_directory_on_windows(install_dir); + g_free(install_dir); #else data_dir = g_build_filename(GEANY_DATADIR, "geany", NULL); /* e.g. /usr/share/geany */ @@ -1143,17 +1157,6 @@ gint main(gint argc, gchar **argv) } #endif -#ifdef G_OS_WIN32 - { - gchar *dir; - /* On Windows, change the working directory to the Geany installation path to not lock - * the directory of a file passed as command line argument (see bug #2626124). */ - dir = win32_get_installation_dir(); - win32_set_working_directory(dir); - g_free(dir); - } -#endif - /* when we are really done with setting everything up and the main event loop is running, * tell other components, mainly plugins, that startup is complete */ g_idle_add_full(G_PRIORITY_LOW, send_startup_complete, NULL, NULL);