[Spice-devel] [PATCH spice-gtk 2/6] gio-coroutine: add a few more run-time checks

Marc-André Lureau marcandre.lureau at gmail.com
Sun Dec 18 09:27:21 PST 2011


---
 gtk/gio-coroutine.c |   13 +++++++++++++
 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);
 }
-- 
1.7.7.4



More information about the Spice-devel mailing list