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 785811 - Support autocleanups for exported types
Support autocleanups for exported types
Status: RESOLVED OBSOLETE
Product: librest
Classification: Platform
Component: other
git master
Other All
: Normal normal
: ---
Assigned To: librest-maint
librest-maint
Depends on:
Blocks:
 
 
Reported: 2017-08-04 12:21 UTC by Debarshi Ray
Modified: 2021-06-02 15:04 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
rest-proxy: Use G_DECLARE_DERIVABLE_TYPE (2.07 KB, patch)
2017-08-04 12:33 UTC, Debarshi Ray
committed Details | Review
rest-proxy-call: Use G_DECLARE_DERIVABLE_TYPE (2.16 KB, patch)
2017-08-04 12:34 UTC, Debarshi Ray
committed Details | Review
rest-xml-parser: Use G_DECLARE_DERIVABLE_TYPE (1.58 KB, patch)
2017-08-04 12:35 UTC, Debarshi Ray
committed Details | Review
oauth-proxy-call: Use G_DECLARE_DERIVABLE_TYPE (1.75 KB, patch)
2017-08-04 12:36 UTC, Debarshi Ray
committed Details | Review
oauth2-proxy-call: Use G_DECLARE_DERIVABLE_TYPE (1.73 KB, patch)
2017-08-04 12:37 UTC, Debarshi Ray
committed Details | Review
lastfm-proxy-call: Use G_DECLARE_DERIVABLE_TYPE (1.76 KB, patch)
2017-08-04 12:39 UTC, Debarshi Ray
committed Details | Review

Description Debarshi Ray 2017-08-04 12:21:49 UTC
GLib 2.44.0 added some features to:

(a) Make it easier to use __attribute__((cleanup)) on compilers that support it (ie. gcc and clang).

A type has to define its cleanup function using G_DEFINE_AUTOPTR_CLEANUP_FUNC(), G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC() or G_DEFINE_AUTO_CLEANUP_FREE_FUNC(). Note that defining the cleanup function doesn't add any dependency on __attribute__((cleanup)).

(b) Reduce the amount of GObject boilerplate using the G_DECLARE_FINAL_TYPE(), G_DECLARE_DERIVABLE_TYPE() or G_DECLARE_INTERFACE() macros.

These declaration macros also define the cleanup function for the GObject (ie. g_object_unref) using G_DEFINE_AUTOPTR_CLEANUP_FUNC(). However, that only works if the parent type also defined a cleanup function.


Therefore, users of librest that want to use either:
(a) g_auto, g_autofree and g_autoptr with the librest types, or
(b) G_DECLARE_* to declare sub-classes of the librest types
... require the cleanup functions to be specified.


The easiest option is to use G_DECLARE_* as much as possible in librest itself.
Comment 1 Debarshi Ray 2017-08-04 12:33:21 UTC
Created attachment 356947 [details] [review]
rest-proxy: Use G_DECLARE_DERIVABLE_TYPE
Comment 2 Debarshi Ray 2017-08-04 12:34:35 UTC
Created attachment 356948 [details] [review]
rest-proxy-call: Use G_DECLARE_DERIVABLE_TYPE
Comment 3 Debarshi Ray 2017-08-04 12:35:33 UTC
Created attachment 356949 [details] [review]
rest-xml-parser: Use G_DECLARE_DERIVABLE_TYPE
Comment 4 Debarshi Ray 2017-08-04 12:36:32 UTC
Created attachment 356950 [details] [review]
oauth-proxy-call: Use G_DECLARE_DERIVABLE_TYPE
Comment 5 Debarshi Ray 2017-08-04 12:37:23 UTC
Created attachment 356951 [details] [review]
oauth2-proxy-call: Use G_DECLARE_DERIVABLE_TYPE
Comment 6 Debarshi Ray 2017-08-04 12:39:31 UTC
Created attachment 356952 [details] [review]
lastfm-proxy-call: Use G_DECLARE_DERIVABLE_TYPE
Comment 7 Rob Bradford 2017-08-08 15:33:22 UTC
Hi Debarshi, good clean-up. lgtm, please merge. Thanks.
Comment 8 Debarshi Ray 2017-08-15 17:40:41 UTC
Thanks for the review, Rob. Pushed them to master.
Comment 9 Debarshi Ray 2017-08-15 17:49:11 UTC
Some classes like RestProxyAuth and OAuth2Proxy can't be ported to G_DECLARE_DERIVABLE_TYPE without breaking ABI. Is that allowed in master? If not then we'll have to manually add the autocleanups.

Even if we can break ABI, it might be nice to first add the autocleanups and then use G_DECLARE_* so that the patches can be easily cherry-picked to librest-0-7, if needed.

What do you think?
Comment 10 André Klapper 2021-05-25 12:45:54 UTC
GNOME is going to shut down bugzilla.gnome.org in favor of gitlab.gnome.org.
As part of that, we are mass-closing older open tickets in bugzilla.gnome.org
which have not seen updates for a longer time (resources are unfortunately
quite limited so not every ticket can get handled).

If you can still reproduce the situation described in this ticket in a recent
and supported software version, then please follow
  https://wiki.gnome.org/GettingInTouch/BugReportingGuidelines
and create a new enhancement request ticket at
  https://gitlab.gnome.org/GNOME/librest/-/issues/

Thank you for your understanding and your help.
Comment 11 Debarshi Ray 2021-06-02 15:04:58 UTC
Continued at:
https://gitlab.gnome.org/GNOME/librest/-/merge_requests/5