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 313688 - All GObject classes should use g_type_class_add_private and G_TYPE_INSTANCE_GET_PRIVATE
All GObject classes should use g_type_class_add_private and G_TYPE_INSTANCE_G...
Status: RESOLVED FIXED
Product: rhythmbox
Classification: Other
Component: general
HEAD
Other Linux
: Normal minor
: ---
Assigned To: RhythmBox Maintainers
RhythmBox Maintainers
Depends on:
Blocks:
 
 
Reported: 2005-08-17 03:38 UTC by James "Doc" Livingston
Modified: 2005-11-30 19:02 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch (48.29 KB, patch)
2005-11-22 16:23 UTC, William Jon McCann
none Details | Review
updated patch (47.99 KB, patch)
2005-11-29 17:53 UTC, William Jon McCann
committed Details | Review
installment 2 patch (44.73 KB, patch)
2005-11-30 15:58 UTC, William Jon McCann
committed Details | Review

Description James "Doc" Livingston 2005-08-17 03:38:12 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;
}
Comment 1 William Jon McCann 2005-11-22 16:23:54 UTC
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?
Comment 2 William Jon McCann 2005-11-22 23:43:23 UTC
I'll be offline for most of the week, so, it this looks ok please commit for me.
 Thanks.
Comment 3 William Jon McCann 2005-11-29 17:53:22 UTC
Created attachment 55379 [details] [review]
updated patch
Comment 4 James "Doc" Livingston 2005-11-30 08:47:55 UTC
Thanks, committed to cvs.
Comment 5 William Jon McCann 2005-11-30 15:57:18 UTC
Unfortunately, that was just the first installment.
Comment 6 William Jon McCann 2005-11-30 15:58:41 UTC
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.
Comment 7 James "Doc" Livingston 2005-11-30 16:11:53 UTC
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.
Comment 8 William Jon McCann 2005-11-30 19:02:18 UTC
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.