Permalink
Browse files

Set the working directory on Windows very early to also help code whi…

…ch uses relative resource paths
  • Loading branch information...
1 parent fc97950 commit 775ef628688c69de34640e12666aed5762a80dff @eht16 eht16 committed Mar 3, 2013
Showing with 14 additions and 11 deletions.
  1. +14 −11 src/main.c
View
@@ -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);

0 comments on commit 775ef62

Please sign in to comment.