diff -u -p -r1.53 rb-podcast-manager.c
--- podcast/rb-podcast-manager.c	23 Jul 2006 16:01:31 -0000	1.53
+++ podcast/rb-podcast-manager.c	25 Jul 2006 01:42:56 -0000
@@ -391,9 +391,13 @@ rb_podcast_manager_new (RhythmDB *db)
 }
 
 void
-rb_podcast_manager_download_entry (RBPodcastManager *pd, RhythmDBEntry *entry)
+rb_podcast_manager_download_entry (RBPodcastManager *pd,
+				   RhythmDBEntry *entry)
 {
 	gulong status;
+
+	g_return_if_fail (RB_IS_PODCAST_MANAGER (pd));
+
 	if (entry == NULL)
 		return;
 
@@ -438,10 +442,13 @@ void
 rb_podcast_manager_start_sync (RBPodcastManager *pd)
 {
 	gint next_time;
+
+	g_return_if_fail (RB_IS_PODCAST_MANAGER (pd));
+
 	if (pd->priv->next_time > 0) {
 		next_time = pd->priv->next_time;
 	} else {
-		next_time = eel_gconf_get_integer(CONF_STATE_PODCAST_DOWNLOAD_NEXT_TIME);
+		next_time = eel_gconf_get_integer (CONF_STATE_PODCAST_DOWNLOAD_NEXT_TIME);
 	}
 
 	if (next_time > 0) {
@@ -475,7 +482,11 @@ rb_podcast_manager_sync_head_cb (gpointe
 void
 rb_podcast_manager_update_feeds (RBPodcastManager *pd)
 {
-	GtkTreeModel* query_model = GTK_TREE_MODEL (rhythmdb_query_model_new_empty(pd->priv->db));
+	GtkTreeModel *query_model;
+
+	g_return_if_fail (RB_IS_PODCAST_MANAGER (pd));
+
+	query_model = GTK_TREE_MODEL (rhythmdb_query_model_new_empty (pd->priv->db));
 
 	rhythmdb_do_full_query (pd->priv->db,
 				RHYTHMDB_QUERY_RESULTS (query_model),
@@ -1238,9 +1249,10 @@ rb_podcast_manager_db_entry_deleted_cb (
 		gnome_vfs_remove_directory (dir_name);
 
 	} else if (type == RHYTHMDB_ENTRY_TYPE_PODCAST_FEED) {
-		GtkTreeModel* query_model = GTK_TREE_MODEL (rhythmdb_query_model_new_empty(pd->priv->db));
+		GtkTreeModel *query_model;
 		GtkTreeIter iter;
 
+		query_model = GTK_TREE_MODEL (rhythmdb_query_model_new_empty (pd->priv->db));
 		rhythmdb_do_full_query (pd->priv->db,
 					RHYTHMDB_QUERY_RESULTS (query_model),
                 	                RHYTHMDB_QUERY_PROP_EQUALS,
@@ -1263,6 +1275,8 @@ rb_podcast_manager_db_entry_deleted_cb (
 
 			rhythmdb_commit (pd->priv->db);
 		}
+
+		g_object_unref (query_model);
 	}
 }
 
diff -u -p -r1.50 rhythmdb-property-model.c
--- rhythmdb/rhythmdb-property-model.c	23 Jul 2006 16:02:56 -0000	1.50
+++ rhythmdb/rhythmdb-property-model.c	25 Jul 2006 01:42:57 -0000
@@ -288,6 +288,52 @@ _add_entry_cb (GtkTreeModel *model,
 }
 
 static void
+rhythmdb_property_model_set_query_model_internal (RhythmDBPropertyModel *model,
+						  RhythmDBQueryModel    *query_model)
+{
+	if (model->priv->query_model != NULL) {
+		g_signal_handlers_disconnect_by_func (model->priv->query_model,
+						      G_CALLBACK (rhythmdb_property_model_row_inserted_cb),
+						      model);
+		g_signal_handlers_disconnect_by_func (model->priv->query_model,
+						      G_CALLBACK (rhythmdb_property_model_entry_removed_cb),
+						      model);
+		g_signal_handlers_disconnect_by_func (model->priv->query_model,
+						      G_CALLBACK (rhythmdb_property_model_prop_changed_cb),
+						      model);
+		g_hash_table_foreach_remove (model->priv->entries, (GHRFunc)_remove_entry_cb, model);
+
+		g_object_unref (model->priv->query_model);
+	}
+
+	model->priv->query_model = query_model;
+	g_assert (rhythmdb_property_model_iter_n_children (GTK_TREE_MODEL (model), NULL) == 1);
+
+	if (model->priv->query_model != NULL) {
+		g_object_ref (model->priv->query_model);
+
+		g_signal_connect_object (model->priv->query_model,
+					 "row_inserted",
+					 G_CALLBACK (rhythmdb_property_model_row_inserted_cb),
+					 model,
+					 0);
+		g_signal_connect_object (model->priv->query_model,
+					 "post-entry-delete",
+					 G_CALLBACK (rhythmdb_property_model_entry_removed_cb),
+					 model,
+					 0);
+		g_signal_connect_object (model->priv->query_model,
+					 "entry-prop-changed",
+					 G_CALLBACK (rhythmdb_property_model_prop_changed_cb),
+					 model,
+					 0);
+		gtk_tree_model_foreach (GTK_TREE_MODEL (model->priv->query_model),
+					(GtkTreeModelForeachFunc)_add_entry_cb,
+					model);
+	}
+}
+
+static void
 rhythmdb_property_model_set_property (GObject *object,
 				      guint prop_id,
 				      const GValue *value,
@@ -297,10 +343,8 @@ rhythmdb_property_model_set_property (GO
 
 	switch (prop_id) {
 	case PROP_RHYTHMDB:
-	{
 		model->priv->db = g_value_get_object (value);
 		break;
-	}
 	case PROP_PROP:
 		model->priv->propid = g_value_get_int (value);
 		switch (model->priv->propid) {
@@ -326,48 +370,8 @@ rhythmdb_property_model_set_property (GO
 		}
 		break;
 	case PROP_QUERY_MODEL:
-	{
-		if (model->priv->query_model) {
-			g_signal_handlers_disconnect_by_func (G_OBJECT (model->priv->query_model),
-							      G_CALLBACK (rhythmdb_property_model_row_inserted_cb),
-							      model);
-			g_signal_handlers_disconnect_by_func (G_OBJECT (model->priv->query_model),
-							      G_CALLBACK (rhythmdb_property_model_entry_removed_cb),
-							      model);
-			g_signal_handlers_disconnect_by_func (G_OBJECT (model->priv->query_model),
-							      G_CALLBACK (rhythmdb_property_model_prop_changed_cb),
-							      model);
-			g_hash_table_foreach_remove (model->priv->entries, (GHRFunc)_remove_entry_cb, model);
-			g_object_unref (model->priv->query_model);
-		}
-
-		model->priv->query_model = g_value_get_object (value);
-		g_assert (rhythmdb_property_model_iter_n_children (GTK_TREE_MODEL (model), NULL) == 1);
-
-		if (model->priv->query_model) {
-			g_object_ref (model->priv->query_model);
-
-			g_signal_connect_object (G_OBJECT (model->priv->query_model),
-						 "row_inserted",
-						 G_CALLBACK (rhythmdb_property_model_row_inserted_cb),
-						 model,
-						 0);
-			g_signal_connect_object (G_OBJECT (model->priv->query_model),
-						 "post-entry-delete",
-						 G_CALLBACK (rhythmdb_property_model_entry_removed_cb),
-						 model,
-						 0);
-			g_signal_connect_object (G_OBJECT (model->priv->query_model),
-						 "entry-prop-changed",
-						 G_CALLBACK (rhythmdb_property_model_prop_changed_cb),
-						 model,
-						 0);
-			gtk_tree_model_foreach (GTK_TREE_MODEL (model->priv->query_model),
-						(GtkTreeModelForeachFunc)_add_entry_cb,
-						model);
-		}
+		rhythmdb_property_model_set_query_model_internal (model, g_value_get_object (value));
 		break;
-	}
 	default:
 		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
 		break;
@@ -445,8 +449,9 @@ rhythmdb_property_model_finalize (GObjec
 
 	g_hash_table_destroy (model->priv->entries);
 
-	if (model->priv->query_model)
-		g_object_unref (G_OBJECT (model->priv->query_model));
+	if (model->priv->query_model != NULL) {
+		g_object_unref (model->priv->query_model);
+	}
 
 	G_OBJECT_CLASS (rhythmdb_property_model_parent_class)->finalize (object);
 }
@@ -990,7 +995,7 @@ rhythmdb_property_model_drag_data_get (R
 					    &is_all, -1);
 		gtk_tree_path_free (path);
 		if (is_all) {
-			g_object_set (G_OBJECT (query_model),
+			g_object_set (query_model,
 				      "base-model", model->priv->query_model,
 				      NULL);
 		} else {
@@ -1022,7 +1027,7 @@ rhythmdb_property_model_drag_data_get (R
  				g_free (name);
  			}
 
-			g_object_set (G_OBJECT (query_model),
+			g_object_set (query_model,
 				      "query", subquery,
 				      "base-model", model->priv->query_model,
 				      NULL);
diff -u -p -r1.140 rhythmdb-query-model.c
--- rhythmdb/rhythmdb-query-model.c	24 Jul 2006 01:34:08 -0000	1.140
+++ rhythmdb/rhythmdb-query-model.c	25 Jul 2006 01:43:01 -0000
@@ -199,7 +199,8 @@ struct RhythmDBQueryModelPrivate
 	GDestroyNotify sort_data_destroy;
 	gboolean sort_reverse;
 
-	GPtrArray *query, *original_query;
+	GPtrArray *query;
+	GPtrArray *original_query;
 
 	guint stamp;
 
@@ -425,6 +426,36 @@ rhythmdb_query_model_drag_dest_init (RbT
 }
 
 static void
+rhythmdb_query_model_set_query_internal (RhythmDBQueryModel *model,
+					GPtrArray          *query)
+{
+	if (query == model->priv->original_query)
+		return;
+
+	rhythmdb_query_free (model->priv->query);
+	rhythmdb_query_free (model->priv->original_query);
+
+	model->priv->query = rhythmdb_query_copy (query);
+	model->priv->original_query = rhythmdb_query_copy (model->priv->query);
+	rhythmdb_query_preprocess (model->priv->db, model->priv->query);
+
+	/* if the query contains time-relative criteria, re-run it periodically.
+	 * currently it's just every half hour, but perhaps it could be smarter.
+	 */
+	if (rhythmdb_query_is_time_relative (model->priv->db, model->priv->query)) {
+		if (model->priv->query_reapply_timeout_id == 0) {
+			model->priv->query_reapply_timeout_id =
+				g_timeout_add (1 * 60 * 1000,
+					       (GSourceFunc) rhythmdb_query_model_reapply_query_cb,
+					       model);
+		}
+	} else if (model->priv->query_reapply_timeout_id) {
+		g_source_remove (model->priv->query_reapply_timeout_id);
+		model->priv->query_reapply_timeout_id = 0;
+	}
+}
+
+static void
 rhythmdb_query_model_set_property (GObject *object,
 				   guint prop_id,
 				   const GValue *value,
@@ -432,36 +463,12 @@ rhythmdb_query_model_set_property (GObje
 {
 	RhythmDBQueryModel *model = RHYTHMDB_QUERY_MODEL (object);
 
-	switch (prop_id)
-	{
+	switch (prop_id) {
 	case PROP_RHYTHMDB:
 		model->priv->db = g_value_get_object (value);
 		break;
 	case PROP_QUERY:
-		if (g_value_get_pointer (value) == model->priv->original_query)
-			break;
-
-		rhythmdb_query_free (model->priv->query);
-		rhythmdb_query_free (model->priv->original_query);
-
-		model->priv->query = rhythmdb_query_copy (g_value_get_pointer (value));
-		model->priv->original_query = rhythmdb_query_copy (model->priv->query);
-		rhythmdb_query_preprocess (model->priv->db, model->priv->query);
-
-		/* if the query contains time-relative criteria, re-run it periodically.
-		 * currently it's just every half hour, but perhaps it could be smarter.
-		 */
-		if (rhythmdb_query_is_time_relative (model->priv->db, model->priv->query)) {
-			if (model->priv->query_reapply_timeout_id == 0) {
-				model->priv->query_reapply_timeout_id =
-					g_timeout_add (1 * 60 * 1000,
-						       (GSourceFunc) rhythmdb_query_model_reapply_query_cb,
-						       model);
-			}
-		} else if (model->priv->query_reapply_timeout_id) {
-			g_source_remove (model->priv->query_reapply_timeout_id);
-			model->priv->query_reapply_timeout_id = 0;
-		}
+		rhythmdb_query_model_set_query_internal (model, g_value_get_pointer (value));
 		break;
 	case PROP_SORT_FUNC:
 		model->priv->sort_func = g_value_get_pointer (value);
@@ -506,8 +513,7 @@ rhythmdb_query_model_get_property (GObje
 {
 	RhythmDBQueryModel *model = RHYTHMDB_QUERY_MODEL (object);
 
-	switch (prop_id)
-	{
+	switch (prop_id) {
 	case PROP_RHYTHMDB:
 		g_value_set_object (value, model->priv->db);
 		break;
@@ -704,23 +710,23 @@ rhythmdb_query_model_chain (RhythmDBQuer
 {
 	rb_debug ("query model %p chaining to base model %p", model, base);
 
-	if (model->priv->base_model) {
-		g_signal_handlers_disconnect_by_func (G_OBJECT (model->priv->base_model),
+	if (model->priv->base_model != NULL) {
+		g_signal_handlers_disconnect_by_func (model->priv->base_model,
 						      G_CALLBACK (rhythmdb_query_model_base_row_inserted),
 						      model);
-		g_signal_handlers_disconnect_by_func (G_OBJECT (model->priv->base_model),
+		g_signal_handlers_disconnect_by_func (model->priv->base_model,
 						      G_CALLBACK (rhythmdb_query_model_base_row_deleted),
 						      model);
-		g_signal_handlers_disconnect_by_func (G_OBJECT (model->priv->base_model),
+		g_signal_handlers_disconnect_by_func (model->priv->base_model,
 						      G_CALLBACK (rhythmdb_query_model_base_non_entry_dropped),
 						      model);
-		g_signal_handlers_disconnect_by_func (G_OBJECT (model->priv->base_model),
+		g_signal_handlers_disconnect_by_func (model->priv->base_model,
 						      G_CALLBACK (rhythmdb_query_model_base_complete),
 						      model);
-		g_signal_handlers_disconnect_by_func (G_OBJECT (model->priv->base_model),
+		g_signal_handlers_disconnect_by_func (model->priv->base_model,
 						      G_CALLBACK (rhythmdb_query_model_base_rows_reordered),
 						      model);
-		g_signal_handlers_disconnect_by_func (G_OBJECT (model->priv->base_model),
+		g_signal_handlers_disconnect_by_func (model->priv->base_model,
 						      G_CALLBACK (rhythmdb_query_model_base_entry_removed),
 						      model);
 		g_object_unref (model->priv->base_model);
@@ -728,32 +734,32 @@ rhythmdb_query_model_chain (RhythmDBQuer
 
 	model->priv->base_model = base;
 
-	if (model->priv->base_model) {
+	if (model->priv->base_model != NULL) {
 		g_object_ref (model->priv->base_model);
 
 		g_assert (model->priv->base_model->priv->db == model->priv->db);
 
-		g_signal_connect_object (G_OBJECT (model->priv->base_model),
+		g_signal_connect_object (model->priv->base_model,
 					 "row-inserted",
 					 G_CALLBACK (rhythmdb_query_model_base_row_inserted),
 					 model, 0);
-		g_signal_connect_object (G_OBJECT (model->priv->base_model),
+		g_signal_connect_object (model->priv->base_model,
 					 "row-deleted",
 					 G_CALLBACK (rhythmdb_query_model_base_row_deleted),
 					 model, 0);
-		g_signal_connect_object (G_OBJECT (model->priv->base_model),
+		g_signal_connect_object (model->priv->base_model,
 					 "non-entry-dropped",
 					 G_CALLBACK (rhythmdb_query_model_base_non_entry_dropped),
 					 model, 0);
-		g_signal_connect_object (G_OBJECT (model->priv->base_model),
+		g_signal_connect_object (model->priv->base_model,
 					 "complete",
 					 G_CALLBACK (rhythmdb_query_model_base_complete),
 					 model, 0);
-		g_signal_connect_object (G_OBJECT (model->priv->base_model),
+		g_signal_connect_object (model->priv->base_model,
 					 "rows-reordered",
 					 G_CALLBACK (rhythmdb_query_model_base_rows_reordered),
 					 model, 0);
-		g_signal_connect_object (G_OBJECT (model->priv->base_model),
+		g_signal_connect_object (model->priv->base_model,
 					 "entry-removed",
 					 G_CALLBACK (rhythmdb_query_model_base_entry_removed),
 					 model, 0);
diff -u -p -r1.33 rhythmdb-query-model.h
--- rhythmdb/rhythmdb-query-model.h	14 Jul 2006 12:29:29 -0000	1.33
+++ rhythmdb/rhythmdb-query-model.h	25 Jul 2006 01:43:03 -0000
@@ -1,4 +1,5 @@
-/*
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
  *  arch-tag: Header for RhythmDB query result GtkTreeModel impl.
  *
  *  Copyright (C) 2003 Colin Walters <walters@rhythmbox.org>
@@ -80,85 +81,102 @@ typedef struct
 
 } RhythmDBQueryModelClass;
 
-GType			rhythmdb_query_model_get_type	(void);
-
-RhythmDBQueryModel *	rhythmdb_query_model_new	(RhythmDB *db, GPtrArray *query,
-							 GCompareDataFunc sort_func,
-							 gpointer sort_data,
-							 GDestroyNotify sort_data_destroy,
-							 gboolean sort_reverse);
-
-RhythmDBQueryModel *	rhythmdb_query_model_new_empty	(RhythmDB *db);
-
-void			rhythmdb_query_model_chain	(RhythmDBQueryModel *child,
-							 RhythmDBQueryModel *base,
-							 gboolean import_entries);
-
-void			rhythmdb_query_model_add_entry	(RhythmDBQueryModel *model, RhythmDBEntry *entry, gint index);
-
-gboolean		rhythmdb_query_model_remove_entry	(RhythmDBQueryModel *model, RhythmDBEntry *entry);
-
-void			rhythmdb_query_model_move_entry (RhythmDBQueryModel *model, RhythmDBEntry *entry, gint index);
-
-guint64	rhythmdb_query_model_get_size	(RhythmDBQueryModel *model);
-
-long			rhythmdb_query_model_get_duration(RhythmDBQueryModel *model);
+GType			rhythmdb_query_model_get_type		(void);
 
-gboolean		rhythmdb_query_model_entry_to_iter(RhythmDBQueryModel *model,
-							   RhythmDBEntry *entry,
-							   GtkTreeIter *iter);
+RhythmDBQueryModel *	rhythmdb_query_model_new		(RhythmDB *db,
+								 GPtrArray *query,
+								 GCompareDataFunc sort_func,
+								 gpointer sort_data,
+								 GDestroyNotify sort_data_destroy,
+								 gboolean sort_reverse);
+
+RhythmDBQueryModel *	rhythmdb_query_model_new_empty		(RhythmDB *db);
+
+void			rhythmdb_query_model_chain		(RhythmDBQueryModel *child,
+								 RhythmDBQueryModel *base,
+								 gboolean import_entries);
+
+void			rhythmdb_query_model_add_entry		(RhythmDBQueryModel *model,
+								 RhythmDBEntry *entry,
+								 gint index);
 
-gboolean		rhythmdb_query_model_has_pending_changes (RhythmDBQueryModel *model);
-
-RhythmDBEntry *		rhythmdb_query_model_tree_path_to_entry(RhythmDBQueryModel *model,
-								GtkTreePath *path);
-RhythmDBEntry *		rhythmdb_query_model_iter_to_entry(RhythmDBQueryModel *model,
-							   GtkTreeIter *entry_iter);
-RhythmDBEntry *		rhythmdb_query_model_get_next_from_entry(RhythmDBQueryModel *model,
+gboolean		rhythmdb_query_model_remove_entry	(RhythmDBQueryModel *model,
 								 RhythmDBEntry *entry);
-RhythmDBEntry *		rhythmdb_query_model_get_previous_from_entry(RhythmDBQueryModel *model,
-								     RhythmDBEntry *entry);
-char *			rhythmdb_query_model_compute_status_normal (RhythmDBQueryModel *model,
-								    const char *singular,
-								    const char *plural);
 
-void			rhythmdb_query_model_set_sort_order (RhythmDBQueryModel *model,
-							     GCompareDataFunc sort_func,
-							     gpointer sort_data,
-							     GDestroyNotify sort_data_destroy,
-							     gboolean sort_reverse);
+void			rhythmdb_query_model_move_entry 	(RhythmDBQueryModel *model,
+								 RhythmDBEntry *entry,
+								 gint index);
+
+guint64 	        rhythmdb_query_model_get_size		(RhythmDBQueryModel *model);
+
+long			rhythmdb_query_model_get_duration 	(RhythmDBQueryModel *model);
+
+gboolean		rhythmdb_query_model_entry_to_iter	(RhythmDBQueryModel *model,
+								 RhythmDBEntry *entry,
+								 GtkTreeIter *iter);
+
+gboolean		rhythmdb_query_model_has_pending_changes	(RhythmDBQueryModel *model);
+
+RhythmDBEntry *		rhythmdb_query_model_tree_path_to_entry	(RhythmDBQueryModel *model,
+								 GtkTreePath *path);
+RhythmDBEntry *		rhythmdb_query_model_iter_to_entry	(RhythmDBQueryModel *model,
+								 GtkTreeIter *entry_iter);
+RhythmDBEntry *		rhythmdb_query_model_get_next_from_entry 	(RhythmDBQueryModel *model,
+									 RhythmDBEntry *entry);
+RhythmDBEntry *		rhythmdb_query_model_get_previous_from_entry	(RhythmDBQueryModel *model,
+									 RhythmDBEntry *entry);
+char *			rhythmdb_query_model_compute_status_normal	(RhythmDBQueryModel *model,
+									 const char *singular,
+									 const char *plural);
+
+void			rhythmdb_query_model_set_sort_order	(RhythmDBQueryModel *model,
+								 GCompareDataFunc sort_func,
+								 gpointer sort_data,
+								 GDestroyNotify sort_data_destroy,
+								 gboolean sort_reverse);
 
-void			rhythmdb_query_model_reapply_query (RhythmDBQueryModel *model, gboolean filter);
+void			rhythmdb_query_model_reapply_query	(RhythmDBQueryModel *model,
+								 gboolean filter);
 
-gint 			rhythmdb_query_model_location_sort_func (RhythmDBEntry *a, RhythmDBEntry *b,
+gint 			rhythmdb_query_model_location_sort_func (RhythmDBEntry *a,
+                                                                 RhythmDBEntry *b,
 								 gpointer data);
 
-gint 			rhythmdb_query_model_string_sort_func (RhythmDBEntry *a, RhythmDBEntry *b,
-							       gpointer data);
+gint 			rhythmdb_query_model_string_sort_func	(RhythmDBEntry *a,
+								 RhythmDBEntry *b,
+								 gpointer data);
 
-gint 			rhythmdb_query_model_title_sort_func (RhythmDBEntry *a, RhythmDBEntry *b,
-							      gpointer data);
+gint 			rhythmdb_query_model_title_sort_func	(RhythmDBEntry *a,
+								 RhythmDBEntry *b,
+								 gpointer data);
 
-gint 			rhythmdb_query_model_album_sort_func (RhythmDBEntry *a, RhythmDBEntry *b,
-							      gpointer data);
+gint 			rhythmdb_query_model_album_sort_func	(RhythmDBEntry *a,
+								 RhythmDBEntry *b,
+								 gpointer data);
 
-gint 			rhythmdb_query_model_artist_sort_func (RhythmDBEntry *a, RhythmDBEntry *b,
-							       gpointer data);
+gint 			rhythmdb_query_model_artist_sort_func	(RhythmDBEntry *a,
+								 RhythmDBEntry *b,
+								 gpointer data);
 
-gint 			rhythmdb_query_model_genre_sort_func (RhythmDBEntry *a, RhythmDBEntry *b,
-							      gpointer data);
+gint 			rhythmdb_query_model_genre_sort_func	(RhythmDBEntry *a,
+								 RhythmDBEntry *b,
+								 gpointer data);
 
-gint 			rhythmdb_query_model_track_sort_func (RhythmDBEntry *a, RhythmDBEntry *b,
-							      gpointer data);
+gint 			rhythmdb_query_model_track_sort_func	(RhythmDBEntry *a,
+								 RhythmDBEntry *b,
+								 gpointer data);
 
-gint 			rhythmdb_query_model_double_ceiling_sort_func (RhythmDBEntry *a, RhythmDBEntry *b,
+gint 			rhythmdb_query_model_double_ceiling_sort_func (RhythmDBEntry *a,
+                                                                       RhythmDBEntry *b,
 								       gpointer data);
 
-gint 			rhythmdb_query_model_ulong_sort_func (RhythmDBEntry *a, RhythmDBEntry *b,
-							      gpointer data);
+gint 			rhythmdb_query_model_ulong_sort_func	(RhythmDBEntry *a,
+								 RhythmDBEntry *b,
+								 gpointer data);
 
-gint 			rhythmdb_query_model_date_sort_func (RhythmDBEntry *a, RhythmDBEntry *b,
-							     gpointer data);
+gint 			rhythmdb_query_model_date_sort_func	(RhythmDBEntry *a,
+								 RhythmDBEntry *b,
+								 gpointer data);
 G_END_DECLS
 
 #endif /* __RHYTHMDB_QUERY_MODEL_H */
diff -u -p -r1.16 rb-browser-source.c
--- sources/rb-browser-source.c	23 Jul 2006 16:04:44 -0000	1.16
+++ sources/rb-browser-source.c	25 Jul 2006 01:43:09 -0000
@@ -132,6 +132,8 @@ struct RBBrowserSourcePrivate
 	guint state_paned_notify_id;
 	guint state_browser_notify_id;
 	guint state_sorting_notify_id;
+
+	gboolean dispose_has_run;
 };
 
 #define RB_BROWSER_SOURCE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), RB_TYPE_BROWSER_SOURCE, RBBrowserSourcePrivate))
@@ -246,18 +248,25 @@ rb_browser_source_dispose (GObject *obje
 	RBBrowserSource *source;
 	source = RB_BROWSER_SOURCE (object);
 
-	if (source->priv->db) {
+	if (source->priv->dispose_has_run) {
+		/* If dispose did already run, return. */
+		return;
+	}
+	/* Make sure dispose does not run twice. */
+	source->priv->dispose_has_run = TRUE;
+
+	if (source->priv->db != NULL) {
 		g_object_unref (source->priv->db);
 		source->priv->db = NULL;
 	}
 
-	if (source->priv->search_text) {
+	if (source->priv->search_text != NULL) {
 		g_free (source->priv->search_text);
 		source->priv->search_text = NULL;
 	}
 
-	if (source->priv->cached_all_query) {
-		g_object_unref (G_OBJECT (source->priv->cached_all_query));
+	if (source->priv->cached_all_query != NULL) {
+		g_object_unref (source->priv->cached_all_query);
 		source->priv->cached_all_query = NULL;
 	}
 
@@ -881,18 +890,19 @@ rb_browser_source_do_query (RBBrowserSou
 		g_object_set (query_model, "query", query, NULL);
 		rhythmdb_query_model_reapply_query (query_model, FALSE);
 		g_object_unref (query_model);
-	} else {/* otherwise build a query based on the search text and feed it to the browser */
+	} else {
+		/* otherwise build a query based on the search text and feed it to the browser */
 		query_model = rhythmdb_query_model_new_empty (source->priv->db);
 		rb_library_browser_set_model (source->priv->browser, query_model, TRUE);
 		source->priv->query_active = TRUE;
 		source->priv->search_on_completion = FALSE;
-		g_signal_connect_object (G_OBJECT (query_model),
+		g_signal_connect_object (query_model,
 					 "complete", G_CALLBACK (rb_browser_source_query_complete_cb),
 					 source, 0);
 		rhythmdb_do_full_query_async_parsed (source->priv->db,
 						     RHYTHMDB_QUERY_RESULTS (query_model),
 						     query);
-		g_object_unref (G_OBJECT (query_model));
+		g_object_unref (query_model);
 	}
 
 	rhythmdb_query_free (query);
diff -u -p -r1.10 rb-import-errors-source.c
--- sources/rb-import-errors-source.c	23 Jul 2006 16:04:45 -0000	1.10
+++ sources/rb-import-errors-source.c	25 Jul 2006 01:43:11 -0000
@@ -144,14 +144,14 @@ rb_import_errors_source_constructor (GTy
 	rb_entry_view_append_column (source->priv->view, RB_ENTRY_VIEW_COL_LOCATION, TRUE);
 	rb_entry_view_append_column (source->priv->view, RB_ENTRY_VIEW_COL_ERROR, TRUE);
 
-	g_signal_connect_object (G_OBJECT (source->priv->view), "show_popup",
+	g_signal_connect_object (source->priv->view, "show_popup",
 				 G_CALLBACK (rb_import_errors_source_songs_show_popup_cb), source, 0);
 
 	gtk_container_add (GTK_CONTAINER (source), GTK_WIDGET (source->priv->view));
 
 	gtk_widget_show_all (GTK_WIDGET (source));
 
-	g_object_set (G_OBJECT (source), "query-model", model, NULL);
+	g_object_set (source, "query-model", model, NULL);
 	g_object_unref (model);
 
 	return G_OBJECT (source);
diff -u -p -r1.127 rb-iradio-source.c
--- sources/rb-iradio-source.c	23 Jul 2006 16:04:45 -0000	1.127
+++ sources/rb-iradio-source.c	25 Jul 2006 01:43:11 -0000
@@ -141,6 +141,7 @@ struct RBIRadioSourcePrivate
 	gboolean firstrun_done;
 
 	RhythmDBEntryType entry_type;
+	gboolean dispose_has_run;
 };
 
 #define RB_IRADIO_SOURCE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), RB_TYPE_IRADIO_SOURCE, RBIRadioSourcePrivate))
@@ -236,6 +237,13 @@ rb_iradio_source_dispose (GObject *objec
 
 	source = RB_IRADIO_SOURCE (object);
 
+	if (source->priv->dispose_has_run) {
+		/* If dispose did already run, return. */
+		return;
+	}
+	/* Make sure dispose does not run twice. */
+	source->priv->dispose_has_run = TRUE;
+
 	if (source->priv->db) {
 		g_object_unref (source->priv->db);
 		source->priv->db = NULL;
@@ -269,7 +277,8 @@ rb_iradio_source_finalize (GObject *obje
 }
 
 static GObject *
-rb_iradio_source_constructor (GType type, guint n_construct_properties,
+rb_iradio_source_constructor (GType type,
+			      guint n_construct_properties,
 			      GObjectConstructParam *construct_properties)
 {
 	RBIRadioSource *source;
@@ -306,7 +315,7 @@ rb_iradio_source_constructor (GType type
 	rb_entry_view_append_column (source->priv->stations, RB_ENTRY_VIEW_COL_RATING, FALSE);
 /*	rb_entry_view_append_column (source->priv->stations, RB_ENTRY_VIEW_COL_PLAY_COUNT, FALSE);*/
 	rb_entry_view_append_column (source->priv->stations, RB_ENTRY_VIEW_COL_LAST_PLAYED, FALSE);
-	g_signal_connect_object (G_OBJECT (source->priv->stations),
+	g_signal_connect_object (source->priv->stations,
 				 "sort-order-changed",
 				 G_CALLBACK (rb_iradio_source_songs_view_sort_order_changed_cb),
 				 source, 0);
@@ -315,7 +324,7 @@ rb_iradio_source_constructor (GType type
 	 * we don't use RBEntryView's DnD support because it does too much.
 	 * we just want to be able to drop stations in to add them.
 	 */
-	g_signal_connect_object (G_OBJECT (source->priv->stations),
+	g_signal_connect_object (source->priv->stations,
 				 "drag_data_received",
 				 G_CALLBACK (stations_view_drag_data_received_cb),
 				 source, 0);
@@ -324,37 +333,36 @@ rb_iradio_source_constructor (GType type
 			   stations_view_drag_types, 2,
 			   GDK_ACTION_COPY | GDK_ACTION_MOVE);
 
-	g_signal_connect_object (G_OBJECT (source->priv->stations),
+	g_signal_connect_object (source->priv->stations,
 				 "size_allocate",
 				 G_CALLBACK (paned_size_allocate_cb),
 				 source, 0);
-	g_signal_connect_object (G_OBJECT (source->priv->stations), "show_popup",
+	g_signal_connect_object (source->priv->stations, "show_popup",
 				 G_CALLBACK (rb_iradio_source_songs_show_popup_cb), source, 0);
 
 	/* set up genre entry view */
 	source->priv->genres = rb_property_view_new (source->priv->db,
 						     RHYTHMDB_PROP_GENRE,
 						     _("Genre"));
-	g_signal_connect_object (G_OBJECT (source->priv->genres),
+	g_signal_connect_object (source->priv->genres,
 				 "property-selected",
 				 G_CALLBACK (genre_selected_cb),
 				 source, 0);
-	g_signal_connect_object (G_OBJECT (source->priv->genres),
+	g_signal_connect_object (source->priv->genres,
 				 "property-selection-reset",
 				 G_CALLBACK (genre_selection_reset_cb),
 				 source, 0);
 
-	g_object_set (G_OBJECT (source->priv->genres), "vscrollbar_policy",
+	g_object_set (source->priv->genres, "vscrollbar_policy",
 		      GTK_POLICY_AUTOMATIC, NULL);
-	g_object_ref (G_OBJECT (source->priv->genres));
 
+	gtk_paned_pack1 (GTK_PANED (source->priv->paned),
+			 GTK_WIDGET (source->priv->genres), FALSE, FALSE);
 	gtk_paned_pack2 (GTK_PANED (source->priv->paned),
 			 GTK_WIDGET (source->priv->stations), TRUE, FALSE);
 
 	gtk_box_pack_start_defaults (GTK_BOX (source->priv->vbox), source->priv->paned);
 
-	rb_iradio_source_state_prefs_sync (source);
-
 	source->priv->prefs_notify_id =
 		eel_gconf_notification_add (CONF_STATE_IRADIO_DIR,
 					    (GConfClientNotifyFunc) rb_iradio_source_state_pref_changed,
@@ -365,8 +373,12 @@ rb_iradio_source_constructor (GType type
 		eel_gconf_notification_add (CONF_FIRST_TIME,
 					    (GConfClientNotifyFunc) rb_iradio_source_first_time_changed,
 					    source);
+
 	gtk_widget_show_all (GTK_WIDGET (source));
 
+	rb_iradio_source_state_prefs_sync (source);
+
+
 	if (source->priv->entry_type == RHYTHMDB_ENTRY_TYPE_INVALID ||
 	    source->priv->entry_type == NULL)
 		source->priv->entry_type = RHYTHMDB_ENTRY_TYPE_IRADIO_STATION;
@@ -378,9 +390,9 @@ rb_iradio_source_constructor (GType type
 
 static void
 rb_iradio_source_set_property (GObject *object,
-			      guint prop_id,
-			      const GValue *value,
-			      GParamSpec *pspec)
+			       guint prop_id,
+			       const GValue *value,
+			       GParamSpec *pspec)
 {
 	RBIRadioSource *source = RB_IRADIO_SOURCE (object);
 
@@ -396,9 +408,9 @@ rb_iradio_source_set_property (GObject *
 
 static void
 rb_iradio_source_get_property (GObject *object,
-			      guint prop_id,
-			      GValue *value,
-			      GParamSpec *pspec)
+			       guint prop_id,
+			       GValue *value,
+			       GParamSpec *pspec)
 {
 	RBIRadioSource *source = RB_IRADIO_SOURCE (object);
 
@@ -450,7 +462,9 @@ guess_uri_scheme (const char *uri)
 
 void
 rb_iradio_source_add_station (RBIRadioSource *source,
-			      const char *uri, const char *title, const char *genre)
+			      const char *uri,
+			      const char *title,
+			      const char *genre)
 {
 	RhythmDBEntry *entry;
 	GValue val = { 0, };
@@ -499,7 +513,8 @@ rb_iradio_source_add_station (RBIRadioSo
 }
 
 static void
-impl_search (RBSource *asource, const char *search_text)
+impl_search (RBSource *asource,
+	     const char *search_text)
 {
 	RBIRadioSource *source = RB_IRADIO_SOURCE (asource);
 
@@ -571,7 +586,10 @@ rb_iradio_source_async_update_play_stati
 #endif
 
 static void
-impl_get_status (RBSource *asource, char **text, char **progress_text, float *progress)
+impl_get_status (RBSource *asource,
+		 char **text,
+		 char **progress_text,
+		 float *progress)
 {
 	RhythmDBQueryModel *model;
 	guint num_entries;
@@ -665,9 +683,10 @@ rb_iradio_source_songs_show_popup_cb (RB
 				      gboolean over_entry,
 				      RBIRadioSource *source)
 {
-	if (G_OBJECT (source) == NULL) {
+	if (source == NULL) {
 		return;
 	}
+
 	if (over_entry)
 		_rb_source_show_popup (RB_SOURCE (source), "/IRadioViewPopup");
 	else
@@ -689,7 +708,8 @@ genre_selected_cb (RBPropertyView *propv
 }
 
 static void
-genre_selection_reset_cb (RBPropertyView *propview, RBIRadioSource *iradio_source)
+genre_selection_reset_cb (RBPropertyView *propview,
+			  RBIRadioSource *iradio_source)
 {
 	if (iradio_source->priv->setting_new_query)
 		return;
@@ -709,14 +729,9 @@ rb_iradio_source_show_browser (RBIRadioS
 	GtkWidget *genreswidget = GTK_WIDGET (source->priv->genres);
 
 	if (show == TRUE) {
-		gtk_paned_pack1 (GTK_PANED (source->priv->paned), genreswidget, FALSE, FALSE);
-		gtk_widget_show_all (genreswidget);
+		gtk_widget_show (genreswidget);
 	} else if (show == FALSE) {
-		GList *children = gtk_container_get_children (GTK_CONTAINER (source->priv->paned));
 		gtk_widget_hide (genreswidget);
-		if (g_list_find (children, genreswidget))
-		    gtk_container_remove (GTK_CONTAINER (source->priv->paned), genreswidget);
-		g_list_free (children);
 	}
 }
 
@@ -740,10 +755,10 @@ rb_iradio_source_do_query (RBIRadioSourc
 				      RHYTHMDB_PROP_TYPE,
 				      source->priv->entry_type,
 				      RHYTHMDB_QUERY_END);
-	genre_query_model = rhythmdb_query_model_new_empty (source->priv->db);
 
-	if (source->priv->search_text) {
+	if (source->priv->search_text != NULL) {
 		GPtrArray *subquery;
+
 		subquery = rhythmdb_query_parse (source->priv->db,
 						 RHYTHMDB_QUERY_PROP_LIKE,
 						 RHYTHMDB_PROP_GENRE_FOLDED,
@@ -764,6 +779,8 @@ rb_iradio_source_do_query (RBIRadioSourc
 	}
 
 	genre_model = rb_property_view_get_model (source->priv->genres);
+
+	genre_query_model = rhythmdb_query_model_new_empty (source->priv->db);
 	g_object_set (genre_model, "query-model", genre_query_model, NULL);
 
 	rhythmdb_do_full_query_parsed (source->priv->db,
@@ -776,6 +793,7 @@ rb_iradio_source_do_query (RBIRadioSourc
 	/* check the selected genre is still available, and if not, select 'all' */
 	if (source->priv->selected_genre != NULL) {
 		GList *sel = NULL;
+
 		if (!rhythmdb_property_model_iter_from_string (genre_model,
 							       source->priv->selected_genre,
 							       NULL)) {
@@ -787,7 +805,6 @@ rb_iradio_source_do_query (RBIRadioSourc
 		rb_property_view_set_selection (source->priv->genres, sel);
 		g_list_free (sel);
 	}
-	g_object_unref (genre_model);
 
 	/* if a genre is selected, construct a new query for it, and create
 	 * a new model based on the search box query model.  otherwise, just
@@ -796,6 +813,7 @@ rb_iradio_source_do_query (RBIRadioSourc
 
 	if (source->priv->selected_genre != NULL) {
 		rb_debug ("matching on genre \"%s\"", source->priv->selected_genre);
+
 		station_query_model = rhythmdb_query_model_new_empty (source->priv->db);
 		query = rhythmdb_query_parse (source->priv->db,
 					      RHYTHMDB_QUERY_PROP_EQUALS,
@@ -811,22 +829,24 @@ rb_iradio_source_do_query (RBIRadioSourc
 		rhythmdb_query_free (query);
 		query = NULL;
 	} else {
-		station_query_model = genre_query_model;
+		station_query_model = g_object_ref (genre_query_model);
 	}
 
 	rb_entry_view_set_model (source->priv->stations, station_query_model);
-	g_object_set (G_OBJECT (source), "query-model", station_query_model, NULL);
+	g_object_set (source, "query-model", station_query_model, NULL);
 
-	g_object_unref (G_OBJECT (genre_query_model));
-	if (station_query_model != genre_query_model)
-		g_object_unref (G_OBJECT (station_query_model));
+	g_object_unref (genre_query_model);
+	g_object_unref (station_query_model);
 
 	source->priv->setting_new_query = FALSE;
 }
 
 static void
-handle_playlist_entry_cb (TotemPlParser *playlist, const char *uri, const char *title,
-			  const char *genre, RBIRadioSource *source)
+handle_playlist_entry_cb (TotemPlParser *playlist,
+			  const char *uri,
+			  const char *title,
+			  const char *genre,
+			  RBIRadioSource *source)
 {
 	rb_iradio_source_add_station (source, uri, title, genre);
 }
@@ -842,11 +862,11 @@ rb_iradio_source_add_from_playlist (RBIR
 	if (real_uri)
 		uri = real_uri;
 
-	g_signal_connect_object (G_OBJECT (parser), "entry",
+	g_signal_connect_object (parser, "entry",
 				 G_CALLBACK (handle_playlist_entry_cb),
 				 source, 0);
 	if (g_object_class_find_property (G_OBJECT_GET_CLASS (parser), "recurse"))
-		g_object_set (G_OBJECT (parser), "recurse", FALSE, NULL);
+		g_object_set (parser, "recurse", FALSE, NULL);
 
 	switch (totem_pl_parser_parse (parser, uri, TRUE)) {
 	case TOTEM_PL_PARSER_RESULT_UNHANDLED:
@@ -859,7 +879,7 @@ rb_iradio_source_add_from_playlist (RBIR
 	case TOTEM_PL_PARSER_RESULT_ERROR:
 		break;
 	}
-	g_object_unref (G_OBJECT (parser));
+	g_object_unref (parser);
 	g_free (real_uri);
 }
 
diff -u -p -r1.9 rb-missing-files-source.c
--- sources/rb-missing-files-source.c	23 Jul 2006 16:04:45 -0000	1.9
+++ sources/rb-missing-files-source.c	25 Jul 2006 01:43:12 -0000
@@ -156,10 +156,10 @@ rb_missing_files_source_constructor (GTy
 	source = RB_MISSING_FILES_SOURCE (G_OBJECT_CLASS (rb_missing_files_source_parent_class)->
 			constructor (type, n_construct_properties, construct_properties));
 
-	g_object_get (G_OBJECT (source), "shell", &shell, NULL);
-	g_object_get (G_OBJECT (shell), "db", &source->priv->db, NULL);
+	g_object_get (source, "shell", &shell, NULL);
+	g_object_get (shell, "db", &source->priv->db, NULL);
 	shell_player = rb_shell_get_player (shell);
-	g_object_unref (G_OBJECT (shell));
+	g_object_unref (shell);
 
 	/* construct real query */
 	query = rhythmdb_query_parse (source->priv->db,
@@ -175,7 +175,7 @@ rb_missing_files_source_constructor (GTy
 
 	rhythmdb_query_free (query);
 
-	g_object_set (G_OBJECT (model), "show-hidden", TRUE, NULL);
+	g_object_set (model, "show-hidden", TRUE, NULL);
 
 	/* set up entry view */
 	source->priv->view = rb_entry_view_new (source->priv->db, shell_player,
@@ -194,14 +194,14 @@ rb_missing_files_source_constructor (GTy
 	rb_entry_view_set_columns_clickable (source->priv->view, TRUE);
 
 	gtk_container_add (GTK_CONTAINER (source), GTK_WIDGET (source->priv->view));
-	g_signal_connect_object (G_OBJECT (source->priv->view), "show_popup",
+	g_signal_connect_object (source->priv->view, "show_popup",
 				 G_CALLBACK (rb_missing_files_source_songs_show_popup_cb), source, 0);
-	g_signal_connect_object (G_OBJECT (source->priv->view), "sort-order-changed",
+	g_signal_connect_object (source->priv->view, "sort-order-changed",
 				 G_CALLBACK (rb_missing_files_source_songs_sort_order_changed_cb), source, 0);
 
 	gtk_widget_show_all (GTK_WIDGET (source));
 
-	g_object_set (G_OBJECT (source), "query-model", model, NULL);
+	g_object_set (source, "query-model", model, NULL);
 	g_object_unref (model);
 
 	return G_OBJECT (source);
@@ -212,8 +212,8 @@ rb_missing_files_source_dispose (GObject
 {
 	RBMissingFilesSource *source = RB_MISSING_FILES_SOURCE (object);
 
-	if (source->priv->db) {
-		g_object_unref (G_OBJECT (source->priv->db));
+	if (source->priv->db != NULL) {
+		g_object_unref (source->priv->db);
 		source->priv->db = NULL;
 	}
 
@@ -272,7 +272,7 @@ rb_missing_files_source_new (RBShell *sh
 	RBSource *source;
 	RhythmDBEntryType entry_type;
 
-	g_object_get (G_OBJECT (library), "entry-type", &entry_type, NULL);
+	g_object_get (library, "entry-type", &entry_type, NULL);
 	source = RB_SOURCE (g_object_new (RB_TYPE_MISSING_FILES_SOURCE,
 					  "name", _("Missing Files"),
 					  "entry-type", entry_type,
diff -u -p -r1.18 rb-play-queue-source.c
--- sources/rb-play-queue-source.c	23 Jul 2006 16:04:45 -0000	1.18
+++ sources/rb-play-queue-source.c	25 Jul 2006 01:43:12 -0000
@@ -110,6 +110,8 @@ rb_play_queue_source_finalize (GObject *
 	if (priv->action_group != NULL) {
 		g_object_unref (priv->action_group);
 	}
+
+	G_OBJECT_CLASS (rb_play_queue_source_parent_class)->finalize (object);
 }
 
 static void
diff -u -p -r1.127 rb-playlist-source.c
--- sources/rb-playlist-source.c	23 Jul 2006 16:04:45 -0000	1.127
+++ sources/rb-playlist-source.c	25 Jul 2006 01:43:12 -0000
@@ -49,18 +49,19 @@
 
 static void rb_playlist_source_class_init (RBPlaylistSourceClass *klass);
 static void rb_playlist_source_init (RBPlaylistSource *source);
-static GObject *rb_playlist_source_constructor (GType type, guint n_construct_properties,
+static GObject *rb_playlist_source_constructor (GType type,
+						guint n_construct_properties,
 						GObjectConstructParam *construct_properties);
 static void rb_playlist_source_dispose (GObject *object);
 static void rb_playlist_source_finalize (GObject *object);
 static void rb_playlist_source_set_property (GObject *object,
-			                  guint prop_id,
-			                  const GValue *value,
-			                  GParamSpec *pspec);
+					     guint prop_id,
+					     const GValue *value,
+					     GParamSpec *pspec);
 static void rb_playlist_source_get_property (GObject *object,
-			                  guint prop_id,
-			                  GValue *value,
-			                  GParamSpec *pspec);
+					     guint prop_id,
+					     GValue *value,
+					     GParamSpec *pspec);
 
 /* source methods */
 static char *impl_get_browser_key (RBSource *source);
@@ -108,6 +109,7 @@ struct RBPlaylistSourcePrivate
 
 	gboolean dirty;
 	gboolean is_local;
+	gboolean dispose_has_run;
 
 	char *title;
 };
@@ -228,6 +230,7 @@ rb_playlist_source_constructor (GType ty
 	RBPlaylistSourceClass *klass;
 	RBShell *shell;
 	RhythmDB *db;
+	RhythmDBQueryModel *query_model;
 
 	klass = RB_PLAYLIST_SOURCE_CLASS (g_type_class_peek (RB_TYPE_PLAYLIST_SOURCE));
 
@@ -246,9 +249,13 @@ rb_playlist_source_constructor (GType ty
 
 	source->priv->entries = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
 
-	source->priv->songs = rb_entry_view_new (source->priv->db, shell_player,
+	source->priv->songs = rb_entry_view_new (source->priv->db,
+						 shell_player,
 					 	 NULL, TRUE, TRUE);
-	rb_playlist_source_set_query_model (source, rhythmdb_query_model_new_empty (source->priv->db));
+
+	query_model = rhythmdb_query_model_new_empty (source->priv->db);
+	rb_playlist_source_set_query_model (source, query_model);
+	g_object_unref (query_model);
 
 	{
 		const char *title = "";
@@ -308,11 +315,25 @@ rb_playlist_source_dispose (GObject *obj
 {
 	RBPlaylistSource *source = RB_PLAYLIST_SOURCE (object);
 
-	if (source->priv->db) {
+	if (source->priv->dispose_has_run) {
+		/* If dispose did already run, return. */
+		rb_debug ("Dispose has already run for playlist source %p", object);
+		return;
+	}
+	/* Make sure dispose does not run twice. */
+	source->priv->dispose_has_run = TRUE;
+
+	rb_debug ("Disposing playlist source %p", source);
+
+	if (source->priv->db != NULL) {
 		g_object_unref (source->priv->db);
 		source->priv->db = NULL;
 	}
 
+	if (source->priv->model != NULL) {
+		g_object_unref (source->priv->model);
+	}
+
 	G_OBJECT_CLASS (rb_playlist_source_parent_class)->dispose (object);
 }
 
@@ -327,6 +348,8 @@ rb_playlist_source_finalize (GObject *ob
 	source = RB_PLAYLIST_SOURCE (object);
 	g_return_if_fail (source->priv != NULL);
 
+	rb_debug ("Finalizing playlist source %p", source);
+
 	g_hash_table_destroy (source->priv->entries);
 
 	g_free (source->priv->title);
@@ -525,6 +548,8 @@ rb_playlist_source_save_playlist (RBPlay
 	GError *error = NULL;
 	char *name;
 
+	g_return_if_fail (RB_IS_PLAYLIST_SOURCE (source));
+
 	rb_debug ("saving playlist");
 	playlist = totem_pl_parser_new ();
 
@@ -629,6 +654,8 @@ rb_playlist_source_new_from_xml	(RBShell
 	xmlChar *tmp;
 	xmlChar *name;
 
+	g_return_val_if_fail (RB_IS_SHELL (shell), NULL);
+
 	/* Try to get name from XML and remove translated names */
 	name = get_playlist_name_from_xml (node);
 
@@ -666,6 +693,8 @@ rb_playlist_source_save_to_xml (RBPlayli
 	xmlChar *name;
 	RBPlaylistSourceClass *klass = RB_PLAYLIST_SOURCE_GET_CLASS (source);
 
+	g_return_if_fail (RB_IS_PLAYLIST_SOURCE (source));
+
 	node = xmlNewChild (parent_node, NULL, RB_PLAYLIST_PLAYLIST, NULL);
 	g_object_get (source, "name", &name, NULL);
 	xmlSetProp (node, RB_PLAYLIST_NAME, name);
@@ -734,56 +763,70 @@ void
 rb_playlist_source_setup_entry_view (RBPlaylistSource *source,
 				     RBEntryView *entry_view)
 {
-	g_signal_connect_object (G_OBJECT (entry_view), "show_popup",
+	g_return_if_fail (RB_IS_PLAYLIST_SOURCE (source));
+
+	g_signal_connect_object (entry_view, "show_popup",
 				 G_CALLBACK (rb_playlist_source_songs_show_popup_cb), source, 0);
-	g_signal_connect_object (G_OBJECT (entry_view), "drag_data_received",
+	g_signal_connect_object (entry_view, "drag_data_received",
 				 G_CALLBACK (rb_playlist_source_drop_cb), source, 0);
-	gtk_drag_dest_set (GTK_WIDGET (entry_view), GTK_DEST_DEFAULT_ALL,
-			   target_uri, G_N_ELEMENTS (target_uri), GDK_ACTION_COPY);
+	gtk_drag_dest_set (GTK_WIDGET (entry_view),
+			   GTK_DEST_DEFAULT_ALL,
+			   target_uri,
+			   G_N_ELEMENTS (target_uri),
+			   GDK_ACTION_COPY);
 }
 
 void
 rb_playlist_source_set_query_model (RBPlaylistSource *source,
 				    RhythmDBQueryModel *model)
 {
-	if (source->priv->model) {
+	g_return_if_fail (RB_IS_PLAYLIST_SOURCE (source));
+
+	if (source->priv->model != NULL) {
 		/* if the query model is replaced, the set of entries in
 		 * the playlist will change, so we should mark the playlist dirty.
 		 */
 		source->priv->dirty = TRUE;
-		g_signal_handlers_disconnect_by_func (G_OBJECT (source->priv->model),
+		g_signal_handlers_disconnect_by_func (source->priv->model,
 						      G_CALLBACK (rb_playlist_source_row_deleted),
 						      source);
 		g_object_unref (source->priv->model);
 	}
+
 	source->priv->model = model;
 
-	if (model) {
-		g_object_ref (G_OBJECT (model));
-		g_signal_connect_object (G_OBJECT (source->priv->model), "row_deleted",
+	if (source->priv->model != NULL) {
+		g_object_ref (source->priv->model);
+		g_signal_connect_object (source->priv->model, "row_deleted",
 					 G_CALLBACK (rb_playlist_source_row_deleted), source, 0);
 	}
 
 	rb_entry_view_set_model (source->priv->songs, RHYTHMDB_QUERY_MODEL (source->priv->model));
 
-	g_object_set (G_OBJECT (source), "query-model", source->priv->model, NULL);
+	g_object_set (source, "query-model", source->priv->model, NULL);
 }
 
 RhythmDB *
 rb_playlist_source_get_db (RBPlaylistSource *source)
 {
+	g_return_val_if_fail (RB_IS_PLAYLIST_SOURCE (source), NULL);
+
 	return source->priv->db;
 }
 
 RhythmDBQueryModel *
 rb_playlist_source_get_query_model (RBPlaylistSource *source)
 {
+	g_return_val_if_fail (RB_IS_PLAYLIST_SOURCE (source), NULL);
+
 	return source->priv->model;
 }
 
 void
 rb_playlist_source_mark_dirty (RBPlaylistSource *source)
 {
+	g_return_if_fail (RB_IS_PLAYLIST_SOURCE (source));
+
 	source->priv->dirty = TRUE;
 }
 
@@ -791,6 +834,8 @@ gboolean
 rb_playlist_source_location_in_map (RBPlaylistSource *source,
 				    const char *location)
 {
+	g_return_val_if_fail (RB_IS_PLAYLIST_SOURCE (source), FALSE);
+
 	return (g_hash_table_lookup (source->priv->entries, location) != NULL);
 }
 
@@ -798,6 +843,8 @@ gboolean
 rb_playlist_source_add_to_map (RBPlaylistSource *source,
 			       const char *location)
 {
+	g_return_val_if_fail (RB_IS_PLAYLIST_SOURCE (source), FALSE);
+
 	if (g_hash_table_lookup (source->priv->entries, location)) {
 		return FALSE;
 	}
diff -u -p -r1.74 rb-podcast-source.c
--- sources/rb-podcast-source.c	23 Jul 2006 16:04:45 -0000	1.74
+++ sources/rb-podcast-source.c	25 Jul 2006 01:43:14 -0000
@@ -250,8 +250,6 @@ static void impl_get_status				(RBSource
 
 struct RBPodcastSourcePrivate
 {
-	gboolean disposed;
-
 	RhythmDB *db;
 
 	guint toolbar_ui_merge_id;
@@ -273,7 +271,9 @@ struct RBPodcastSourcePrivate
 	gboolean initialized;
 
 	RhythmDBEntryType entry_type;
-	RBPodcastManager *podcast_mg;
+	RBPodcastManager *podcast_mgr;
+
+	gboolean dispose_has_run;
 };
 
 #define RB_PODCAST_SOURCE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), RB_TYPE_PODCAST_SOURCE, RBPodcastSourcePrivate))
@@ -416,15 +416,17 @@ rb_podcast_source_dispose (GObject *obje
 	rb_debug ("dispose podcast_source");
 	source = RB_PODCAST_SOURCE (object);
 
-	if (source->priv->disposed)
+	if (source->priv->dispose_has_run) {
+		/* If dispose did already run, return. */
 		return;
+	}
+	/* Make sure dispose does not run twice. */
+	source->priv->dispose_has_run = TRUE;
 
 	if (source->priv->db != NULL) {
 		g_object_unref (source->priv->db);
 	}
 
-	source->priv->disposed = TRUE;
-
 	G_OBJECT_CLASS (rb_podcast_source_parent_class)->dispose (object);
 }
 
@@ -448,8 +450,7 @@ rb_podcast_source_finalize (GObject *obj
 
 	eel_gconf_notification_remove (source->priv->prefs_notify_id);
 
-	g_object_unref (source->priv->feeds);
-	g_object_unref (source->priv->podcast_mg);
+	g_object_unref (source->priv->podcast_mgr);
 
 	if (source->priv->selected_feeds) {
 		g_list_foreach (source->priv->selected_feeds, (GFunc) g_free, NULL);
@@ -547,7 +548,7 @@ rb_podcast_source_constructor (GType typ
 
 	gtk_idle_add ((GtkFunction) rb_podcast_source_load_finish_cb, source);
 
-	source->priv->podcast_mg = rb_podcast_manager_new (source->priv->db);
+	source->priv->podcast_mgr = rb_podcast_manager_new (source->priv->db);
 
 	g_object_unref (shell);
 
@@ -650,12 +651,12 @@ rb_podcast_source_constructor (GType typ
 				 G_CALLBACK (rb_podcast_source_posts_view_sort_order_changed_cb),
 				 source, 0);
 
-	g_signal_connect (G_OBJECT (source->priv->podcast_mg),
+	g_signal_connect (G_OBJECT (source->priv->podcast_mgr),
 			  "status_changed",
 			  G_CALLBACK (rb_podcast_source_download_status_changed_cb),
 			  source);
 
-	g_signal_connect_object (G_OBJECT (source->priv->podcast_mg),
+	g_signal_connect_object (G_OBJECT (source->priv->podcast_mgr),
 			  	 "process_error",
 			 	 G_CALLBACK (rb_podcast_source_download_process_error_cb),
 			  	 source, 0);
@@ -674,8 +675,7 @@ rb_podcast_source_constructor (GType typ
 
 	query_model = rhythmdb_query_model_new_empty (source->priv->db);
 	feed_model = rb_property_view_get_model (RB_PROPERTY_VIEW (source->priv->feeds));
-	g_object_set (G_OBJECT (feed_model), "query-model", query_model, NULL);
-	g_object_unref (G_OBJECT (feed_model));
+	g_object_set (feed_model, "query-model", query_model, NULL);
 
 	if (source->priv->entry_type == RHYTHMDB_ENTRY_TYPE_INVALID ||
 	    source->priv->entry_type == NULL)
@@ -691,6 +691,7 @@ rb_podcast_source_constructor (GType typ
 				       query);
 
 	rhythmdb_query_free (query);
+	g_object_unref (query_model);
 
 	/* column title */
 	column = gtk_tree_view_column_new ();
@@ -708,11 +709,11 @@ rb_podcast_source_constructor (GType typ
 	gtk_tree_view_column_set_visible (column, TRUE);
 	rb_property_view_append_column_custom (source->priv->feeds, column);
 
-	g_signal_connect_object (G_OBJECT (source->priv->feeds), "show_popup",
+	g_signal_connect_object (source->priv->feeds, "show_popup",
 				 G_CALLBACK (rb_podcast_source_feeds_show_popup_cb),
 				 source, 0);
 
-	g_signal_connect_object (G_OBJECT (source->priv->feeds),
+	g_signal_connect_object (source->priv->feeds,
 				 "properties-selected",
 				 G_CALLBACK (feed_select_change_cb),
 				 source, 0);
@@ -722,10 +723,8 @@ rb_podcast_source_constructor (GType typ
 					  source,
 					  NULL);
 
-	g_object_ref (G_OBJECT (source->priv->feeds));
-
 	/* set up drag and drop */
-	g_signal_connect_object (G_OBJECT (source->priv->feeds),
+	g_signal_connect_object (source->priv->feeds,
 				 "drag_data_received",
 				 G_CALLBACK (posts_view_drag_data_received_cb),
 				 source, 0);
@@ -746,19 +745,19 @@ rb_podcast_source_constructor (GType typ
 			   GDK_ACTION_COPY | GDK_ACTION_MOVE);
 
 	/* set up propiets page */
-
+	gtk_paned_pack1 (GTK_PANED (source->priv->paned),
+			 GTK_WIDGET (source->priv->feeds), FALSE, FALSE);
 	gtk_paned_pack2 (GTK_PANED (source->priv->paned),
 			 GTK_WIDGET (source->priv->posts), TRUE, FALSE);
 
 	gtk_box_pack_start_defaults (GTK_BOX (source->priv->vbox), source->priv->paned);
 
-	rb_podcast_source_state_prefs_sync (source);
-
 	source->priv->prefs_notify_id = eel_gconf_notification_add (CONF_STATE_PODCAST_PREFIX,
 								    (GConfClientNotifyFunc) rb_podcast_source_state_pref_changed,
 								    source);
 
 	gtk_widget_show_all (GTK_WIDGET (source));
+	rb_podcast_source_state_prefs_sync (source);
 
 	rb_podcast_source_do_query (source, RB_PODCAST_QUERY_TYPE_ALL);
 
@@ -778,7 +777,7 @@ rb_podcast_source_set_property (GObject 
 		source->priv->entry_type = g_value_get_boxed (value);
 		break;
 	case PROP_PODCAST_MANAGER:
-		source->priv->podcast_mg = g_value_get_object (value);
+		source->priv->podcast_mgr = g_value_get_object (value);
 		break;
 	default:
 		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -799,7 +798,7 @@ rb_podcast_source_get_property (GObject 
 		g_value_set_boxed (value, source->priv->entry_type);
 		break;
 	case PROP_PODCAST_MANAGER:
-		g_value_set_object (value, source->priv->podcast_mg);
+		g_value_set_object (value, source->priv->podcast_mgr);
 	        break;
 	default:
 		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -923,7 +922,7 @@ impl_delete (RBSource *asource)
 	if (ret == GTK_RESPONSE_CANCEL || ret == GTK_RESPONSE_DELETE_EVENT)
 		return;
 
-	rb_podcast_manager_set_remove_files (source->priv->podcast_mg,
+	rb_podcast_manager_set_remove_files (source->priv->podcast_mgr,
 					     (ret == GTK_RESPONSE_YES));
 
 	entries = rb_entry_view_get_selected_entries (source->priv->posts);
@@ -966,7 +965,7 @@ rb_podcast_source_state_prefs_sync (RBPo
 	gtk_paned_set_position (GTK_PANED (source->priv->paned),
 				eel_gconf_get_integer (CONF_STATE_PANED_POSITION));
 	rb_podcast_source_show_browser (source,
-				       eel_gconf_get_boolean (CONF_STATE_SHOW_BROWSER));
+					eel_gconf_get_boolean (CONF_STATE_SHOW_BROWSER));
 }
 
 static void
@@ -1094,22 +1093,9 @@ feed_select_change_cb (RBPropertyView *p
 
 static void
 rb_podcast_source_show_browser (RBPodcastSource *source,
-			       gboolean show)
+				gboolean show)
 {
-
-	GtkWidget *feedswidget = GTK_WIDGET (source->priv->feeds);
-
-	if (show == TRUE) {
-		gtk_paned_pack1 (GTK_PANED (source->priv->paned), feedswidget, FALSE, FALSE);
-		gtk_widget_show_all (feedswidget);
-	} else if (show == FALSE) {
-		GList *children = gtk_container_get_children (GTK_CONTAINER (source->priv->paned));
-		gtk_widget_hide (feedswidget);
-		if (g_list_find (children, feedswidget))
-		    gtk_container_remove (GTK_CONTAINER (source->priv->paned), feedswidget);
-
-		g_list_free (children);
-	}
+	g_object_set (source->priv->feeds, "visible", show, NULL);
 }
 
 static GPtrArray *
@@ -1189,7 +1175,8 @@ construct_query_from_selection (RBPodcas
 }
 
 static void
-rb_podcast_source_do_query (RBPodcastSource *source, RBPodcastQueryType qtype)
+rb_podcast_source_do_query (RBPodcastSource *source,
+			    RBPodcastQueryType qtype)
 {
 	RhythmDBQueryModel *query_model;
 	GPtrArray *query;
@@ -1209,12 +1196,12 @@ rb_podcast_source_do_query (RBPodcastSou
 	query_model = rhythmdb_query_model_new_empty (source->priv->db);
 	if (source->priv->cached_all_query == NULL) {
 		rb_debug ("caching new query");
-		source->priv->cached_all_query = query_model;
+		source->priv->cached_all_query = g_object_ref (query_model);
 	}
 
 	rb_debug ("setting empty model");
 	rb_entry_view_set_model (source->priv->posts, query_model);
-	g_object_set (G_OBJECT (source), "query-model", query_model, NULL);
+	g_object_set (source, "query-model", query_model, NULL);
 
 	rb_debug ("doing query");
 	query = construct_query_from_selection (source);
@@ -1224,8 +1211,7 @@ rb_podcast_source_do_query (RBPodcastSou
 
 	rhythmdb_query_free (query);
 
-	if (!is_all_query)
-		g_object_unref (G_OBJECT (query_model));
+	g_object_unref (query_model);
 }
 
 static gboolean
@@ -1251,7 +1237,7 @@ impl_get_config_widget (RBSource *asourc
 	source->priv->config_widget = glade_xml_get_widget (xml, "podcast_vbox");
 
 	btn_file = glade_xml_get_widget (xml, "location_chooser");
-	download_dir = rb_podcast_manager_get_podcast_dir (source->priv->podcast_mg);
+	download_dir = rb_podcast_manager_get_podcast_dir (source->priv->podcast_mgr);
 	gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (btn_file),
 						 download_dir);
 	g_free (download_dir);
@@ -1297,7 +1283,7 @@ posts_view_drag_data_received_cb (GtkWid
 void
 rb_podcast_source_add_feed (RBPodcastSource *source, const char *uri)
 {
-	rb_podcast_manager_subscribe_feed (source->priv->podcast_mg, uri);
+	rb_podcast_manager_subscribe_feed (source->priv->podcast_mgr, uri);
 }
 
 static void
@@ -1322,7 +1308,7 @@ rb_podcast_source_cmd_download_post (Gtk
 		    status == RHYTHMDB_PODCAST_STATUS_ERROR) {
 			g_value_set_ulong (&val, RHYTHMDB_PODCAST_STATUS_WAITING);
 			rhythmdb_entry_set (source->priv->db, entry, RHYTHMDB_PROP_STATUS, &val);
-			rb_podcast_manager_download_entry (source->priv->podcast_mg, entry);
+			rb_podcast_manager_download_entry (source->priv->podcast_mgr, entry);
 		}
 
 		lst = lst->next;
@@ -1356,7 +1342,7 @@ rb_podcast_source_cmd_cancel_download (G
 		    status == RHYTHMDB_PODCAST_STATUS_WAITING) {
 			g_value_set_ulong (&val, RHYTHMDB_PODCAST_STATUS_PAUSED);
 			rhythmdb_entry_set (source->priv->db, entry, RHYTHMDB_PROP_STATUS, &val);
-			rb_podcast_manager_cancel_download (source->priv->podcast_mg, entry);
+			rb_podcast_manager_cancel_download (source->priv->podcast_mgr, entry);
 		}
 
 		lst = lst->next;
@@ -1425,7 +1411,7 @@ rb_podcast_source_cmd_delete_feed (GtkAc
 		const char *location = l->data;
 
 		rb_debug ("Removing podcast location: %s", location);
-		rb_podcast_manager_remove_feed (source->priv->podcast_mg,
+		rb_podcast_manager_remove_feed (source->priv->podcast_mgr,
 						location,
 						(ret == GTK_RESPONSE_YES));
 	}
@@ -1468,7 +1454,7 @@ rb_podcast_source_cmd_update_feed (GtkAc
 	for (l = feeds; l != NULL; l = g_list_next (l)) {
 		const char *location = l->data;
 
-		rb_podcast_manager_subscribe_feed (source->priv->podcast_mg,
+		rb_podcast_manager_subscribe_feed (source->priv->podcast_mgr,
 						   location);
 	}
 
@@ -1478,7 +1464,7 @@ rb_podcast_source_cmd_update_feed (GtkAc
 static void
 rb_podcast_source_cmd_update_all (GtkAction *action, RBPodcastSource *source)
 {
-	rb_podcast_manager_update_feeds (source->priv->podcast_mg);
+	rb_podcast_manager_update_feeds (source->priv->podcast_mgr);
 }
 
 static void
@@ -1667,7 +1653,7 @@ rb_podcast_source_cb_interval_changed_cb
 	eel_gconf_set_integer (CONF_STATE_PODCAST_DOWNLOAD_INTERVAL,
 			       index);
 
-	rb_podcast_manager_start_sync (RB_PODCAST_SOURCE (cb_data)->priv->podcast_mg);
+	rb_podcast_manager_start_sync (RB_PODCAST_SOURCE (cb_data)->priv->podcast_mgr);
 }
 
 static gboolean
@@ -1675,19 +1661,19 @@ rb_podcast_source_load_finish_cb  (gpoin
 {
 	RBPodcastSource *source  = RB_PODCAST_SOURCE (cb_data);
 
-	rb_podcast_manager_start_sync (source->priv->podcast_mg);
+	rb_podcast_manager_start_sync (source->priv->podcast_mgr);
 
-	g_signal_connect_after (G_OBJECT (source->priv->podcast_mg),
+	g_signal_connect_after (G_OBJECT (source->priv->podcast_mgr),
 	 		        "start_download",
 			  	G_CALLBACK (rb_podcast_source_start_download_cb),
 			  	source);
 
-	g_signal_connect_after (G_OBJECT (source->priv->podcast_mg),
+	g_signal_connect_after (G_OBJECT (source->priv->podcast_mgr),
 			  	"finish_download",
 			  	G_CALLBACK (rb_podcast_source_finish_download_cb),
 			  	source);
 
-	g_signal_connect_after (G_OBJECT (source->priv->podcast_mg),
+	g_signal_connect_after (G_OBJECT (source->priv->podcast_mgr),
 			  	"feed_updates_avaliable",
  			  	G_CALLBACK (rb_podcast_source_feed_updates_avaliable_cb),
 			  	source);
@@ -1802,7 +1788,7 @@ void
 rb_podcast_source_shutdown	(RBPodcastSource *source)
 {
 	rb_debug ("podcast source shutdown");
-	rb_podcast_manager_cancel_all (source->priv->podcast_mg);
+	rb_podcast_manager_cancel_all (source->priv->podcast_mgr);
 }
 
 static gint
@@ -1899,7 +1885,7 @@ static void rb_podcast_source_entry_acti
 	rhythmdb_commit (source->priv->db);
 	g_value_unset (&val);
 
-	rb_podcast_manager_download_entry (source->priv->podcast_mg, entry);
+	rb_podcast_manager_download_entry (source->priv->podcast_mgr, entry);
 }
 
 static gboolean
diff -u -p -r1.76 rb-source.c
--- sources/rb-source.c	23 Jul 2006 16:04:46 -0000	1.76
+++ sources/rb-source.c	25 Jul 2006 01:43:14 -0000
@@ -282,13 +282,16 @@ rb_source_finalize (GObject *object)
 	priv = RB_SOURCE_GET_PRIVATE (source);
 	g_return_if_fail (priv != NULL);
 
-	rb_debug ("Finalizing view %p", source);
+	rb_debug ("Finalizing source %p: '%s'", source, priv->name);
 
 	if (priv->update_visibility_id != 0) {
 		g_source_remove (priv->update_visibility_id);
 	}
 
-	g_object_unref (G_OBJECT (priv->query_model));
+	if (priv->query_model != NULL) {
+		rb_debug ("Unreffing model %p count: %d", priv->query_model, G_OBJECT (priv->query_model)->ref_count);
+		g_object_unref (priv->query_model);
+	}
 
 	if (priv->pixbuf != NULL) {
 		g_object_unref (priv->pixbuf);
@@ -363,13 +366,47 @@ rb_source_set_hidden_when_empty (RBSourc
 }
 
 static void
+rb_source_set_query_model_internal (RBSource *source,
+				    RhythmDBQueryModel *model)
+{
+	RBSourcePrivate *priv = RB_SOURCE_GET_PRIVATE (source);
+
+	if (priv->query_model == model) {
+		return;
+	}
+
+	if (priv->query_model != NULL) {
+		g_signal_handlers_disconnect_by_func (priv->query_model,
+						      G_CALLBACK (rb_source_post_entry_deleted_cb),
+						      source);
+		g_signal_handlers_disconnect_by_func (priv->query_model,
+						      G_CALLBACK (rb_source_row_inserted_cb),
+						      source);
+		g_object_unref (priv->query_model);
+	}
+
+	priv->query_model = model;
+	if (priv->query_model != NULL) {
+		g_object_ref (priv->query_model);
+		g_signal_connect_object (model, "post-entry-delete",
+					 G_CALLBACK (rb_source_post_entry_deleted_cb),
+					 source, 0);
+		g_signal_connect_object (model, "row_inserted",
+					 G_CALLBACK (rb_source_row_inserted_cb),
+					 source, 0);
+	}
+
+	/* g_object_notify (G_OBJECT (source), "query-model"); */
+	rb_source_notify_status_changed (source);
+}
+
+static void
 rb_source_set_property (GObject *object,
 			guint prop_id,
 			const GValue *value,
 			GParamSpec *pspec)
 {
 	RBSourcePrivate *priv = RB_SOURCE_GET_PRIVATE (object);
-	RhythmDBQueryModel *model;
 	RBSource *source = RB_SOURCE (object);
 
 	switch (prop_id) {
@@ -393,34 +430,7 @@ rb_source_set_property (GObject *object,
 		rb_source_set_hidden_when_empty (source, g_value_get_boolean (value));
 		break;
 	case PROP_QUERY_MODEL:
-		model = g_value_get_object (value);
-
-		if (priv->query_model == model)
-			return;
-
-		if (priv->query_model) {
-			g_signal_handlers_disconnect_by_func (G_OBJECT (priv->query_model),
-							      G_CALLBACK (rb_source_post_entry_deleted_cb),
-							      source);
-			g_signal_handlers_disconnect_by_func (G_OBJECT (priv->query_model),
-							      G_CALLBACK (rb_source_row_inserted_cb),
-							      source);
-			g_object_unref (G_OBJECT (priv->query_model));
-		}
-
-		priv->query_model = model;
-		if (priv->query_model) {
-			g_object_ref (G_OBJECT (model));
-			g_signal_connect_object (G_OBJECT (model), "post-entry-delete",
-						 G_CALLBACK (rb_source_post_entry_deleted_cb),
-						 source, 0);
-			g_signal_connect_object (G_OBJECT (model), "row_inserted",
-						 G_CALLBACK (rb_source_row_inserted_cb),
-						 source, 0);
-		}
-
-		/* g_object_notify (G_OBJECT (source), "query-model"); */
-		rb_source_notify_status_changed (source);
+		rb_source_set_query_model_internal (source, g_value_get_object (value));
 		break;
 	case PROP_SOURCELIST_GROUP:
 		priv->sourcelist_group = g_value_get_enum (value);
@@ -481,10 +491,12 @@ default_get_status (RBSource *source,
 		    float *progress)
 {
 	RBSourcePrivate *priv = RB_SOURCE_GET_PRIVATE (source);
+
 	/* hack to get these strings marked for translation */
 	if (0) {
 		ngettext ("%d song", "%d songs", 0);
 	}
+
 	if (priv->query_model) {
 		*text = rhythmdb_query_model_compute_status_normal (priv->query_model,
 								    "%d song",
diff -u -p -r1.28 rb-static-playlist-source.c
--- sources/rb-static-playlist-source.c	23 Jul 2006 16:04:49 -0000	1.28
+++ sources/rb-static-playlist-source.c	25 Jul 2006 01:43:15 -0000
@@ -107,6 +107,7 @@ typedef struct
 
 	GtkActionGroup *action_group;
 	RhythmDBPropType search_prop;
+	gboolean dispose_has_run;
 } RBStaticPlaylistSourcePrivate;
 
 static gpointer playlist_pixbuf = NULL;
@@ -168,14 +169,26 @@ static void
 rb_static_playlist_source_dispose (GObject *object)
 {
 	RBStaticPlaylistSourcePrivate *priv = RB_STATIC_PLAYLIST_SOURCE_GET_PRIVATE (object);
-	if (!priv)
+
+	if (priv->dispose_has_run) {
+		/* If dispose did already run, return. */
+		rb_debug ("Dispose has already run for static playlist source %p", object);
 		return;
+	}
+	/* Make sure dispose does not run twice. */
+	priv->dispose_has_run = TRUE;
+
+	rb_debug ("Disposing static playlist source %p", object);
 
-	if (priv->base_model) {
-		g_object_unref (G_OBJECT (priv->base_model));
+	if (priv->base_model != NULL) {
+		g_object_unref (priv->base_model);
 		priv->base_model = NULL;
 	}
 
+	if (priv->filter_model != NULL) {
+		g_object_unref (priv->filter_model);
+	}
+
 	G_OBJECT_CLASS (rb_static_playlist_source_parent_class)->dispose (object);
 }
 
@@ -184,6 +197,8 @@ rb_static_playlist_source_finalize (GObj
 {
 	RBStaticPlaylistSourcePrivate *priv = RB_STATIC_PLAYLIST_SOURCE_GET_PRIVATE (object);
 
+	rb_debug ("Finalizing static playlist source %p", object);
+
 	g_free (priv->search_text);
 
 	if (priv->action_group != NULL) {
@@ -194,7 +209,8 @@ rb_static_playlist_source_finalize (GObj
 }
 
 static GObject *
-rb_static_playlist_source_constructor (GType type, guint n_construct_properties,
+rb_static_playlist_source_constructor (GType type,
+				       guint n_construct_properties,
 				       GObjectConstructParam *construct_properties)
 {
 	GObjectClass *parent_class = G_OBJECT_CLASS (rb_static_playlist_source_parent_class);
@@ -207,8 +223,8 @@ rb_static_playlist_source_constructor (G
 	RhythmDBEntryType entry_type;
 
 	priv->base_model = rb_playlist_source_get_query_model (RB_PLAYLIST_SOURCE (psource));
-	g_object_set (G_OBJECT (priv->base_model), "show-hidden", TRUE, NULL);
-	g_object_ref (G_OBJECT (priv->base_model));
+	g_object_set (priv->base_model, "show-hidden", TRUE, NULL);
+	g_object_ref (priv->base_model);
 
 	priv->paned = gtk_vpaned_new ();
 
@@ -232,7 +248,7 @@ rb_static_playlist_source_constructor (G
 						entry_type);
 	g_boxed_free (RHYTHMDB_TYPE_ENTRY_TYPE, entry_type);
 	gtk_paned_pack1 (GTK_PANED (priv->paned), GTK_WIDGET (priv->browser), TRUE, FALSE);
-	g_signal_connect_object (G_OBJECT (priv->browser), "notify::output-model",
+	g_signal_connect_object (priv->browser, "notify::output-model",
 				 G_CALLBACK (rb_static_playlist_source_browser_changed_cb),
 				 source, 0);
 
@@ -241,19 +257,19 @@ rb_static_playlist_source_constructor (G
 
 	/* reparent the entry view */
 	songs = rb_source_get_entry_view (RB_SOURCE (source));
-	g_object_ref (G_OBJECT (songs));
+	g_object_ref (songs);
 	gtk_container_remove (GTK_CONTAINER (source), GTK_WIDGET (songs));
 	gtk_paned_pack2 (GTK_PANED (priv->paned), GTK_WIDGET (songs), TRUE, FALSE);
 	gtk_container_add (GTK_CONTAINER (source), priv->paned);
 	g_object_unref (songs);
 
 	/* watch these to find out when things are dropped into the entry view */
-	g_signal_connect_object (G_OBJECT (priv->base_model), "row-inserted",
-			 G_CALLBACK (rb_static_playlist_source_row_inserted),
-			 source, 0);
-	g_signal_connect_object (G_OBJECT (priv->base_model), "non-entry-dropped",
-			 G_CALLBACK (rb_static_playlist_source_non_entry_dropped),
-			 source, 0);
+	g_signal_connect_object (priv->base_model, "row-inserted",
+				 G_CALLBACK (rb_static_playlist_source_row_inserted),
+				 source, 0);
+	g_signal_connect_object (priv->base_model, "non-entry-dropped",
+				 G_CALLBACK (rb_static_playlist_source_non_entry_dropped),
+				 source, 0);
 
 	gtk_widget_show_all (GTK_WIDGET (source));
 
@@ -448,13 +464,14 @@ rb_static_playlist_source_do_query (RBSt
 	RhythmDB *db = rb_playlist_source_get_db (psource);
 	GPtrArray *query;
 
-	if (priv->filter_model)
+	if (priv->filter_model != NULL) {
 		g_object_unref (priv->filter_model);
+	}
 	priv->filter_model = rhythmdb_query_model_new_empty (db);
-	g_object_set (G_OBJECT (priv->filter_model), "base-model", priv->base_model, NULL);
+	g_object_set (priv->filter_model, "base-model", priv->base_model, NULL);
 
 	query = construct_query_from_selection (source);
-	g_object_set (G_OBJECT (priv->filter_model), "query", query, NULL);
+	g_object_set (priv->filter_model, "query", query, NULL);
 	rhythmdb_query_free (query);
 
 	rhythmdb_query_model_reapply_query (priv->filter_model, TRUE);
diff -u -p -r1.154 rb-entry-view.c
--- widgets/rb-entry-view.c	23 Jul 2006 16:05:02 -0000	1.154
+++ widgets/rb-entry-view.c	25 Jul 2006 01:43:17 -0000
@@ -423,9 +423,13 @@ rb_entry_view_finalize (GObject *object)
 		g_object_unref (view->priv->paused_pixbuf);
 	if (view->priv->error_pixbuf != NULL)
 		g_object_unref (view->priv->error_pixbuf);
-	if (view->priv->playing_entry != NULL) {
+
+	if (view->priv->playing_model != NULL) {
 		g_object_unref (view->priv->playing_model);
 	}
+	if (view->priv->model != NULL) {
+		g_object_unref (view->priv->model);
+	}
 
 	g_free (view->priv->sorting_key);
 	g_free (view->priv->sorting_column_name);
@@ -445,7 +449,7 @@ rb_entry_view_set_shell_player_internal 
 
 	view->priv->shell_player = player;
 
-	g_signal_connect_object (G_OBJECT (view->priv->shell_player),
+	g_signal_connect_object (view->priv->shell_player,
 				 "playing-song-changed",
 				 G_CALLBACK (rb_entry_view_playing_song_changed),
 				 view, 0);
@@ -456,42 +460,49 @@ rb_entry_view_set_model_internal (RBEntr
 				  RhythmDBQueryModel *model)
 {
 	if (view->priv->model != NULL) {
-		g_signal_handlers_disconnect_by_func (G_OBJECT (view->priv->model),
+		g_signal_handlers_disconnect_by_func (view->priv->model,
 						      G_CALLBACK (rb_entry_view_row_inserted_cb),
 						      view);
-		g_signal_handlers_disconnect_by_func (G_OBJECT (view->priv->model),
+		g_signal_handlers_disconnect_by_func (view->priv->model,
 						      G_CALLBACK (rb_entry_view_row_deleted_cb),
 						      view);
-		g_signal_handlers_disconnect_by_func (G_OBJECT (view->priv->model),
+		g_signal_handlers_disconnect_by_func (view->priv->model,
 						      G_CALLBACK (rb_entry_view_rows_reordered_cb),
 						      view);
+		g_object_unref (view->priv->model);
 	}
 
-	g_signal_connect_object (G_OBJECT (model),
-				 "row_inserted",
-				 G_CALLBACK (rb_entry_view_row_inserted_cb),
-				 view,
-				 0);
-	g_signal_connect_object (G_OBJECT (model),
-				 "row_deleted",
-				 G_CALLBACK (rb_entry_view_row_deleted_cb),
-				 view,
-				 0);
-	g_signal_connect_object (G_OBJECT (model),
-				 "rows_reordered",
-				 G_CALLBACK (rb_entry_view_rows_reordered_cb),
-				 view,
-				 0);
+	view->priv->model = model;
+	if (view->priv->model != NULL) {
+		g_object_ref (view->priv->model);
+		g_signal_connect_object (view->priv->model,
+					 "row_inserted",
+					 G_CALLBACK (rb_entry_view_row_inserted_cb),
+					 view,
+					 0);
+		g_signal_connect_object (view->priv->model,
+					 "row_deleted",
+					 G_CALLBACK (rb_entry_view_row_deleted_cb),
+					 view,
+					 0);
+		g_signal_connect_object (view->priv->model,
+					 "rows_reordered",
+					 G_CALLBACK (rb_entry_view_rows_reordered_cb),
+					 view,
+					 0);
+	}
 
 	gtk_tree_selection_unselect_all (view->priv->selection);
-	view->priv->model = model;
 
-	if (view->priv->sorting_column) {
+	if (view->priv->sorting_column != NULL) {
 		rb_entry_view_resort_model (view);
 	}
 
-	gtk_tree_view_set_model (GTK_TREE_VIEW (view->priv->treeview),
-				 GTK_TREE_MODEL (model));
+	if (view->priv->model != NULL) {
+		gtk_tree_view_set_model (GTK_TREE_VIEW (view->priv->treeview),
+					 GTK_TREE_MODEL (view->priv->model));
+	}
+
 	view->priv->have_selection = FALSE;
 	view->priv->have_complete_selection = FALSE;
 
@@ -548,8 +559,7 @@ rb_entry_view_get_property (GObject *obj
 {
 	RBEntryView *view = RB_ENTRY_VIEW (object);
 
-	switch (prop_id)
-	{
+	switch (prop_id) {
 	case PROP_DB:
 		g_value_set_object (value, view->priv->db);
 		break;
@@ -605,7 +615,7 @@ void
 rb_entry_view_set_model (RBEntryView *view,
 			 RhythmDBQueryModel *model)
 {
-	g_object_set (G_OBJECT (view), "model", model, NULL);
+	g_object_set (view, "model", model, NULL);
 }
 
 /* Sweet name, eh? */
@@ -1116,7 +1126,7 @@ rb_entry_view_append_column (RBEntryView
 		g_signal_connect_object (renderer,
 					 "rated",
 					 G_CALLBACK (rb_entry_view_rated_cb),
-					 G_OBJECT (view),
+					 view,
 					 0);
 		break;
 	case RB_ENTRY_VIEW_COL_PLAY_COUNT:
@@ -1207,7 +1217,7 @@ rb_entry_view_append_column (RBEntryView
 	 * width of 0.
 	 */
 	if (ellipsize) {
-		g_object_set (G_OBJECT (renderer), "ellipsize", PANGO_ELLIPSIZE_END, NULL);
+		g_object_set (renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
 		gtk_tree_view_column_set_expand (GTK_TREE_VIEW_COLUMN (column), TRUE);
 	} else if (column_width != -1) {
 		gtk_tree_view_column_set_fixed_width (column, column_width);
@@ -1256,7 +1266,7 @@ rb_entry_view_insert_column_custom (RBEn
 	gtk_tree_view_column_set_title (column, title);
 	gtk_tree_view_column_set_reorderable (column, FALSE);
 
-	g_signal_connect_object (G_OBJECT (column), "clicked",
+	g_signal_connect_object (column, "clicked",
 				 G_CALLBACK (rb_entry_view_column_clicked_cb),
 				 view, 0);
 
@@ -1314,23 +1324,23 @@ rb_entry_view_constructor (GType type,
 					     type_ahead_search_func,
 					     NULL, NULL);
 
-	g_signal_connect_object (G_OBJECT (view->priv->treeview),
+	g_signal_connect_object (view->priv->treeview,
 			         "button_press_event",
 			         G_CALLBACK (rb_entry_view_button_press_cb),
 			         view,
 				 0);
-	g_signal_connect_object (G_OBJECT (view->priv->treeview),
+	g_signal_connect_object (view->priv->treeview,
 			         "row_activated",
 			         G_CALLBACK (rb_entry_view_row_activated_cb),
 			         view,
 				 0);
-	g_signal_connect_object (G_OBJECT (view->priv->treeview),
+	g_signal_connect_object (view->priv->treeview,
 				 "popup_menu",
 				 G_CALLBACK (rb_entry_view_popup_menu_cb),
 				 view,
 				 0);
 	view->priv->selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view->priv->treeview));
-	g_signal_connect_object (G_OBJECT (view->priv->selection),
+	g_signal_connect_object (view->priv->selection,
 			         "changed",
 			         G_CALLBACK (rb_entry_view_selection_changed_cb),
 			         view,
@@ -1340,18 +1350,21 @@ rb_entry_view_constructor (GType type,
 	gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (view->priv->treeview), TRUE);
 	gtk_tree_selection_set_mode (view->priv->selection, GTK_SELECTION_MULTIPLE);
 
-	if (view->priv->is_drag_source)
+	if (view->priv->is_drag_source) {
 		rb_tree_dnd_add_drag_source_support (GTK_TREE_VIEW (view->priv->treeview),
 						     GDK_BUTTON1_MASK,
 						     rb_entry_view_drag_types,
 						     G_N_ELEMENTS (rb_entry_view_drag_types),
 						     GDK_ACTION_COPY);
-	if (view->priv->is_drag_dest)
+	}
+
+	if (view->priv->is_drag_dest) {
 		rb_tree_dnd_add_drag_dest_support (GTK_TREE_VIEW (view->priv->treeview),
 						   RB_TREE_DEST_CAN_DROP_BETWEEN | RB_TREE_DEST_EMPTY_VIEW_DROP,
 						   rb_entry_view_drag_types,
 						   G_N_ELEMENTS (rb_entry_view_drag_types),
 						   GDK_ACTION_COPY | GDK_ACTION_MOVE);
+	}
 
 	gtk_container_add (GTK_CONTAINER (view), view->priv->treeview);
 
@@ -1386,7 +1399,7 @@ rb_entry_view_constructor (GType type,
 		g_signal_connect_swapped (renderer,
 					  "pixbuf-clicked",
 					  G_CALLBACK (rb_entry_view_pixbuf_clicked_cb),
-					  G_OBJECT (view));
+					  view);
 
 		gtk_tooltips_set_tip (GTK_TOOLTIPS (tooltip), GTK_WIDGET (column->button),
 				       _("Now Playing"), NULL);
@@ -1396,14 +1409,16 @@ rb_entry_view_constructor (GType type,
 		eel_gconf_notification_add (CONF_UI_COLUMNS_SETUP,
 					    rb_entry_view_columns_config_changed_cb,
 					    view);
-	if (view->priv->sorting_key)
+	if (view->priv->sorting_key) {
 		view->priv->sorting_gconf_notification_id =
 			eel_gconf_notification_add (view->priv->sorting_key,
 						    rb_entry_view_sort_key_changed_cb,
 						    view);
+	}
 
-	if (view->priv->sorting_key)
+	if (view->priv->sorting_key) {
 		rb_entry_view_set_sorting_type (view, eel_gconf_get_string (view->priv->sorting_key));
+	}
 
 	{
 		RhythmDBQueryModel *query_model;
@@ -1940,7 +1955,7 @@ rb_entry_view_set_state (RBEntryView *vi
 			 RBEntryViewState state)
 {
 	g_return_if_fail (RB_IS_ENTRY_VIEW (view));
-	g_object_set (G_OBJECT (view), "playing-state", state, NULL);
+	g_object_set (view, "playing-state", state, NULL);
 }
 
 static void
diff -u -p -r1.16 rb-library-browser.c
--- widgets/rb-library-browser.c	23 Jul 2006 16:05:02 -0000	1.16
+++ widgets/rb-library-browser.c	25 Jul 2006 01:43:17 -0000
@@ -156,7 +156,8 @@ rb_library_browser_init (RBLibraryBrowse
 }
 
 static GObject *
-rb_library_browser_constructor (GType type, guint n_construct_properties,
+rb_library_browser_constructor (GType type,
+				guint n_construct_properties,
 				GObjectConstructParam *construct_properties)
 {
 	RBLibraryBrowserClass *klass;
@@ -206,7 +207,15 @@ rb_library_browser_finalize (GObject *ob
 
 	eel_gconf_notification_remove (priv->browser_view_notify_id);
 
-	g_object_unref (priv->db);
+	if (priv->db != NULL) {
+		g_object_unref (priv->db);
+	}
+	if (priv->input_model != NULL) {
+		g_object_unref (priv->input_model);
+	}
+	if (priv->output_model != NULL) {
+		g_object_unref (priv->output_model);
+	}
 
 	g_hash_table_destroy (priv->property_views);
 	g_hash_table_destroy (priv->selections);
@@ -270,7 +279,8 @@ rb_library_browser_get_property (GObject
 }
 
 RBLibraryBrowser *
-rb_library_browser_new (RhythmDB *db, RhythmDBEntryType entry_type)
+rb_library_browser_new (RhythmDB *db,
+			RhythmDBEntryType entry_type)
 {
 	RBLibraryBrowser *widget;
 
@@ -283,7 +293,9 @@ rb_library_browser_new (RhythmDB *db, Rh
 }
 
 static void
-update_browser_property_visibilty (RhythmDBPropType prop, RBPropertyView *view, GList *properties)
+update_browser_property_visibilty (RhythmDBPropType prop,
+				   RBPropertyView *view,
+				   GList *properties)
 {
 	gboolean old_vis, new_vis;
 
@@ -339,7 +351,8 @@ view_property_selected_cb (RBPropertyVie
 	rb_library_browser_set_selection (widget, prop, selection);
 }
 static void
-view_selection_reset_cb (RBPropertyView *view, RBLibraryBrowser *widget)
+view_selection_reset_cb (RBPropertyView *view,
+			 RBLibraryBrowser *widget)
 {
 	RhythmDBPropType prop;
 
@@ -348,7 +361,9 @@ view_selection_reset_cb (RBPropertyView 
 }
 
 static void
-reset_view_cb (RhythmDBPropType prop, RBPropertyView *view, RBLibraryBrowser *widget)
+reset_view_cb (RhythmDBPropType prop,
+	       RBPropertyView *view,
+	       RBLibraryBrowser *widget)
 {
 	rb_property_view_set_selection (view, NULL);
 }
@@ -373,7 +388,9 @@ typedef struct {
 } ConstructQueryData;
 
 static void
-construct_query_cb (RhythmDBPropType type, GList *selections, ConstructQueryData *data)
+construct_query_cb (RhythmDBPropType type,
+		    GList *selections,
+		    ConstructQueryData *data)
 {
 	rhythmdb_query_append_prop_multiple (data->db,
 					     data->query,
@@ -421,7 +438,9 @@ prop_to_index (RhythmDBPropType type)
 }
 
 static void
-ignore_selection_changes (RBLibraryBrowser *widget, RBPropertyView *view, gboolean block)
+ignore_selection_changes (RBLibraryBrowser *widget,
+			  RBPropertyView *view,
+			  gboolean block)
 {
 	if (block) {
 		g_signal_handlers_block_by_func (view, view_selection_reset_cb, widget);
@@ -471,7 +490,7 @@ restore_selection (RBLibraryBrowser *wid
 	selections = g_hash_table_lookup (priv->selections, (gpointer)browser_properties[property_index].type);
 
 	if (query_pending) {
-		g_object_ref (G_OBJECT (widget));
+		g_object_ref (widget);
 
 		data = g_new0 (SelectionRestoreData, 1);
 		data->widget = widget;
@@ -493,7 +512,9 @@ restore_selection (RBLibraryBrowser *wid
 }
 
 static void
-rebuild_child_model (RBLibraryBrowser *widget, gint property_index, gboolean query_pending)
+rebuild_child_model (RBLibraryBrowser *widget,
+		     gint property_index,
+		     gboolean query_pending)
 {
 	RBLibraryBrowserPrivate *priv = RB_LIBRARY_BROWSER_GET_PRIVATE (widget);
 	RhythmDBPropertyModel *prop_model;
@@ -508,8 +529,7 @@ rebuild_child_model (RBLibraryBrowser *w
 	/* get the query model for the previous property view */
 	view = g_hash_table_lookup (priv->property_views, (gpointer)browser_properties[property_index].type);
 	prop_model = rb_property_view_get_model (view);
-	g_object_get (G_OBJECT (prop_model), "query-model", &base_model, NULL);
-	g_object_unref (G_OBJECT (prop_model));
+	g_object_get (prop_model, "query-model", &base_model, NULL);
 
 	selections = g_hash_table_lookup (priv->selections, (gpointer)browser_properties[property_index].type);
 	if (selections != NULL) {
@@ -530,7 +550,7 @@ rebuild_child_model (RBLibraryBrowser *w
 		child_model = rhythmdb_query_model_new_empty (priv->db);
 		if (query_pending) {
 			rb_debug ("rebuilding child model for browser %d; query is pending", property_index);
-			g_object_set (G_OBJECT (child_model),
+			g_object_set (child_model,
 				      "query", query,
 				      "base-model", base_model,
 				      NULL);
@@ -544,7 +564,7 @@ rebuild_child_model (RBLibraryBrowser *w
 		rhythmdb_query_free (query);
 	} else {
 		rb_debug ("no selection for browser %d - reusing parent model", property_index);
-		child_model = base_model;
+		child_model = g_object_ref (base_model);
 	}
 
 	/* If this is the last property, use the child model as the output model
@@ -552,10 +572,12 @@ rebuild_child_model (RBLibraryBrowser *w
 	 * view.
 	 */
 	if (property_index == num_browser_properties-1) {
-		if (priv->output_model)
-			g_object_unref (G_OBJECT (priv->output_model));
+		if (priv->output_model != NULL) {
+			g_object_unref (priv->output_model);
+		}
 
 		priv->output_model = child_model;
+
 		g_object_notify (G_OBJECT (widget), "output-model");
 
 	} else {
@@ -564,7 +586,6 @@ rebuild_child_model (RBLibraryBrowser *w
 
 		prop_model = rb_property_view_get_model (view);
 		g_object_set (prop_model, "query-model", child_model, NULL);
-		g_object_unref (prop_model);
 
 		g_object_unref (base_model);
 
@@ -572,12 +593,13 @@ rebuild_child_model (RBLibraryBrowser *w
 		restore_selection (widget, property_index + 1, query_pending);
 	}
 
-	if (child_model != base_model)
-		g_object_unref (G_OBJECT (child_model));
+	g_object_unref (child_model);
 }
 
 void
-rb_library_browser_set_selection (RBLibraryBrowser *widget, RhythmDBPropType type, GList *selection)
+rb_library_browser_set_selection (RBLibraryBrowser *widget,
+				  RhythmDBPropType type,
+				  GList *selection)
 {
 	RBLibraryBrowserPrivate *priv = RB_LIBRARY_BROWSER_GET_PRIVATE (widget);
 	GList *old_selection;
@@ -610,7 +632,7 @@ rb_library_browser_get_property_views (R
 	return rb_collate_hash_table_values (priv->property_views);
 }
 
-RBPropertyView*
+RBPropertyView *
 rb_library_browser_get_property_view (RBLibraryBrowser *widget,
 				      RhythmDBPropType type)
 {
@@ -630,18 +652,21 @@ rb_library_browser_set_model (RBLibraryB
 	RBPropertyView *view;
 	RhythmDBPropertyModel *prop_model;
 
-	if (priv->input_model)
-		g_object_unref (G_OBJECT (priv->input_model));
+	if (priv->input_model != NULL) {
+		g_object_unref (priv->input_model);
+	}
 
 	priv->input_model = model;
-	g_object_ref (G_OBJECT (model));
+
+	if (priv->input_model != NULL) {
+		g_object_ref (priv->input_model);
+	}
 
 	view = g_hash_table_lookup (priv->property_views, (gpointer)browser_properties[0].type);
 	ignore_selection_changes (widget, view, TRUE);
 
 	prop_model = rb_property_view_get_model (view);
 	g_object_set (prop_model, "query-model", priv->input_model, NULL);
-	g_object_unref (prop_model);
 
 	rebuild_child_model (widget, 0, query_pending);
 	restore_selection (widget, 0, query_pending);
diff -u -p -r1.48 rb-property-view.c
--- widgets/rb-property-view.c	23 Jul 2006 16:05:03 -0000	1.48
+++ widgets/rb-property-view.c	25 Jul 2006 01:43:17 -0000
@@ -20,7 +20,7 @@
  *
  */
 
-#include <config.h>
+#include "config.h"
 
 #include <string.h>
 #include <stdlib.h>
@@ -247,11 +247,11 @@ static void
 rb_property_view_set_model_internal (RBPropertyView *view,
 				     RhythmDBPropertyModel *model)
 {
-	if (view->priv->prop_model) {
-		g_signal_handlers_disconnect_by_func (G_OBJECT (view->priv->prop_model),
+	if (view->priv->prop_model != NULL) {
+		g_signal_handlers_disconnect_by_func (view->priv->prop_model,
 						      G_CALLBACK (rb_property_view_pre_row_deleted_cb),
 						      view);
-		g_signal_handlers_disconnect_by_func (G_OBJECT (view->priv->prop_model),
+		g_signal_handlers_disconnect_by_func (view->priv->prop_model,
 						      G_CALLBACK (rb_property_view_post_row_deleted_cb),
 						      view);
 		g_object_unref (view->priv->prop_model);
@@ -286,6 +286,7 @@ rb_property_view_set_model_internal (RBP
 
 		if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (view->priv->prop_model), &iter))
 			gtk_tree_selection_select_iter (view->priv->selection, &iter);
+
 		g_signal_handlers_unblock_by_func (view->priv->selection,
 						   G_CALLBACK (rb_property_view_selection_changed_cb),
 						   view);
@@ -399,7 +400,9 @@ void
 rb_property_view_set_selection_mode (RBPropertyView *view,
 				     GtkSelectionMode mode)
 {
+	g_return_if_fail (RB_IS_PROPERTY_VIEW (view));
 	g_return_if_fail (mode == GTK_SELECTION_SINGLE || mode == GTK_SELECTION_MULTIPLE);
+
 	gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (view->priv->treeview)),
 				     mode);
 }
@@ -409,9 +412,11 @@ rb_property_view_reset (RBPropertyView *
 {
 	RhythmDBPropertyModel *model;
 
+	g_return_if_fail (RB_IS_PROPERTY_VIEW (view));
+
 	model = rhythmdb_property_model_new (view->priv->db, view->priv->propid);
 
-	g_object_set (view, "property-model", model, NULL);
+	rb_property_view_set_model_internal (view, model);
 	g_object_unref (model);
 }
 
@@ -420,15 +425,20 @@ rb_property_view_get_model (RBPropertyVi
 {
 	RhythmDBPropertyModel *model;
 
-	g_object_get (view, "property-model", &model, NULL);
+	g_return_val_if_fail (RB_IS_PROPERTY_VIEW (view), NULL);
+
+	model = view->priv->prop_model;
 
 	return model;
 }
 
 void
-rb_property_view_set_model (RBPropertyView *view, RhythmDBPropertyModel *model)
+rb_property_view_set_model (RBPropertyView *view,
+			    RhythmDBPropertyModel *model)
 {
-	g_object_set (view, "property-model", model, NULL);
+	g_return_if_fail (RB_IS_PROPERTY_VIEW (view));
+
+	rb_property_view_set_model_internal (view, model);
 }
 
 static void
@@ -465,6 +475,8 @@ rb_property_view_post_row_deleted_cb (Gt
 guint
 rb_property_view_get_num_properties (RBPropertyView *view)
 {
+	g_return_val_if_fail (RB_IS_PROPERTY_VIEW (view), 0);
+
 	return gtk_tree_model_iter_n_children (GTK_TREE_MODEL (view->priv->prop_model),
 					       NULL)-1;
 }
@@ -613,8 +625,11 @@ rb_property_view_row_activated_cb (GtkTr
 }
 
 void
-rb_property_view_set_selection (RBPropertyView *view, const GList *vals)
+rb_property_view_set_selection (RBPropertyView *view,
+				const GList *vals)
 {
+	g_return_if_fail (RB_IS_PROPERTY_VIEW (view));
+
 	view->priv->handling_row_deletion = TRUE;
 
 	gtk_tree_selection_unselect_all (view->priv->selection);
@@ -715,6 +730,8 @@ void
 rb_property_view_append_column_custom (RBPropertyView *view,
 				       GtkTreeViewColumn *column)
 {
+	g_return_if_fail (RB_IS_PROPERTY_VIEW (view));
+
 	gtk_tree_view_append_column (GTK_TREE_VIEW (view->priv->treeview), column);
 }
 
@@ -761,6 +778,8 @@ rb_property_view_set_search_func (RBProp
 				  gpointer func_data,
 				  GtkDestroyNotify notify)
 {
+	g_return_if_fail (RB_IS_PROPERTY_VIEW (view));
+
 	gtk_tree_view_set_search_equal_func (GTK_TREE_VIEW (view->priv->treeview),
 					     func, func_data,
 					     notify);
