[rhythmbox] shuffle: don't move the playing entry when handling query model changes
- From: Jonathan Matthew <jmatthew src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rhythmbox] shuffle: don't move the playing entry when handling query model changes
- Date: Sun, 15 Mar 2015 12:14:18 +0000 (UTC)
commit c2fbbd42cc15c8c69300af5a8045a4306df16a3a
Author: Jonathan Matthew <jonathan d14n org>
Date: Sun Mar 15 22:11:58 2015 +1000
shuffle: don't move the playing entry when handling query model changes
If the current playing entry is present in the new query model, then
we want to leave it in its current location, as parts of the shuffle
logic rely on it remaining there.
shell/rb-play-order-shuffle.c | 16 ++++++++++++++--
1 files changed, 14 insertions(+), 2 deletions(-)
---
diff --git a/shell/rb-play-order-shuffle.c b/shell/rb-play-order-shuffle.c
index 42de0e8..60bdae2 100644
--- a/shell/rb-play-order-shuffle.c
+++ b/shell/rb-play-order-shuffle.c
@@ -309,6 +309,7 @@ handle_query_model_changed (RBShufflePlayOrder *sorder)
{
GPtrArray *history;
RhythmDBEntry *entry;
+ RhythmDBEntry *playing_entry;
RhythmDBQueryModel *model;
GtkTreeIter iter;
int i;
@@ -328,15 +329,26 @@ handle_query_model_changed (RBShufflePlayOrder *sorder)
}
g_ptr_array_free (history, TRUE);
+ playing_entry = rb_play_order_get_playing_entry (RB_PLAY_ORDER (sorder));
+
model = rb_play_order_get_query_model (RB_PLAY_ORDER (sorder));
if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (model), &iter)) {
do {
entry = rhythmdb_query_model_iter_to_entry (model, &iter);
- /* hash table takes the reference we got from the query model */
- g_hash_table_insert (sorder->priv->entries_added, entry, entry);
+ if (entry == playing_entry) {
+ /* don't move the playing entry */
+ g_hash_table_remove (sorder->priv->entries_removed, entry);
+ rhythmdb_entry_unref (entry);
+ } else {
+ /* hash table takes the reference we got from the query model */
+ g_hash_table_insert (sorder->priv->entries_added, entry, entry);
+ }
} while (gtk_tree_model_iter_next (GTK_TREE_MODEL (model), &iter));
}
+ if (playing_entry)
+ rhythmdb_entry_unref (playing_entry);
+
sorder->priv->query_model_changed = FALSE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]