After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 721947 - Improve GApplication ⇔ GOptionContext compatibility
Improve GApplication ⇔ GOptionContext compatibility
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks: 721892
 
 
Reported: 2014-01-10 17:32 UTC by Allison Karlitskaya (desrt)
Modified: 2014-01-11 05:48 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
GOptionContext: add memory-friendly parse mode (3.78 KB, patch)
2014-01-10 17:32 UTC, Allison Karlitskaya (desrt)
committed Details | Review
tests: fix leaks in option-context test (1.44 KB, patch)
2014-01-10 17:32 UTC, Allison Karlitskaya (desrt)
committed Details | Review
gedit-app: use g_option_context_parse_strv() (2.11 KB, patch)
2014-01-10 17:46 UTC, Allison Karlitskaya (desrt)
committed Details | Review

Description Allison Karlitskaya (desrt) 2014-01-10 17:32:34 UTC
See patches.
Comment 1 Allison Karlitskaya (desrt) 2014-01-10 17:32:36 UTC
Created attachment 265952 [details] [review]
GOptionContext: add memory-friendly parse mode

Add g_option_context_parse_strv() that obeys the normal memory conventions for
dealing with a strv instead of assuming that we're dealing with the 'argv'
parameter to main().

This will help for using GOptionContext with GApplication.
Comment 2 Allison Karlitskaya (desrt) 2014-01-10 17:32:39 UTC
Created attachment 265953 [details] [review]
tests: fix leaks in option-context test

Use the new g_option_context_parse_strv() to patch up some leaks in some
insufficiently-argv-emulating testcases in option-context.c.

This gives some test coverage of the new function while also making
option-context now leak-free.
Comment 3 Allison Karlitskaya (desrt) 2014-01-10 17:46:41 UTC
Created attachment 265956 [details] [review]
gedit-app: use g_option_context_parse_strv()

Instead of our own function to do (almost) the same.
Comment 4 Ignacio Casal Quinteiro (nacho) 2014-01-10 18:55:43 UTC
Review of attachment 265952 [details] [review]:

See minor comment. Apart from that looks good.

::: glib/goption.c
@@ +2474,3 @@
+ * @context: a #GOptionContext
+ * @arguments: (inout) (array null-terminated=1): a pointer to the command line arguments
+ * @error: a return location for errors

missing annotation?
Comment 5 Ignacio Casal Quinteiro (nacho) 2014-01-10 18:57:15 UTC
Review of attachment 265953 [details] [review]:

Looks good
Comment 6 Ignacio Casal Quinteiro (nacho) 2014-01-10 18:59:08 UTC
Review of attachment 265956 [details] [review]:

nice. go ahead
Comment 7 Matthias Clasen 2014-01-10 19:12:23 UTC
Review of attachment 265952 [details] [review]:

::: glib/goption.c
@@ +2486,3 @@
+ *
+ * This function is useful if you are trying to use #GOptionContext with
+ * #GApplication.

I think this calls or an example (probably over on the GApplication side)
Comment 8 Allison Karlitskaya (desrt) 2014-01-11 05:46:41 UTC
I've started writing docs (with examples) here: https://wiki.gnome.org/HowDoI/GtkApplication/CommandLine