[geany/geany] e80219: Re-add the previous workaround to remember the directory Geany was started from

Enrico Tröger git-noreply at xxxxx
Sun Apr 13 13:14:35 UTC 2014


Branch:      refs/heads/master
Author:      Enrico Tröger <enrico.troeger at uvena.de>
Committer:   Enrico Tröger <enrico.troeger at uvena.de>
Date:        Sun, 13 Apr 2014 13:14:35 UTC
Commit:      e802194ad395201cfddf6fd1548446244f2748f3
             https://github.com/geany/geany/commit/e802194ad395201cfddf6fd1548446244f2748f3

Log Message:
-----------
Re-add the previous workaround to remember the directory Geany was started from

My previous fix (e1ce9cfbec) didn't fix all possible use cases (opening
files from CLI when starting Geany). This one should close the gap.


Modified Paths:
--------------
    src/main.c

Modified: src/main.c
11 files changed, 10 insertions(+), 1 deletions(-)
===================================================================
@@ -91,6 +91,7 @@ gboolean	ignore_callback;	/* hack workaround for GTK+ toggle button callback pro
 GeanyStatus	 main_status;
 CommandLineOptions cl_options;	/* fields initialised in parse_command_line_options */
 
+static gchar *original_cwd = NULL;
 
 static const gchar geany_lib_versions[] = "GTK %u.%u.%u, GLib %u.%u.%u";
 
@@ -313,7 +314,11 @@ gchar *main_get_argv_filename(const gchar *filename)
 	else
 	{
 		/* use current dir */
-		gchar *cur_dir = g_get_current_dir();
+		gchar *cur_dir = NULL;
+		if (original_cwd == NULL)
+			cur_dir = g_get_current_dir();
+		else
+			cur_dir = g_strdup(original_cwd);
 
 		result = g_strjoin(
 			G_DIR_SEPARATOR_S, cur_dir, filename, NULL);
@@ -384,6 +389,9 @@ static void change_working_directory_on_windows()
 {
 	gchar *install_dir = win32_get_installation_dir();
 
+	/* remember original working directory for use with opening files from the command line */
+	original_cwd = g_get_current_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
@@ -1333,6 +1341,7 @@ void main_quit(void)
 	g_object_unref(geany_object);
 	geany_object = NULL;
 
+	g_free(original_cwd);
 	g_free(app);
 
 	ui_finalize_builder();



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Commits mailing list