[Spice-devel,client,v2,01/10] gdk: Temporarily ignore clipboard_get()'s deprecation warnings

Submitted by Francois Gouget on Oct. 21, 2016, 1:41 p.m.

Details

Message ID E1bxa4Q-00013N-Ke@amboise
State New
Headers show
Series "Deprecation warning cleanup" ( rev: 3 ) in Spice

Not browsing as part of any series.

Commit Message

Francois Gouget Oct. 21, 2016, 1:41 p.m.
Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
---

Of course a better solution would be to figure out whether this is still 
needed, whether this executes in the main thread or not, etc.

 src/spice-gtk-session.c | 2 ++
 1 file changed, 2 insertions(+)

Patch hide | download patch | download mbox

diff --git a/src/spice-gtk-session.c b/src/spice-gtk-session.c
index 7bed005..7ec2a57 100644
--- a/src/spice-gtk-session.c
+++ b/src/spice-gtk-session.c
@@ -810,9 +810,11 @@  static void clipboard_get(GtkClipboard *clipboard,
 
     /* apparently, this is needed to avoid dead-lock, from
        gtk_dialog_run */
+    G_GNUC_BEGIN_IGNORE_DEPRECATIONS
     gdk_threads_leave();
     g_main_loop_run(ri.loop);
     gdk_threads_enter();
+    G_GNUC_END_IGNORE_DEPRECATIONS
 
 cleanup:
     g_clear_pointer(&ri.loop, g_main_loop_unref);

Comments

On Fri, 2016-10-21 at 15:41 +0200, Francois Gouget wrote:
> Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
> ---
> 
> Of course a better solution would be to figure out whether this is
> still 
> needed, whether this executes in the main thread or not, etc.
> 
>  src/spice-gtk-session.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/src/spice-gtk-session.c b/src/spice-gtk-session.c
> index 7bed005..7ec2a57 100644
> --- a/src/spice-gtk-session.c
> +++ b/src/spice-gtk-session.c
> @@ -810,9 +810,11 @@ static void clipboard_get(GtkClipboard
> *clipboard,
>  
>      /* apparently, this is needed to avoid dead-lock, from
>         gtk_dialog_run */
> +    G_GNUC_BEGIN_IGNORE_DEPRECATIONS
>      gdk_threads_leave();
>      g_main_loop_run(ri.loop);
>      gdk_threads_enter();
> +    G_GNUC_END_IGNORE_DEPRECATIONS
>  
>  cleanup:
>      g_clear_pointer(&ri.loop, g_main_loop_unref);


So, I just now noticed that it calls _leave() first, and then _enter()
afterwards. So the first time clipboard_get() is called, it calls
_leave() without _enter() ever having been called. It turns out that
gdk handles this case by doing a g_mutex_trylock() before unlocking the
mutex, but it still seems quite strange...  

Since this code is modeled on the implementation of gtk_dialog_run(),
and that implementation also still uses these deprecated functions, I
guess I'm OK with just ignoring these deprecations for now unless
somebody else objects.

Acked-by: Jonathon Jongsma <jjongsma@redhat.com>