[Spice-devel] [PATCH spice-gtk 05/15] Fix deprecation warning handling

Daniel P. Berrange berrange at redhat.com
Tue Mar 13 06:40:03 PDT 2012


From: "Daniel P. Berrange" <berrange at redhat.com>

Various methods are deprecated by using the G_GNUC_DEPRECATED_FOR
macro. Unfortunately this macro was placed in the .c file impl,
instead of the .h file decl. Thus applications building against
SPICE-GTK would never see the deprecation warnings. At the same
time, building SPICE-GTK itself would trigger some of the warnings
preventing use of -Wdeprecated-declarations to detect use of
deprecated GTK functions.

The fix is in multiple parts

 * Replace calls to G_GNUC_DEPRECATED_FOR with SPICE_DEPRECATED_FOR
 * Move macros from .c to .h files
 * Turn SPICE_DEPRECATED_FOR into a no-op if SPICE_NO_DEPRECATED
   is defined
 * Define SPICE_NO_DEPRECATED when building
---
 gtk/Makefile.am    |    1 +
 gtk/channel-main.c |    4 ----
 gtk/channel-main.h |    4 ++++
 gtk/spice-audio.c  |    1 -
 gtk/spice-audio.h  |    1 +
 gtk/spice-util.h   |    7 +++++++
 gtk/spice-widget.c |    2 --
 gtk/spice-widget.h |    2 ++
 8 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/gtk/Makefile.am b/gtk/Makefile.am
