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

From: Andy Moreton <[email-masked]>
Date: Thu, 11 Jul 2019 13:52:58 +0100

On Thu 11 Jul 2019, Andy Moreton wrote:

> On Wed 10 Jul 2019, Paul Eggert wrote:
>
>> Thanks, I attempted to port that patch to MS-Windows, installed the attached,
>> and am marking this bug as done.
>
> This patch breaks SVG support on 64bit MSYS2 Windows builds, using
> librsvg 2.44.14.

The problem is that some of the dynamically loaded functionas are
actually in gio, not glib. Please install the following patch to fix it.

diff --git a/lisp/term/w32-win.el b/lisp/term/w32-win.el
index 044b82ed1e..2e45d8623b 100644
--- a/lisp/term/w32-win.el
+++ b/lisp/term/w32-win.el
@@ -278,6 +278,7 @@ libgnutls-version
 	 '(gif "libgif-5.dll" "giflib4.dll" "libungif4.dll" "libungif.dll")))
        '(svg "librsvg-2-2.dll")
        '(gdk-pixbuf "libgdk_pixbuf-2.0-0.dll")
+       '(gio "libgio-2.0-0.dll")
        '(glib "libglib-2.0-0.dll")
        '(gobject "libgobject-2.0-0.dll")
        (if (>= libgnutls-version 30400)
diff --git a/src/image.c b/src/image.c
index 3695342232..8ffb08b147 100644
--- a/src/image.c
+++ b/src/image.c
@@ -9336,22 +9336,23 @@ DEF_DLL_FN (void, g_clear_error, (GError **));
 static bool
 init_svg_functions (void)
 {
-  HMODULE library, gdklib = NULL, glib = NULL, gobject = NULL;
+  HMODULE library, gdklib = NULL, gio = NULL, glib = NULL, gobject = NULL;
 
-  if (!(glib = w32_delayed_load (Qglib))
+  if (!(gio = w32_delayed_load (Qgio))
+      || !(glib = w32_delayed_load (Qglib))
       || !(gobject = w32_delayed_load (Qgobject))
       || !(gdklib = w32_delayed_load (Qgdk_pixbuf))
       || !(library = w32_delayed_load (Qsvg)))
     {
       if (gdklib)  FreeLibrary (gdklib);
       if (gobject) FreeLibrary (gobject);
       if (glib)    FreeLibrary (glib);
+      if (gio)     FreeLibrary (gio);
       return 0;
     }
 
 #if LIBRSVG_CHECK_VERSION (2, 32, 0)
-  LOAD_DLL_FN (glib, g_file_new_for_path);
-  LOAD_DLL_FN (glib, g_memory_input_stream_new_from_data);
+  LOAD_DLL_FN (gio, g_file_new_for_path);
+  LOAD_DLL_FN (gio, g_memory_input_stream_new_from_data);
   LOAD_DLL_FN (library, rsvg_handle_new_from_stream_sync);
 #else
   LOAD_DLL_FN (library, rsvg_handle_new);
@@ -10228,6 +10229,7 @@ syms_of_image (void)
 #ifdef HAVE_NTGUI
   /* Other libraries used directly by svg code.  */
   DEFSYM (Qgdk_pixbuf, "gdk-pixbuf");
+  DEFSYM (Qgio, "gio");
   DEFSYM (Qglib, "glib");
   DEFSYM (Qgobject, "gobject");
 #endif /* HAVE_NTGUI  */