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 743349 - goption: Add boxed type for GOptionGroup
goption: Add boxed type for GOptionGroup
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks: 743350
 
 
Reported: 2015-01-22 13:47 UTC by Bastien Nocera
Modified: 2015-02-17 18:38 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
goption: Add boxed type for GOptionGroup (3.82 KB, patch)
2015-01-22 13:47 UTC, Bastien Nocera
reviewed Details | Review
goption: Add boxed type for GOptionGroup (4.38 KB, patch)
2015-01-22 13:58 UTC, Bastien Nocera
none Details | Review
goption: Add boxed type for GOptionGroup (5.05 KB, patch)
2015-01-22 15:28 UTC, Bastien Nocera
reviewed Details | Review
goption: Add boxed type for GOptionGroup (6.17 KB, patch)
2015-01-28 09:21 UTC, Bastien Nocera
none Details | Review
goption: Add boxed type for GOptionGroup (6.13 KB, patch)
2015-01-28 15:57 UTC, Bastien Nocera
none Details | Review
goption: Add boxed type for GOptionGroup (6.13 KB, patch)
2015-01-28 15:59 UTC, Bastien Nocera
needs-work Details | Review
goption: Add boxed type for GOptionGroup (7.71 KB, patch)
2015-02-11 13:51 UTC, Bastien Nocera
accepted-commit_now Details | Review
goption: Add boxed type for GOptionGroup (7.68 KB, patch)
2015-02-11 14:33 UTC, Bastien Nocera
committed Details | Review

Description Bastien Nocera 2015-01-22 13:47:10 UTC
.
Comment 1 Bastien Nocera 2015-01-22 13:47:14 UTC
Created attachment 295170 [details] [review]
goption: Add boxed type for GOptionGroup

This would allow bindings to use _get_option_group() functions, which
would then allow them to use GOption parsing.
Comment 2 Allison Karlitskaya (desrt) 2015-01-22 13:48:11 UTC
Review of attachment 295170 [details] [review]:

Why not refcounting?
Comment 3 Bastien Nocera 2015-01-22 13:58:30 UTC
Created attachment 295172 [details] [review]
goption: Add boxed type for GOptionGroup

This would allow bindings to use _get_option_group() functions, which
would then allow them to use GOption parsing.
Comment 4 Bastien Nocera 2015-01-22 15:28:49 UTC
Created attachment 295189 [details] [review]
goption: Add boxed type for GOptionGroup

This would allow bindings to use _get_option_group() functions, which
would then allow them to use GOption parsing.
Comment 5 Allison Karlitskaya (desrt) 2015-01-28 09:11:00 UTC
Review of attachment 295189 [details] [review]:

Just about right -- can you deprecate free() [moving the code to unref] and make the refcounting non-atomic?
Comment 6 Bastien Nocera 2015-01-28 09:21:41 UTC
Created attachment 295623 [details] [review]
goption: Add boxed type for GOptionGroup