index 2057b5a..2f7d4ae 100644
--- a/gtk/Makefile.am
+++ b/gtk/Makefile.am
@@ -57,6 +57,7 @@ EXTRA_DIST += $(KEYMAPS)
 
 SPICE_COMMON_CPPFLAGS = \
 	-DG_LOG_DOMAIN=\"GSpice\"       \
+	-DSPICE_NO_DEPRECATED		\
 	-DSW_CANVAS_CACHE		\
 	-DSPICE_GTK_LOCALEDIR=\"${SPICE_GTK_LOCALEDIR}\" \
 	-DPNP_IDS=\""$(PNP_IDS)"\"\
diff --git a/gtk/channel-main.c b/gtk/channel-main.c
index dbe78d9..745e954 100644
--- a/gtk/channel-main.c
+++ b/gtk/channel-main.c
@@ -1809,7 +1809,6 @@ void spice_main_set_display(SpiceMainChannel *channel, int id,
  *
  * Deprecated: 0.6: use spice_main_clipboard_selection_grab() instead.
  **/
-G_GNUC_DEPRECATED_FOR(spice_main_clipboard_selection_grab)
 void spice_main_clipboard_grab(SpiceMainChannel *channel, guint32 *types, int ntypes)
 {
     spice_main_clipboard_selection_grab(channel, VD_AGENT_CLIPBOARD_SELECTION_CLIPBOARD, types, ntypes);
@@ -1845,7 +1844,6 @@ void spice_main_clipboard_selection_grab(SpiceMainChannel *channel, guint select
  *
  * Deprecated: 0.6: use spice_main_clipboard_selection_release() instead.
  **/
-G_GNUC_DEPRECATED_FOR(spice_main_clipboard_selection_release)
 void spice_main_clipboard_release(SpiceMainChannel *channel)
 {
     spice_main_clipboard_selection_release(channel, VD_AGENT_CLIPBOARD_SELECTION_CLIPBOARD);
@@ -1886,7 +1884,6 @@ void spice_main_clipboard_selection_release(SpiceMainChannel *channel, guint sel
  *
  * Deprecated: 0.6: use spice_main_clipboard_selection_notify() instead.
  **/
-G_GNUC_DEPRECATED_FOR(spice_main_clipboard_selection_notify)
 void spice_main_clipboard_notify(SpiceMainChannel *channel,
                                  guint32 type, const guchar *data, size_t size)
 {
@@ -1926,7 +1923,6 @@ void spice_main_clipboard_selection_notify(SpiceMainChannel *channel, guint sele
  *
  * Deprecated: 0.6: use spice_main_clipboard_selection_request() instead.
  **/
-G_GNUC_DEPRECATED_FOR(spice_main_clipboard_selection_request)
 void spice_main_clipboard_request(SpiceMainChannel *channel, guint32 type)
 {
     spice_main_clipboard_selection_request(channel, VD_AGENT_CLIPBOARD_SELECTION_CLIPBOARD, type);
diff --git a/gtk/channel-main.h b/gtk/channel-main.h
index ae3f241..197c8d5 100644
--- a/gtk/channel-main.h
+++ b/gtk/channel-main.h
@@ -73,9 +73,13 @@ void spice_main_set_display(SpiceMainChannel *channel, int id,
 void spice_main_set_display_enabled(SpiceMainChannel *channel, int id, gboolean enabled);
 gboolean spice_main_send_monitor_config(SpiceMainChannel *channel);
 
+SPICE_DEPRECATED_FOR(spice_main_clipboard_selection_grab)
 void spice_main_clipboard_grab(SpiceMainChannel *channel, guint32 *types, int ntypes);
+SPICE_DEPRECATED_FOR(spice_main_clipboard_selection_release)
 void spice_main_clipboard_release(SpiceMainChannel *channel);
+SPICE_DEPRECATED_FOR(spice_main_clipboard_selection_notify)
 void spice_main_clipboard_notify(SpiceMainChannel *channel, guint32 type, const guchar *data, size_t size);
+SPICE_DEPRECATED_FOR(spice_main_clipboard_selection_request)
 void spice_main_clipboard_request(SpiceMainChannel *channel, guint32 type);
 
 void spice_main_clipboard_selection_grab(SpiceMainChannel *channel, guint selection, guint32 *types, int ntypes);
diff --git a/gtk/spice-audio.c b/gtk/spice-audio.c
index 3d6e34c..30c2920 100644
--- a/gtk/spice-audio.c
+++ b/gtk/spice-audio.c
@@ -204,7 +204,6 @@ static void session_enable_audio(GObject *gobject, GParamSpec *pspec,
  * Returns: a new #SpiceAudio instance or %NULL if no backend or failed.
  * Deprecated: 0.8: Use spice_audio_get() instead
  **/
-G_GNUC_DEPRECATED_FOR(spice_audio_get)
 SpiceAudio *spice_audio_new(SpiceSession *session, GMainContext *context,
                             const char *name)
 {
diff --git a/gtk/spice-audio.h b/gtk/spice-audio.h
index 1709227..ab8a1be 100644
--- a/gtk/spice-audio.h
+++ b/gtk/spice-audio.h
@@ -73,6 +73,7 @@ struct _SpiceAudioClass {
 
 GType spice_audio_get_type(void);
 
+SPICE_DEPRECATED_FOR(spice_audio_get)
 SpiceAudio* spice_audio_new(SpiceSession *session, GMainContext *context, const char *name);
 
 SpiceAudio* spice_audio_get(SpiceSession *session, GMainContext *context);
diff --git a/gtk/spice-util.h b/gtk/spice-util.h
index aace4b6..5bd24d3 100644
--- a/gtk/spice-util.h
+++ b/gtk/spice-util.h
@@ -39,6 +39,13 @@ gulong spice_g_signal_connect_object(gpointer instance,
 
 #define SPICE_RESERVED_PADDING 44
 
+#ifndef SPICE_NO_DEPRECATED
+#define SPICE_DEPRECATED_FOR(f) \
+    G_GNUC_DEPRECATED_FOR(f)
+#else
+#define SPICE_DEPRECATED_FOR(f)
+#endif
+
 G_END_DECLS
 
 #endif /* SPICE_UTIL_H */
diff --git a/gtk/spice-widget.c b/gtk/spice-widget.c
index c502732..fb40d1a 100644
--- a/gtk/spice-widget.c
+++ b/gtk/spice-widget.c
@@ -1900,7 +1900,6 @@ void spice_display_mouse_ungrab(SpiceDisplay *display)
  *
  * Deprecated: 0.8: Use spice_gtk_session_copy_to_guest() instead
  **/
-G_GNUC_DEPRECATED_FOR(spice_gtk_session_copy_to_guest)
 void spice_display_copy_to_guest(SpiceDisplay *display)
 {
     SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
@@ -1918,7 +1917,6 @@ void spice_display_copy_to_guest(SpiceDisplay *display)
  *
  * Deprecated: 0.8: Use spice_gtk_session_paste_from_guest() instead
  **/
-G_GNUC_DEPRECATED_FOR(spice_gtk_session_paste_from_guest)
 void spice_display_paste_from_guest(SpiceDisplay *display)
 {
     SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
diff --git a/gtk/spice-widget.h b/gtk/spice-widget.h
index 4ea0976..b7f185f 100644
--- a/gtk/spice-widget.h
+++ b/gtk/spice-widget.h
@@ -72,7 +72,9 @@ GType	        spice_display_get_type(void);
 
 SpiceDisplay* spice_display_new(SpiceSession *session, int id);
 void spice_display_mouse_ungrab(SpiceDisplay *display);
+SPICE_DEPRECATED_FOR(spice_gtk_session_copy_to_guest)
 void spice_display_copy_to_guest(SpiceDisplay *display);
+SPICE_DEPRECATED_FOR(spice_gtk_session_paste_from_guest)
 void spice_display_paste_from_guest(SpiceDisplay *display);
 void spice_display_set_grab_keys(SpiceDisplay *display, SpiceGrabSequence *seq);
 SpiceGrabSequence *spice_display_get_grab_keys(SpiceDisplay *display);
-- 
1.7.7.6



More information about the Spice-devel mailing list