From b64b432e72a8b72c8f551bb3e98b4ad422dcb83d Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Sun, 18 Dec 2011 17:41:09 +0100 Subject: gio-coroutine: add a few more run-time checks --- gtk/gio-coroutine.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/gtk/gio-coroutine.c b/gtk/gio-coroutine.c index ff37272..7470b43 100644 --- a/gtk/gio-coroutine.c +++ b/gtk/gio-coroutine.c @@ -158,6 +158,7 @@ struct signal_data gpointer params; GSignalEmitMainFunc func; const char *debug_info; + gboolean notified; }; static gboolean emit_main_context(gpointer opaque) @@ -165,6 +166,8 @@ static gboolean emit_main_context(gpointer opaque) struct signal_data *signal = opaque; signal->func(signal->object, signal->signum, signal->params); + signal->notified = TRUE; + coroutine_yieldto(signal->caller, NULL); return FALSE; @@ -179,12 +182,15 @@ void g_signal_emit_main_context(GObject *object, { struct signal_data data; + g_return_if_fail(coroutine_self()->caller); + data.object = object; data.caller = coroutine_self(); data.signum = signum; data.params = params; data.func = emit_main_func; data.debug_info = debug_info; + data.notified = FALSE; g_idle_add(emit_main_context, &data); /* This switches to the system coroutine context, lets @@ -194,6 +200,7 @@ void g_signal_emit_main_context(GObject *object, * an idle function involved */ coroutine_yield(NULL); + g_warn_if_fail(data.notified); } static gboolean notify_main_context(gpointer opaque) @@ -201,6 +208,8 @@ static gboolean notify_main_context(gpointer opaque) struct signal_data *signal = opaque; g_object_notify(signal->object, signal->params); + signal->notified = TRUE; + coroutine_yieldto(signal->caller, NULL); return FALSE; @@ -212,9 +221,12 @@ void g_object_notify_main_context(GObject *object, { struct signal_data data; + g_return_if_fail(coroutine_self()->caller); + data.object = object; data.caller = coroutine_self(); data.params = (gpointer)property_name; + data.notified = FALSE; g_idle_add(notify_main_context, &data); @@ -225,4 +237,5 @@ void g_object_notify_main_context(GObject *object, * an idle function involved */ coroutine_yield(NULL); + g_warn_if_fail(data.notified); } -- cgit v1.2.3