From de25afdca7fecd69f9ac79f6a2de0c00d02b4f4a Mon Sep 17 00:00:00 2001 From: Yonit Halperin Date: Fri, 10 May 2013 16:15:00 -0400 Subject: emit_main_context macro: handle calls from both coroutine context and main context --- gtk/coroutine.h | 1 + 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); -- cgit v1.2.3