This would allow bindings to use _get_option_group() functions, which
would then allow them to use GOption parsing.
Comment 7 Bastien Nocera 2015-01-28 09:24:21 UTC
(In reply to comment #5)
> Review of attachment 295189 [details] [review]:
> 
> Just about right -- can you deprecate free() [moving the code to unref] and

Done.

> make the refcounting non-atomic?

I don't understand that. Why?
Comment 8 Allison Karlitskaya (desrt) 2015-01-28 13:29:05 UTC
We're trying to move away from our general approach of "make all refcounting atomic" for performance reasons.  I don't really think it matters much in this particular case, but as a general pattern, it's something that we are trying to change.

I can't imagine any situation in which you would want to use a GOptionGroup from multiple threads at the same time, so as a default, we should make it non-atomic.
Comment 9 Bastien Nocera 2015-01-28 15:57:38 UTC
Created attachment 295673 [details] [review]
goption: Add boxed type for GOptionGroup

This would allow bindings to use _get_option_group() functions, which
would then allow them to use GOption parsing.
Comment 10 Bastien Nocera 2015-01-28 15:59:24 UTC
Created attachment 295675 [details] [review]
goption: Add boxed type for GOptionGroup

This would allow bindings to use _get_option_group() functions, which
would then allow them to use GOption parsing.
Comment 11 Allison Karlitskaya (desrt) 2015-02-11 13:12:40 UTC
Review of attachment 295675 [details] [review]:

Please update the documentation for g_option_context_add_group() and add a (transfer full) annotation there.  Same for g_option_context_set_main_group().  In kind, g_option_context_get_main_group() could use a (transfer none) annotation on its return value.

::: glib/goption.c
@@ +2283,3 @@
+ *
+ * Atomically increments the reference count of @group by one.
+ * This function is MT-safe and may be called from any thread.

!!

@@ +2306,3 @@
+ * If the reference count drops to 0, the @group will be freed.
+ * and all memory allocated by the hash table is released.
+ * This function is MT-safe and may be called from any thread.

!!

::: gobject/gboxed.c
@@ +166,3 @@
 G_DEFINE_BOXED_TYPE (GChecksum, g_checksum, g_checksum_copy, g_checksum_free)
 
+G_DEFINE_BOXED_TYPE (GOptionGroup, g_option_group, g_option_group_ref, g_option_group_free)

I think you wanted _unref here?
Comment 12 Bastien Nocera 2015-02-11 13:51:52 UTC
Created attachment 296598 [details] [review]
goption: Add boxed type for GOptionGroup

This would allow bindings to use _get_option_group() functions, which
would then allow them to use GOption parsing.

This also adds introspection annotations to
g_option_context_add_group(), g_option_context_set_main_group() and
g_option_context_get_main_group().
Comment 13 Allison Karlitskaya (desrt) 2015-02-11 14:21:14 UTC
Review of attachment 296598 [details] [review]:

Looks good to go, but please address the three minor docs issues before pushing.

::: glib/goption.c
@@ +2280,3 @@
+ * @group: a #GOptionGroup
+ *
+ * Atomically increments the reference count of @group by one.

The word "atomic" is still here.  It should be removed.

@@ +2300,3 @@
+ * @group: a #GOptionGroup
+ *
+ * Atomically decrements the reference count of @group by one.

ditto.

@@ +2302,3 @@
+ * Atomically decrements the reference count of @group by one.
+ * If the reference count drops to 0, the @group will be freed.
+ * and all memory allocated by the hash table is released.

this line "and all memory allocated by the hash table is released." looks like it is included by accident.
Comment 14 Bastien Nocera 2015-02-11 14:33:37 UTC
Created attachment 296603 [details] [review]
goption: Add boxed type for GOptionGroup

This would allow bindings to use _get_option_group() functions, which
would then allow them to use GOption parsing.

This also adds introspection annotations to
g_option_context_add_group(), g_option_context_set_main_group() and
g_option_context_get_main_group().
Comment 15 Bastien Nocera 2015-02-11 14:34:08 UTC
Attachment 296603 [details] pushed as 43df97a - goption: Add boxed type for GOptionGroup
Comment 16 Kjell Ahlstedt 2015-02-15 14:44:49 UTC
Shall g_option_group_free be replaced by g_option_group_unref in
glib/glib-autocleanups.h?

When I try to build glibmm with the latest glib from the git repository, I get
the following compile error:

/opt/gnome/include/glib-2.0/glib/glib-autocleanups.h: In function
  ‘void glib_autoptr_cleanup_GOptionGroup(GOptionGroup**)’:
/opt/gnome/include/glib-2.0/glib/glib-autocleanups.h:44:45: error:
  ‘void g_option_group_free(GOptionGroup*)’ is deprecated (declared at
  /opt/gnome/include/glib-2.0/glib/goption.h:368)
  [-Werror=deprecated-declarations]
 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GOptionGroup, g_option_group_free)
                                             ^
I don't know what G_DEFINE_AUTOPTR_CLEANUP_FUNC() does, and I don't know if
replacing g_option_group_free by g_option_group_unref is the right fix, but
it fixes the build error in glibmm.