aboutsummaryrefslogtreecommitdiffstats
path: root/src/queue.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/queue.c')
-rw-r--r--src/queue.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/queue.c b/src/queue.c
index 4fe564a35..098cbcce9 100644
--- a/src/queue.c
+++ b/src/queue.c
@@ -103,7 +103,7 @@ queue_append(struct queue *queue, struct song *song, uint8_t priority)
assert(!queue_is_full(queue));
queue->items[queue->length] = (struct queue_item){
- .song = song,
+ .song = song_dup_detached(song),
.id = id,
.version = queue->version,
.priority = priority,
@@ -256,8 +256,8 @@ queue_delete(struct queue *queue, unsigned position)
assert(position < queue->length);
song = queue_get(queue, position);
- if (!song_in_database(song))
- song_free(song);
+ assert(!song_in_database(song) || song_is_detached(song));
+ song_free(song);
id = queue_position_to_id(queue, position);
order = queue_position_to_order(queue, position);
@@ -291,8 +291,9 @@ queue_clear(struct queue *queue)
for (unsigned i = 0; i < queue->length; i++) {
struct queue_item *item = &queue->items[i];
- if (!song_in_database(item->song))
- song_free(item->song);
+ assert(!song_in_database(item->song) ||
+ song_is_detached(item->song));
+ song_free(item->song);
queue->id_to_position[item->id] = -1;
}