[Spice-devel,client,v2,01/10] gtk: Ignore GLib's too-new warnings where we explicitly check its version

Submitted by Francois Gouget on Oct. 19, 2016, 4:06 p.m.

Details

Message ID 1186b32b16bee3665cbd13f7492d37fe186852b2.1476892275.git.fgouget@free.fr
State New
Headers show
Series "Deprecation warning cleanup" ( rev: 2 ) in Spice

Not browsing as part of any series.

Commit Message

Francois Gouget Oct. 19, 2016, 4:06 p.m.
Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
---
 src/spice-gtk-session.c | 5 +++++
 src/spice-widget-egl.c  | 3 +++
 src/spice-widget.c      | 6 ++++++
 3 files changed, 14 insertions(+)

Patch hide | download patch | download mbox

diff --git a/src/spice-gtk-session.c b/src/spice-gtk-session.c
index 3e0ec74..7ec2a57 100644
--- a/src/spice-gtk-session.c
+++ b/src/spice-gtk-session.c
@@ -126,6 +126,8 @@  static guint32 get_keyboard_lock_modifiers(void)
 {
     guint32 modifiers = 0;
 #if GTK_CHECK_VERSION(3,18,0)
+/* Ignore GLib's too-new warnings */
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
     GdkKeymap *keyboard = gdk_keymap_get_default();
 
     if (gdk_keymap_get_caps_lock_state(keyboard)) {
@@ -139,6 +141,7 @@  static guint32 get_keyboard_lock_modifiers(void)
     if (gdk_keymap_get_scroll_lock_state(keyboard)) {
         modifiers |= SPICE_INPUTS_SCROLL_LOCK;
     }
+G_GNUC_END_IGNORE_DEPRECATIONS
 #else
 #ifdef HAVE_X11_XKBLIB_H
     Display *x_display = NULL;
@@ -807,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);
diff --git a/src/spice-widget-egl.c b/src/spice-widget-egl.c
index 0698af3..3cc1098 100644
--- a/src/spice-widget-egl.c
+++ b/src/spice-widget-egl.c
@@ -303,9 +303,12 @@  gl_make_current(SpiceDisplay *display, GError **err)
     }
 #if GTK_CHECK_VERSION(3,16,0)
     else {
+        /* Ignore GLib's too-new warnings */
+        G_GNUC_BEGIN_IGNORE_DEPRECATIONS
         GtkWidget *area = gtk_stack_get_child_by_name(d->stack, "gl-area");
 
         gtk_gl_area_make_current(GTK_GL_AREA(area));
+        G_GNUC_END_IGNORE_DEPRECATIONS
     }
 #endif
 
diff --git a/src/spice-widget.c b/src/spice-widget.c
index 3ac0a7d..82adacf 100644
--- a/src/spice-widget.c
+++ b/src/spice-widget.c
@@ -567,6 +567,8 @@  static void grab_notify(SpiceDisplay *display, gboolean was_grabbed)
 
 #if GTK_CHECK_VERSION(3,16,0)
 #ifndef G_OS_WIN32
+/* Ignore GLib's too-new warnings */
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
 static gboolean
 gl_area_render(GtkGLArea *area, GdkGLContext *context, gpointer user_data)
 {
@@ -598,6 +600,7 @@  gl_area_realize(GtkGLArea *area, gpointer user_data)
         g_clear_error(&err);
     }
 }
+G_GNUC_END_IGNORE_DEPRECATIONS
 #endif
 #endif
 
@@ -636,6 +639,8 @@  static void spice_display_init(SpiceDisplay *display)
 
 #if GTK_CHECK_VERSION(3,16,0)
 #ifndef G_OS_WIN32
+/* Ignore GLib's too-new warnings */
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
     area = gtk_gl_area_new();
     gtk_gl_area_set_required_version(GTK_GL_AREA(area), 3, 2);
     gtk_gl_area_set_auto_render(GTK_GL_AREA(area), false);
@@ -645,6 +650,7 @@  static void spice_display_init(SpiceDisplay *display)
                      NULL);
     gtk_stack_add_named(d->stack, area, "gl-area");
     gtk_widget_show_all(widget);
+G_GNUC_END_IGNORE_DEPRECATIONS
 #endif
 #endif
 

Comments

