GNOME Bugzilla – Bug 313688
All GObject classes should use g_type_class_add_private and G_TYPE_INSTANCE_GET_PRIVATE
Last modified: 2005-11-30 19:02:18 UTC
All our classes should use g_type_class_add_private and G_TYPE_INSTANCE_GET_PRIVATE to handle private storage, rather than doing it manually. The big advantage is that this will allocate the private storage fora class and all parent classes in the same memory block as the public structures of an object - which helps to reduce memory fragmentation. This will probably break patches so they no longer apply cleanly, so we should probably do this piece by piece as we commit changes for a class that will make other patches not apply cleanly to that class anyway. For reference the example given in the gtk docs is below. typedef struct _MyObjectPrivate MyObjectPrivate; struct _MyObjectPrivate { int some_field; }; #define MY_OBJECT_GET_PRIVATE(o) \ (G_TYPE_INSTANCE_GET_PRIVATE ((o), MY_TYPE_OBJECT, MyObjectPrivate)) static void my_object_class_init (MyObjectClass *klass) { g_type_class_add_private (klass, sizeof (MyObjectPrivate)); } static int my_object_get_some_field (MyObject *my_object) { MyObjectPrivate *priv = MY_OBJECT_GET_PRIVATE (my_object); return priv->some_field; }
Created attachment 55090 [details] [review] patch This fixes all classes in sources, widgets, and rhythdb. Very few patches will touch the areas of the code that this changes so I don't think this will break many patches. Is this OK to commit?
I'll be offline for most of the week, so, it this looks ok please commit for me. Thanks.
Created attachment 55379 [details] [review] updated patch
Thanks, committed to cvs.
Unfortunately, that was just the first installment.
Created attachment 55428 [details] [review] installment 2 patch This should be all of it now except metadata/sj-metadata-musicbrainz.c which we should probably fix in SJ.
That looks fine to commit too. With regards to the SJ code, there was some talk of breaking metadata lookup and extraction out into a "libjuicer"; I should probably have another chat with Ross and take a look at doing this sometime.
Committed. 2005-11-30 William Jon McCann <mccann@jhu.edu> * shell/rb-tray-icon.c (rb_tray_icon_class_init) (rb_tray_icon_init, rb_tray_icon_finalize): * shell/rb-statusbar.c (rb_statusbar_class_init) (rb_statusbar_init, rb_statusbar_finalize): * shell/rb-source-header.c (rb_source_header_class_init) (rb_source_header_init, rb_source_header_finalize): * shell/rb-shell.c (rb_shell_class_init, rb_shell_init) (rb_shell_finalize): * shell/rb-shell-preferences.c (rb_shell_preferences_class_init) (rb_shell_preferences_init, rb_shell_preferences_finalize): * shell/rb-shell-player.c (rb_shell_player_class_init) (rb_shell_player_init, rb_shell_player_finalize): * shell/rb-shell-clipboard.c (rb_shell_clipboard_class_init) (rb_shell_clipboard_init, rb_shell_clipboard_finalize): * shell/rb-playlist-manager.c (rb_playlist_manager_class_init) (rb_playlist_manager_init, rb_playlist_manager_finalize): * shell/rb-play-order.c (rb_play_order_class_init) (rb_play_order_init, rb_play_order_finalize): * shell/rb-play-order-shuffle.c (rb_shuffle_play_order_class_init) (rb_shuffle_play_order_init, rb_shuffle_play_order_finalize): * shell/rb-play-order-random.c (rb_random_play_order_class_init) (rb_random_play_order_init, rb_random_play_order_finalize): * shell/rb-history.c (rb_history_class_init, rb_history_init) (rb_history_finalize): * shell/rb-commander.c (rb_commander_class_init) (rb_commander_init, rb_commander_finalize): * shell/rb-audioscrobbler.c (rb_audioscrobbler_class_init) (rb_audioscrobbler_init, rb_audioscrobbler_finalize): * remote/bonobo/rb-remote-bonobo.c (rb_remote_bonobo_class_init) (rb_remote_bonobo_init, rb_remote_bonobo_finalize): * podcast/rb-podcast-properties-dialog.c (rb_podcast_properties_dialog_class_init) (rb_podcast_properties_dialog_init) (rb_podcast_properties_dialog_finalize): * podcast/rb-podcast-manager.c (rb_podcast_manager_class_init) (rb_podcast_manager_init, rb_podcast_manager_finalize): * podcast/rb-new-podcast-dialog.c (rb_new_podcast_dialog_class_init) (rb_new_podcast_dialog_init, rb_new_podcast_dialog_finalize): * podcast/rb-feed-podcast-properties-dialog.c (rb_feed_podcast_properties_dialog_class_init) (rb_feed_podcast_properties_dialog_init) (rb_feed_podcast_properties_dialog_finalize): * metadata/rb-metadata-gst.c (rb_metadata_class_init) (rb_metadata_init, rb_metadata_finalize): * iradio/rb-station-properties-dialog.c (rb_station_properties_dialog_class_init) (rb_station_properties_dialog_init) (rb_station_properties_dialog_finalize): * daapsharing/rb-daap-share.c (rb_daap_share_class_init) (rb_daap_share_init, rb_daap_share_dispose): Use g_type_class_add_private in all classes. Closes bug 313688.