diff --git a/CHANGELOG b/CHANGELOG index 2819852b..1157075a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,5 @@ 6.4.16: +- Let tests run without fetching album art - Don't try to read data from nonexistant playlists - Show hidden folders when selecting new images - Add preview widget to album art chooser dialog diff --git a/core/core.c b/core/core.c index 91eec0ea..85358563 100644 --- a/core/core.c +++ b/core/core.c @@ -14,7 +14,11 @@ void core_init(int *argc, char ***argv, struct core_init_data *init) { +#ifdef CONFIG_TESTING + idle_init_sync(); +#else idle_init(); +#endif /* CONFIG_TESTING */ filter_init(); tags_init(); playlist_init(init->playlist_ops); diff --git a/core/idle.c b/core/idle.c index ef673263..0db4ad1e 100644 --- a/core/idle.c +++ b/core/idle.c @@ -17,13 +17,17 @@ static unsigned int queued = 0; static unsigned int serviced = 0; +void __idle_free_task(struct idle_task *task) +{ + g_free(task); + g_atomic_int_inc(&serviced); +} + bool __idle_run_task(struct idle_task *task) { bool finished = task->idle_func(task->idle_data); - if (finished) { - g_free(task); - g_atomic_int_inc(&serviced); - } + if (finished) + __idle_free_task(task); return finished; } @@ -39,6 +43,12 @@ void idle_init() idle_pool = g_thread_pool_new(__idle_thread, NULL, 1, true, NULL); } +#ifdef CONFIG_TESTING +void idle_init_sync() +{ +} +#endif /* CONFIG_TESTING */ + void idle_deinit() { struct idle_task *task; @@ -72,9 +82,12 @@ bool idle_run_task() if (!g_queue_is_empty(&idle_queue)) { task = g_queue_pop_head(&idle_queue); - if (task->idle_sync == IDLE_ASYNC) - g_thread_pool_push(idle_pool, task, NULL); - else if (!__idle_run_task(task)) + if (task->idle_sync == IDLE_ASYNC) { + if (idle_pool) + g_thread_pool_push(idle_pool, task, NULL); + else + __idle_free_task(task); + } else if (!__idle_run_task(task)) g_queue_push_tail(&idle_queue, task); } diff --git a/include/core/idle.h b/include/core/idle.h index 0b3c12e5..4d182d81 100644 --- a/include/core/idle.h +++ b/include/core/idle.h @@ -25,6 +25,9 @@ enum idle_sync_t { /* Called to initialize the idle queue. */ void idle_init(); +#ifdef CONFIG_TESTING +void idle_init_sync(); +#endif /* CONFIG_TESTING */ /* Called to deinitialize the idle queue. */ void idle_deinit(); diff --git a/tests/core/collection.c b/tests/core/collection.c index a33b9451..34b83615 100644 --- a/tests/core/collection.c +++ b/tests/core/collection.c @@ -14,7 +14,7 @@ static void test_init() struct queue *q = collection_get_queue(); GSList *list; - idle_init(); + idle_init_sync(); filter_init(); tags_init(); playlist_init(NULL); diff --git a/tests/core/history.c b/tests/core/history.c index 28ec348c..4702faf5 100644 --- a/tests/core/history.c +++ b/tests/core/history.c @@ -14,7 +14,7 @@ static void test_init() { struct queue *q = history_get_queue(); - idle_init(); + idle_init_sync(); filter_init(); tags_init(); playlist_init(NULL); diff --git a/tests/core/playlist.c b/tests/core/playlist.c index e093d5fc..b40025e0 100644 --- a/tests/core/playlist.c +++ b/tests/core/playlist.c @@ -13,7 +13,7 @@ static void test_init() struct library *library; GSList *list; - idle_init(); + idle_init_sync(); filter_init(); tags_init(); playlist_init(NULL); diff --git a/tests/core/playlists/system.c b/tests/core/playlists/system.c index 07a7487f..b92e96d1 100644 --- a/tests/core/playlists/system.c +++ b/tests/core/playlists/system.c @@ -53,7 +53,7 @@ static void test_init() { struct library *library; - idle_init(); + idle_init_sync(); filter_init(); tags_init(); pl_system_init(NULL); diff --git a/tests/core/tags/track.c b/tests/core/tags/track.c index 656db479..edd89a7b 100644 --- a/tests/core/tags/track.c +++ b/tests/core/tags/track.c @@ -72,7 +72,7 @@ static void test_track() gchar *date; setlocale(LC_TIME, "C"); - idle_init(); + idle_init_sync(); filter_init(); tags_init(); file_init(&f, "track_tag", 0, 0); diff --git a/tests/core/tempq.c b/tests/core/tempq.c index d7c2b113..292dc280 100644 --- a/tests/core/tempq.c +++ b/tests/core/tempq.c @@ -13,7 +13,7 @@ static void test_init() { - idle_init(); + idle_init_sync(); filter_init(); tags_init(); playlist_init(NULL);