On Wed, 2016-10-19 at 18:06 +0200, Francois Gouget wrote:
> Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
> ---
>  src/spice-gtk-session.c | 5 +++++
>  src/spice-widget-egl.c  | 3 +++
>  src/spice-widget.c      | 6 ++++++
>  3 files changed, 14 insertions(+)
> 
> diff --git a/src/spice-gtk-session.c b/src/spice-gtk-session.c
> index 3e0ec74..7ec2a57 100644
> --- a/src/spice-gtk-session.c
> +++ b/src/spice-gtk-session.c
> @@ -126,6 +126,8 @@ static guint32 get_keyboard_lock_modifiers(void)
>  {
>      guint32 modifiers = 0;
>  #if GTK_CHECK_VERSION(3,18,0)
> +/* Ignore GLib's too-new warnings */
> +G_GNUC_BEGIN_IGNORE_DEPRECATIONS
>      GdkKeymap *keyboard = gdk_keymap_get_default();
>  
>      if (gdk_keymap_get_caps_lock_state(keyboard)) {
> @@ -139,6 +141,7 @@ static guint32 get_keyboard_lock_modifiers(void)
>      if (gdk_keymap_get_scroll_lock_state(keyboard)) {
>          modifiers |= SPICE_INPUTS_SCROLL_LOCK;
>      }
> +G_GNUC_END_IGNORE_DEPRECATIONS
>  #else
>  #ifdef HAVE_X11_XKBLIB_H
>      Display *x_display = NULL;
> @@ -807,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

As far as I can see, this hunk doesn't have an explicit gtk version
check around it. Why do you need to disable deprecation warnings here?


>  
>  cleanup:
>      g_clear_pointer(&ri.loop, g_main_loop_unref);
> diff --git a/src/spice-widget-egl.c b/src/spice-widget-egl.c
> index 0698af3..3cc1098 100644
> --- a/src/spice-widget-egl.c
> +++ b/src/spice-widget-egl.c
> @@ -303,9 +303,12 @@ gl_make_current(SpiceDisplay *display, GError
> **err)
>      }
>  #if GTK_CHECK_VERSION(3,16,0)
>      else {
> +        /* Ignore GLib's too-new warnings */
> +        G_GNUC_BEGIN_IGNORE_DEPRECATIONS
>          GtkWidget *area = gtk_stack_get_child_by_name(d->stack, "gl-
> area");
>  
>          gtk_gl_area_make_current(GTK_GL_AREA(area));
> +        G_GNUC_END_IGNORE_DEPRECATIONS
>      }
>  #endif
>  
> diff --git a/src/spice-widget.c b/src/spice-widget.c
> index 3ac0a7d..82adacf 100644
> --- a/src/spice-widget.c
> +++ b/src/spice-widget.c
> @@ -567,6 +567,8 @@ static void grab_notify(SpiceDisplay *display,
> gboolean was_grabbed)
>  
>  #if GTK_CHECK_VERSION(3,16,0)
>  #ifndef G_OS_WIN32
> +/* Ignore GLib's too-new warnings */
> +G_GNUC_BEGIN_IGNORE_DEPRECATIONS
>  static gboolean
>  gl_area_render(GtkGLArea *area, GdkGLContext *context, gpointer
> user_data)
>  {
> @@ -598,6 +600,7 @@ gl_area_realize(GtkGLArea *area, gpointer
> user_data)
>          g_clear_error(&err);
>      }
>  }
> +G_GNUC_END_IGNORE_DEPRECATIONS
>  #endif
>  #endif
>  
> @@ -636,6 +639,8 @@ static void spice_display_init(SpiceDisplay
> *display)
>  
>  #if GTK_CHECK_VERSION(3,16,0)
>  #ifndef G_OS_WIN32
> +/* Ignore GLib's too-new warnings */
> +G_GNUC_BEGIN_IGNORE_DEPRECATIONS
>      area = gtk_gl_area_new();
>      gtk_gl_area_set_required_version(GTK_GL_AREA(area), 3, 2);
>      gtk_gl_area_set_auto_render(GTK_GL_AREA(area), false);
> @@ -645,6 +650,7 @@ static void spice_display_init(SpiceDisplay
> *display)
>                       NULL);
>      gtk_stack_add_named(d->stack, area, "gl-area");
>      gtk_widget_show_all(widget);
> +G_GNUC_END_IGNORE_DEPRECATIONS
>  #endif
>  #endif
>
On Thu, 20 Oct 2016, Jonathon Jongsma wrote:
[...]
> > @@ -807,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
> 
> As far as I can see, this hunk doesn't have an explicit gtk version
> check around it. Why do you need to disable deprecation warnings here?

Sorry. That hunk should not have been in that patch.

The reason it's needed is that gdk_threads_{enter,leave}() are 
deprecated since 3.6: all GDK and GTK+ calls should be made from the 
main thread. That code is pretty old (91eeacbe 2011-10-04) so I don't 
know if it's really still needed or was a GTK 2 thing.