core/calendar-monitor: Assert more startup conditions

The calendar view thread can start spinning its own mainloop
before g_thread_new() returns, and in that case we have a NULL
thread.

Check that either the GThread is what we expect it to be, OR,
the thread is NULL and there are no messages in the queue.
This commit is contained in:
Georges Basile Stavracas Neto
2023-08-23 10:17:01 -03:00
parent 8403052d88
commit f16b0a1563
+8 -1
View File
@@ -848,7 +848,14 @@ message_queue_source_prepare (GSource *source,
queue_source = (MessageQueueSource*) source;
self = queue_source->monitor;
g_assert (GCAL_IS_THREAD (self->thread));
/*
* The prepare function can be called before g_thread_new()
* returns, and that's valid. However, in that case, no messages
* should be available in the queue, as the main thread didn't
* return execution to the mainloop yet. Protect against that.
*/
g_assert (GCAL_IS_THREAD (self->thread) ||
(!self->thread && g_async_queue_length (self->messages) == 0));
return g_async_queue_length (self->messages) > 0;
}