[gedit] Revert "gedit-app: use g_option_context_parse_strv()"
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit] Revert "gedit-app: use g_option_context_parse_strv()"
- Date: Sat, 1 Feb 2014 14:54:06 +0000 (UTC)
commit 7660d0b636bd1f2d9e311f229753e506ae934f01
Author: Paolo Borelli <pborelli gnome org>
Date: Sat Feb 1 15:48:54 2014 +0100
Revert "gedit-app: use g_option_context_parse_strv()"
This reverts commit 0e82694a539de3017aa62e09cf32f4016f3df465.
It turns out that things are actually trickier and we rely on the
fact that the original array is left alone. For now we revert so
that "gedit foo.txt" works again, but we should revisit this once
https://bugzilla.gnome.org/show_bug.cgi?id=721977 lands in glib
gedit/gedit-app.c | 31 +++++++++++++++++++++++++++++--
1 files changed, 29 insertions(+), 2 deletions(-)
---
diff --git a/gedit/gedit-app.c b/gedit/gedit-app.c
index cc2875d..cec095b 100644
--- a/gedit/gedit-app.c
+++ b/gedit/gedit-app.c
@@ -793,6 +793,33 @@ get_option_context (void)
return context;
}
+static gboolean
+option_context_parse (GOptionContext *context,
+ gchar **arguments,
+ GError **error)
+{
+ gint argc;
+ gchar **argv;
+ gint i;
+ gboolean ret;
+
+ /* 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.
+ */
+ argc = g_strv_length (arguments);
+ argv = g_new (gchar *, argc);
+ for (i = 0; i < argc; i++)
+ {
+ argv[i] = arguments[i];
+ }
+
+ ret = g_option_context_parse (context, &argc, &argv, error);
+
+ g_free (argv);
+
+ return ret;
+}
+
static void
clear_options (void)
{
@@ -859,7 +886,7 @@ gedit_app_command_line (GApplication *application,
/* Avoid exit() on the main instance */
g_option_context_set_help_enabled (context, FALSE);
- if (!g_option_context_parse_strv (context, &arguments, &error))
+ if (!option_context_parse (context, arguments, &error))
{
/* We should never get here since parsing would have
* failed on the client side... */
@@ -952,7 +979,7 @@ gedit_app_local_command_line (GApplication *application,
/* Handle some of the option without contacting the main instance */
context = get_option_context ();
- if (!g_option_context_parse_strv (context, arguments, &error))
+ if (!option_context_parse (context, *arguments, &error))
{
g_printerr (_("%s\nRun '%s --help' to see a full list of available command line options.\n"),
error->message, (*arguments)[0]);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]