Re: [PATCH] Make sure property notifications are done in the main context

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




----- Original Message -----
> Modify g_object_notify_main_conetxt() to work whether it's called from the
> main
> context or a coroutine context.  Change object notify calls in SpiceSession
> to
> use g_object_notify_main_context() instead of g_object_notify().

ack

> ---
>  gtk/gio-coroutine.c | 37 ++++++++++++++++++++-----------------
>  gtk/spice-session.c |  8 ++++----
>  2 files changed, 24 insertions(+), 21 deletions(-)
> 
> diff --git a/gtk/gio-coroutine.c b/gtk/gio-coroutine.c
> index 355c75c..dd2b9fc 100644
> --- a/gtk/gio-coroutine.c
> +++ b/gtk/gio-coroutine.c
> @@ -252,21 +252,24 @@ 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);
> -
> -    /* This switches to the system coroutine context, lets
> -     * the idle function run to dispatch the signal, and
> -     * finally returns once complete. ie this is synchronous
> -     * from the POV of the coroutine despite there being
> -     * an idle function involved
> -     */
> -    coroutine_yield(NULL);
> -    g_warn_if_fail(data.notified);
> +    if (IN_MAIN_CONTEXT) {
> +        g_object_notify(object, property_name);
> +    } else {
> +
> +        data.object = object;
> +        data.caller = coroutine_self();
> +        data.params = (gpointer)property_name;
> +        data.notified = FALSE;
> +
> +        g_idle_add(notify_main_context, &data);
> +
> +        /* This switches to the system coroutine context, lets
> +         * the idle function run to dispatch the signal, and
> +         * finally returns once complete. ie this is synchronous
> +         * from the POV of the coroutine despite there being
> +         * an idle function involved
> +         */
> +        coroutine_yield(NULL);
> +        g_warn_if_fail(data.notified);
> +    }
>  }
> diff --git a/gtk/spice-session.c b/gtk/spice-session.c
> index 79a13de..bcbba27 100644
> --- a/gtk/spice-session.c
> +++ b/gtk/spice-session.c
> @@ -608,7 +608,7 @@ static void spice_session_set_property(GObject
> *gobject,
>          break;
>      case PROP_READ_ONLY:
>          s->read_only = g_value_get_boolean(value);
> -        g_object_notify(gobject, "read-only");
> +        g_object_notify_main_context(gobject, "read-only");
>          break;
>      case PROP_CACHE_SIZE:
>          s->images_cache_size = g_value_get_int(value);
> @@ -2033,7 +2033,7 @@ void spice_session_set_migration_state(SpiceSession
> *session, SpiceSessionMigrat
>  
>      g_return_if_fail(s != NULL);
>      s->migration_state = state;
> -    g_object_notify(G_OBJECT(session), "migration-state");
> +    g_object_notify_main_context(G_OBJECT(session), "migration-state");
>  }
>  
>  G_GNUC_INTERNAL
> @@ -2128,7 +2128,7 @@ void spice_session_set_uuid(SpiceSession *session,
> guint8 uuid[16])
>      g_return_if_fail(s != NULL);
>      memcpy(s->uuid, uuid, sizeof(s->uuid));
>  
> -    g_object_notify(G_OBJECT(session), "uuid");
> +    g_object_notify_main_context(G_OBJECT(session), "uuid");
>  }
>  
>  G_GNUC_INTERNAL
> @@ -2140,7 +2140,7 @@ void spice_session_set_name(SpiceSession *session,
> const gchar *name)
>      g_free(s->name);
>      s->name = g_strdup(name);
>  
> -    g_object_notify(G_OBJECT(session), "name");
> +    g_object_notify_main_context(G_OBJECT(session), "name");
>  }
>  
>  G_GNUC_INTERNAL
> --
> 1.8.3.1
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel@xxxxxxxxxxxxxxxxxxxxx
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
> 
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]