bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#35548: image.c uses deprecated rsvg_handle_write etc.


From: YAMAMOTO Mitsuharu
Subject: bug#35548: image.c uses deprecated rsvg_handle_write etc.
Date: Thu, 04 Jul 2019 13:19:03 +0900
User-agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM/1.14.9 (Goj┼Ź) APEL/10.8 EasyPG/1.0.0 Emacs/25.3 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO)

On Thu, 04 Jul 2019 12:14:08 +0900,
YAMAMOTO Mitsuharu wrote:
> 
> On Sat, 04 May 2019 04:23:32 +0900,
> Paul Eggert wrote:
> > 
> > I just upgraded my Emacs build platform to Fedora 30 and found that
> > Emacs wouldn't build when configured with --enable-gcc-warnings. The
> > problem is that starting in librsvg 2.45.1, the librsvg functions
> > rsvg_handle_write and rsvg_handle_close are deprecated, and Emacs calls
> > those functions. Although I pacified GCC by installing the attached
> > patch into Emacs master, the underlying problem is still there and an
> > rsvg expert should take a look at this at some point.
> 
> If we omit Windows DLL stuff, then the patch would be as simple as
> below.

Oops, I forgot NULL-check for filename.

                                     YAMAMOTO Mitsuharu
                                address@hidden

diff --git a/src/image.c b/src/image.c
index 6ead12166b6..726edb014dc 100644
--- a/src/image.c
+++ b/src/image.c
@@ -9490,6 +9490,22 @@ svg_load_image (struct frame *f, struct image *img, char 
*contents,
   g_type_init ();
 #endif
 
+#if LIBRSVG_CHECK_VERSION (2, 32, 0) && !defined WINDOWSNT
+  /* In order to replace rsvg_handle_write and rsvg_handle_close that
+     are deprecated in librsvg 2.45.1 (Bug#35548), we need
+     rsvg_handle_new_from_stream_sync that requires librsvg
+     2.32.0.  */
+  GInputStream *input_stream = g_memory_input_stream_new_from_data (contents,
+                                                                   size, NULL);
+  GFile *base_file = filename ? g_file_new_for_path (filename) : NULL;
+  rsvg_handle = rsvg_handle_new_from_stream_sync (input_stream, base_file,
+                                                 RSVG_HANDLE_FLAGS_NONE,
+                                                 NULL, &err);
+  if (base_file)
+    g_object_unref (base_file);
+  g_object_unref (input_stream);
+  if (err) goto rsvg_error;
+#else
   /* Make a handle to a new rsvg object.  */
   rsvg_handle = rsvg_handle_new ();
 
@@ -9499,17 +9515,6 @@ svg_load_image (struct frame *f, struct image *img, char 
*contents,
   if (filename)
     rsvg_handle_set_base_uri (rsvg_handle, filename);
 
-  /* Suppress GCC deprecation warnings starting in librsvg 2.45.1 for
-     rsvg_handle_write and rsvg_handle_close.  FIXME: Use functions
-     like rsvg_handle_new_from_gfile_sync on newer librsvg versions,
-     and remove this hack.  */
-  #if GNUC_PREREQ (4, 6, 0)
-   #pragma GCC diagnostic push
-  #endif
-  #if LIBRSVG_CHECK_VERSION (2, 45, 1) && GNUC_PREREQ (4, 2, 0)
-   #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-  #endif
-
   /* Parse the contents argument and fill in the rsvg_handle.  */
   rsvg_handle_write (rsvg_handle, (unsigned char *) contents, size, &err);
   if (err) goto rsvg_error;
@@ -9518,10 +9523,7 @@ svg_load_image (struct frame *f, struct image *img, char 
*contents,
      for further writes.  */
   rsvg_handle_close (rsvg_handle, &err);
   if (err) goto rsvg_error;
-
-  #if GNUC_PREREQ (4, 6, 0)
-   #pragma GCC diagnostic pop
-  #endif
+#endif
 
   rsvg_handle_get_dimensions (rsvg_handle, &dimension_data);
   if (! check_image_size (f, dimension_data.width, dimension_data.height))





reply via email to

[Prev in Thread] Current Thread [Next in Thread]