diff options
author | Yonit Halperin <yhalperi@redhat.com> | 2013-05-10 16:15:00 -0400 |
---|---|---|
committer | Alon Levy <alon@pobox.com> | 2013-05-13 17:40:55 +0300 |
commit | de25afdca7fecd69f9ac79f6a2de0c00d02b4f4a (patch) | |
tree | 8dd3f2b0ad740d5ee69536bcd8081f2df48bf889 | |
parent | 577263aaf4cffe260e31d19eb4b8bca1c253eff3 (diff) |
emit_main_context macro: handle calls from both coroutine context and main context
-rw-r--r-- | gtk/coroutine.h | 1 | ||||
-rw-r--r-- | gtk/spice-channel-priv.h | 12 |
2 files changed, 9 insertions, 4 deletions
diff --git a/gtk/coroutine.h b/gtk/coroutine.h index 031a97b..a9b3a87 100644 --- a/gtk/coroutine.h +++ b/gtk/coroutine.h @@ -55,6 +55,7 @@ struct coroutine #endif }; +#define IN_MAIN_CONTEXT (coroutine_self()->caller == NULL) int coroutine_init(struct coroutine *co); int coroutine_release(struct coroutine *co); diff --git a/gtk/spice-channel-priv.h b/gtk/spice-channel-priv.h index 5584662..be061c5 100644 --- a/gtk/spice-channel-priv.h +++ b/gtk/spice-channel-priv.h @@ -188,10 +188,14 @@ void spice_caps_set(GArray *caps, guint32 cap, const gchar *desc); spice_caps_set(SPICE_CHANNEL(channel)->priv->caps, cap, #cap) /* coroutine context */ -#define emit_main_context(object, event, args...) \ - G_STMT_START { \ - g_signal_emit_main_context(G_OBJECT(object), do_emit_main_context, \ - event, &((struct event) { args }), G_STRLOC); \ +#define emit_main_context(object, event, args...) \ + G_STMT_START { \ + if (IN_MAIN_CONTEXT) { \ + do_emit_main_context(G_OBJECT(object), event, &((struct event) { args })); \ + } else { \ + g_signal_emit_main_context(G_OBJECT(object), do_emit_main_context, \ + event, &((struct event) { args }), G_STRLOC); \ + } \ } G_STMT_END gchar *spice_channel_supported_string(void); |