From 116d1cd28fee69c154790c6adf388fcd1f764809 Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Sat, 4 Apr 2015 09:55:19 -0400 Subject: [PATCH] deck: Make sure that Q_NOTIFY_REMOVE is set TempQueues need this to tell the GUI when they have been removed. Signed-off-by: Anna Schumaker --- core/deck.cpp | 2 +- tests/core/deck.cpp | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/core/deck.cpp b/core/deck.cpp index 2d8fa939..04642184 100644 --- a/core/deck.cpp +++ b/core/deck.cpp @@ -29,7 +29,7 @@ static File deck_file("deck", 1); TempQueue :: TempQueue() {} TempQueue :: TempQueue(bool random) - : Queue(Q_ENABLED | (random ? Q_RANDOM : 0)) {} + : Queue(Q_ENABLED | (random ? Q_RANDOM : 0) | Q_NOTIFY_REMOVE) {} void TempQueue :: set_flag(queue_flags flag) { diff --git a/tests/core/deck.cpp b/tests/core/deck.cpp index 9dac49c7..c1a03654 100644 --- a/tests/core/deck.cpp +++ b/tests/core/deck.cpp @@ -61,16 +61,21 @@ static void test_init() } static unsigned int n = 0; -static void on_queue_removed(Queue *queue) -{ - n++; -} +static class TestNotifier : public QNotifier { +public: + TestNotifier() : QNotifier() {} + void on_remove() { n++; } + void on_track_added(unsigned int i) {} + void on_track_removed(unsigned int i) {} + void on_track_updated(unsigned int i) {} +} test_notifier; static void test_create_mv_destroy() { Queue *q1, *q2; q1 = deck :: create(true); + q1->set_notifier(&test_notifier); test_not_equal(q1, Q_NULL); test_equal(q1->has_flag(Q_ENABLED), true); test_equal(q1->has_flag(Q_RANDOM), true); @@ -78,6 +83,7 @@ static void test_create_mv_destroy() test_equal(deck :: get(2), q1); q2 = deck :: create(false); + q2->set_notifier(&test_notifier); test_not_equal(q2, Q_NULL); test_equal(q2->has_flag(Q_ENABLED), true); test_equal(q2->has_flag(Q_RANDOM), false); @@ -91,8 +97,6 @@ static void test_create_mv_destroy() deck :: move(q1, 2); test_equal(deck :: index(q1), (unsigned)2); - get_callbacks()->on_pq_removed = on_queue_removed; - deck :: destroy(q1); test_equal(n, (unsigned)1); test_equal(deck :: index(q1), (unsigned)3);