[rhythmbox] shell-player: hold a ref on the entry while processing eos



commit 5f9035718b8c996b207d0cb908d746de4a7f1206
Author: Jonathan Matthew <jonathan d14n org>
Date:   Sat Mar 3 11:25:12 2012 +1000

    shell-player: hold a ref on the entry while processing eos
    
    We can't rely on the player backend or the internal reference to
    the entry, because we might stop the player, which drops both of
    those.  Fixes crashes when playing special purpose entries that
    aren't added to query models or kept alive any other way.

 shell/rb-shell-player.c |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)
---
diff --git a/shell/rb-shell-player.c b/shell/rb-shell-player.c
index 2eac737..e37553e 100644
--- a/shell/rb-shell-player.c
+++ b/shell/rb-shell-player.c
@@ -799,16 +799,18 @@ rb_shell_player_handle_eos_unlocked (RBShellPlayer *player, RhythmDBEntry *entry
 		return;
 	}
 
+	if (player->priv->playing_entry_eos) {
+		rb_debug ("playing entry has already EOS'd");
+		return;
+	}
+
 	if (entry != NULL) {
 		if (player->priv->playing_entry != entry) {
 			rb_debug ("EOS'd entry is not the current playing entry; ignoring");
 			return;
 		}
-	}
 
-	if (player->priv->playing_entry_eos) {
-		rb_debug ("playing entry has already EOS'd");
-		return;
+		rhythmdb_entry_ref (entry);
 	}
 
 	/* defer EOS handling while the position slider is being dragged */
@@ -816,6 +818,8 @@ rb_shell_player_handle_eos_unlocked (RBShellPlayer *player, RhythmDBEntry *entry
 	if (dragging) {
 		rb_debug ("slider is dragging, will handle EOS (if applicable) on release");
 		player->priv->playing_entry_eos = TRUE;
+		if (entry != NULL)
+			rhythmdb_entry_unref (entry);
 		return;
 	}
 
@@ -897,6 +901,9 @@ rb_shell_player_handle_eos_unlocked (RBShellPlayer *player, RhythmDBEntry *entry
 						  player->priv->db,
 						  entry);
 	}
+
+	if (entry != NULL)
+		rhythmdb_entry_unref (entry);
 }
 
 static void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]