[gedit/wip/gtkapp] we actually need the ugly hack on both sides :(



commit 13e34d022b3c48ac951c7d4ed92a2b949e25fdd0
Author: Paolo Borelli <pborelli gnome org>
Date:   Tue Jul 31 16:57:02 2012 +0200

    we actually need the ugly hack on both sides :(

 gedit/gedit-app.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
---
diff --git a/gedit/gedit-app.c b/gedit/gedit-app.c
index 53c25bc..6cd6b6d 100644
--- a/gedit/gedit-app.c
+++ b/gedit/gedit-app.c
@@ -578,6 +578,7 @@ gedit_app_command_line (GApplication            *application,
 	GError *error = NULL;
 	gint argc;
 	gchar **argv;
+	gchar **argv_tofree;
 
 	/* reset values */
 	g_free (encoding_charset);
@@ -599,6 +600,17 @@ gedit_app_command_line (GApplication            *application,
 
 	argv = g_application_command_line_get_arguments (command_line, &argc);
 
+	gint i;
+
+	/* We have to make an extra copy of the array, since g_option_context_parse()
+	 * assumes that it can remove strings from the array without freeing them.
+	 */
+	argv_tofree = g_new (gchar*, argc + 1);
+	for (i = 0; i <= argc; i++)
+	{
+		argv[i] = argv[i];
+	}
+
 	/* Setup command line options */
 	context = g_option_context_new (_("- Edit text files"));
 	g_option_context_set_help_enabled (context, FALSE);
@@ -639,6 +651,7 @@ gedit_app_command_line (GApplication            *application,
 	}
 
 	g_option_context_free (context);
+	g_free (argv_tofree);
 
 	return 0;
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]