GNOME Bugzilla – Bug 785818
Replace g_type_class_add_private with G_DEFINE_TYPE_WITH_PRIVATE
Last modified: 2021-05-25 12:45:55 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.
Created attachment 356955 [details] [review] rest-proxy-auth: Use G_DEFINE_TYPE_WITH_PRIVATE
Created attachment 356956 [details] [review] oauth2-proxy: Use G_DEFINE_TYPE_WITH_PRIVATE
Debarshi, lgtm please commit when you're ready. (splinter isn't letting update that field.)
(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.
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.