summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2011-12-18 17:41:09 +0100
committerMarc-André Lureau <marcandre.lureau@redhat.com>2011-12-19 13:06:43 +0100
commitb64b432e72a8b72c8f551bb3e98b4ad422dcb83d (patch)
tree782e023708be2c7a5c489eb56ec4c59de024df0a
parent234a8fcce2a339f86dd9247c78f04dea85e8ad87 (diff)
gio-coroutine: add a few more run-time checks
-rw-r--r--gtk/gio-coroutine.c13
1 files changed, 13 insertions, 0 deletions
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);
}