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 785818 - Replace g_type_class_add_private with G_DEFINE_TYPE_WITH_PRIVATE
Replace g_type_class_add_private with G_DEFINE_TYPE_WITH_PRIVATE
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:52 UTC by Debarshi Ray
Modified: 2021-05-25 12:45 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
rest-proxy-auth: Use G_DEFINE_TYPE_WITH_PRIVATE (1.61 KB, patch)
2017-08-04 12:53 UTC, Debarshi Ray
committed Details | Review
oauth2-proxy: Use G_DEFINE_TYPE_WITH_PRIVATE (1.55 KB, patch)
2017-08-04 12:53 UTC, Debarshi Ray
committed Details | Review

Description Debarshi Ray 2017-08-04 12:52:17 UTC
Modern GObject best practice recommends using G_DEFINE_TYPE_WITH_PRIVATE, G_ADD_PRIVATE, etc. instead of g_type_class_add_private. G_ADD_PRIVATE generates a my_object_get_instance_private method which does the same thing as G_TYPE_INSTANCE_GET_PRIVATE, but is faster and can be used on invalid pointers because it only does pointer arithmetic.

While some of the classes already use G_DEFINE_TYPE_WITH_PRIVATE, some still need to be ported.

In some cases, the private struct of one class is directly accessed by another via a *-private.h header. This is a problem because the my_object_get_instance_private method generated by G_ADD_PRIVATE is only present in the *.c file. One option is to use private get/set accessors instead.
Comment 1 Debarshi Ray 2017-08-04 12:53:40 UTC
Created attachment 356955 [details] [review]
rest-proxy-auth: Use G_DEFINE_TYPE_WITH_PRIVATE
Comment 2 Debarshi Ray 2017-08-04 12:53:55 UTC
Created attachment 356956 [details] [review]
oauth2-proxy: Use G_DEFINE_TYPE_WITH_PRIVATE
Comment 3 Rob Bradford 2017-08-08 15:26:51 UTC
Debarshi, lgtm please commit when you're ready. (splinter isn't letting update that field.)
Comment 4 Debarshi Ray 2017-08-15 17:43:46 UTC
(In reply to Rob Bradford from comment #3)
> Debarshi, lgtm please commit when you're ready. (splinter isn't letting
> update that field.)

Thanks. Pushed to master.

Do you agree with this:

(In reply to Debarshi Ray from comment #0)
> In some cases, the private struct of one class is directly accessed by
> another via a *-private.h header. This is a problem because the
> my_object_get_instance_private method generated by G_ADD_PRIVATE is only
> present in the *.c file. One option is to use private get/set accessors
> instead.

If you do, then I will add the private get/set accessors and convert the remaining classes.
Comment 5 André Klapper 2021-05-25 12:45:55 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.