commit 05ebf4792e09d1d8475c6efc7711de8849e8cc1a
Author: Cole Robinson <crobinso@redhat.com>
Date:   Sun Mar 11 13:01:31 2012 -0400

    ipod: Don't call before-save handler on free'd playlist data
    
    We weren't unregistering the before-save handler when a playlist
    was removed. Move the handler register/unregister into static playlist
    code so we don't need to open code the cleanup.

diff --git a/plugins/ipod/rb-ipod-source.c b/plugins/ipod/rb-ipod-source.c
index aea499e..be3b391 100644
--- a/plugins/ipod/rb-ipod-source.c
+++ b/plugins/ipod/rb-ipod-source.c
@@ -789,7 +789,8 @@ add_rb_playlist (RBiPodSource *source, Itdb_Playlist *playlist)
                                                               source,
                                                               priv->ipod_db,
                                                               playlist,
-                                                              entry_type);
+                                                              entry_type,
+                                                              G_CALLBACK(playlist_before_save));
 	g_object_unref (entry_type);
 
 	for (it = playlist->members; it != NULL; it = it->next) {
@@ -819,9 +820,6 @@ add_rb_playlist (RBiPodSource *source, Itdb_Playlist *playlist)
 	g_signal_connect (playlist_source, "notify::base-query-model",
 			  G_CALLBACK (playlist_source_model_changed),
 			  playlist_source);
-	g_signal_connect (priv->ipod_db, "before-save",
-			  G_CALLBACK (playlist_before_save),
-			  playlist_source);
 	g_object_unref (model);
 	playlist_source_model_connect_signals (playlist_source);
 
diff --git a/plugins/ipod/rb-ipod-static-playlist-source.c b/plugins/ipod/rb-ipod-static-playlist-source.c
index a2f0248..f219c3c 100644
--- a/plugins/ipod/rb-ipod-static-playlist-source.c
+++ b/plugins/ipod/rb-ipod-static-playlist-source.c
@@ -57,6 +57,7 @@ typedef struct
 	Itdb_Playlist	*itdb_playlist;
 	RBiPodSource	*ipod_source;
 	gboolean	was_reordered;
+	gulong		before_save_handler;
 } RBIpodStaticPlaylistSourcePrivate;
 
 G_DEFINE_DYNAMIC_TYPE(RBIpodStaticPlaylistSource, rb_ipod_static_playlist_source, RB_TYPE_STATIC_PLAYLIST_SOURCE)
@@ -159,10 +160,13 @@ impl_delete_thyself (RBDisplayPage *page)
 		priv->ipod_source = NULL;
 	}
 	if (priv->ipod_db) {
+		g_signal_handler_disconnect (priv->ipod_db,
+					     priv->before_save_handler);
 		g_object_unref (priv->ipod_db);
+		priv->before_save_handler = 0;
 		priv->ipod_db = NULL;
 	}
-	
+
 	RB_DISPLAY_PAGE_CLASS (rb_ipod_static_playlist_source_parent_class)->delete_thyself (page);
 }
 
@@ -171,9 +175,11 @@ rb_ipod_static_playlist_source_new (RBShell *shell,
 				    RBiPodSource *ipod_source,
 				    RbIpodDb *ipod_db,
 				    Itdb_Playlist *playlist,
-				    RhythmDBEntryType *entry_type)
+				    RhythmDBEntryType *entry_type,
+				    GCallback before_save_cb)
 {
 	RBIpodStaticPlaylistSource *source;
+	RBIpodStaticPlaylistSourcePrivate *priv;
 
 	g_assert (RB_IS_IPOD_SOURCE (ipod_source));
 
@@ -187,6 +193,11 @@ rb_ipod_static_playlist_source_new (RBShell *shell,
 							       "itdb-playlist", playlist,
 							       NULL));
 
+	priv = IPOD_STATIC_PLAYLIST_SOURCE_GET_PRIVATE (source);
+	priv->before_save_handler = g_signal_connect (ipod_db, "before-save",
+						      G_CALLBACK (before_save_cb),
+						      source);
+
 	return source;
 }
 
diff --git a/plugins/ipod/rb-ipod-static-playlist-source.h b/plugins/ipod/rb-ipod-static-playlist-source.h
index 38afff0..bc92fd1 100644
--- a/plugins/ipod/rb-ipod-static-playlist-source.h
+++ b/plugins/ipod/rb-ipod-static-playlist-source.h
@@ -52,7 +52,8 @@ RBIpodStaticPlaylistSource *	rb_ipod_static_playlist_source_new (RBShell *shell,
 								    RBiPodSource *source,
 								    RbIpodDb *ipod_db,
 								    Itdb_Playlist *playlist,
-								    RhythmDBEntryType *entry_type);
+								    RhythmDBEntryType *entry_type,
+								    GCallback before_save_cb);
 
 Itdb_Playlist* rb_ipod_static_playlist_source_get_itdb_playlist (RBIpodStaticPlaylistSource *playlist);
 RBiPodSource* rb_ipod_static_playlist_source_get_ipod_source (RBIpodStaticPlaylistSource *playlist);
