emacs-diffs
[Top][All Lists]
Advanced

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

master 133026c: rsvg_handle_get_dimensions is deprecated in 2.52.0


From: Paul Eggert
Subject: master 133026c: rsvg_handle_get_dimensions is deprecated in 2.52.0
Date: Fri, 5 Nov 2021 14:53:23 -0400 (EDT)

branch: master
commit 133026c362eb27191d992fbf35727550804bfc96
Author: Paul Eggert <eggert@cs.ucla.edu>
Commit: Paul Eggert <eggert@cs.ucla.edu>

    rsvg_handle_get_dimensions is deprecated in 2.52.0
    
    In Bug#44655#32 (2020-11-19) it was reported that
    rsvg_handle_get_dimensions was not deprecated.  However, it became
    deprecated in librsvg 2.52.0 (2021-09-15), and because of this Emacs
    builds with --enable-gcc-warnings fail in Fedora 35 (2025-11-02)
    with the diagnostic “‘rsvg_handle_get_dimensions’ is deprecated:
    Use 'rsvg_handle_get_intrinsic_size_in_pixels' instead
    [-Werror=deprecated-declarations]”.
    * src/image.c (rsvg_handle_get_dimensions): Define as a DLL
    function only if < librsvg 2.46.0, since it’s not used
    in 2.46.0 or later.
    (svg_load_image): Use rsvg_handle_get_dimensions only if librsvg <
    2.46.0, since it isn’t needed if >= 2.46.0.
---
 src/image.c | 34 +++++++++++++++-------------------
 1 file changed, 15 insertions(+), 19 deletions(-)

diff --git a/src/image.c b/src/image.c
index 102f3a1..da6cbba 100644
--- a/src/image.c
+++ b/src/image.c
@@ -9974,14 +9974,15 @@ DEF_DLL_FN (void, rsvg_handle_get_intrinsic_dimensions,
 DEF_DLL_FN (gboolean, rsvg_handle_get_geometry_for_layer,
            (RsvgHandle *, const char *, const RsvgRectangle *,
             RsvgRectangle *, RsvgRectangle *, GError **));
+#  else
+DEF_DLL_FN (void, rsvg_handle_get_dimensions,
+           (RsvgHandle *, RsvgDimensionData *));
 #  endif
 
 #  if LIBRSVG_CHECK_VERSION (2, 48, 0)
 DEF_DLL_FN (gboolean, rsvg_handle_set_stylesheet,
            (RsvgHandle *, const guint8 *, gsize, GError **));
 #  endif
-DEF_DLL_FN (void, rsvg_handle_get_dimensions,
-           (RsvgHandle *, RsvgDimensionData *));
 DEF_DLL_FN (GdkPixbuf *, rsvg_handle_get_pixbuf, (RsvgHandle *));
 DEF_DLL_FN (int, gdk_pixbuf_get_width, (const GdkPixbuf *));
 DEF_DLL_FN (int, gdk_pixbuf_get_height, (const GdkPixbuf *));
@@ -10032,11 +10033,12 @@ init_svg_functions (void)
 #if LIBRSVG_CHECK_VERSION (2, 46, 0)
   LOAD_DLL_FN (library, rsvg_handle_get_intrinsic_dimensions);
   LOAD_DLL_FN (library, rsvg_handle_get_geometry_for_layer);
+#else
+  LOAD_DLL_FN (library, rsvg_handle_get_dimensions);
 #endif
 #if LIBRSVG_CHECK_VERSION (2, 48, 0)
   LOAD_DLL_FN (library, rsvg_handle_set_stylesheet);
 #endif
-  LOAD_DLL_FN (library, rsvg_handle_get_dimensions);
   LOAD_DLL_FN (library, rsvg_handle_get_pixbuf);
 
   LOAD_DLL_FN (gdklib, gdk_pixbuf_get_width);
@@ -10074,8 +10076,9 @@ init_svg_functions (void)
 #  if LIBRSVG_CHECK_VERSION (2, 46, 0)
 #   undef rsvg_handle_get_intrinsic_dimensions
 #   undef rsvg_handle_get_geometry_for_layer
+#  else
+#   undef rsvg_handle_get_dimensions
 #  endif
-#  undef rsvg_handle_get_dimensions
 #  if LIBRSVG_CHECK_VERSION (2, 48, 0)
 #   undef rsvg_handle_set_stylesheet
 #  endif
@@ -10110,8 +10113,9 @@ init_svg_functions (void)
        fn_rsvg_handle_get_intrinsic_dimensions
 #   define rsvg_handle_get_geometry_for_layer  \
        fn_rsvg_handle_get_geometry_for_layer
+#  else
+#   define rsvg_handle_get_dimensions fn_rsvg_handle_get_dimensions
 #  endif
-#  define rsvg_handle_get_dimensions fn_rsvg_handle_get_dimensions
 #  if LIBRSVG_CHECK_VERSION (2, 48, 0)
 #   define rsvg_handle_set_stylesheet fn_rsvg_handle_set_stylesheet
 #  endif
@@ -10386,21 +10390,13 @@ svg_load_image (struct frame *f, struct image *img, 
char *contents,
       viewbox_width = viewbox.x + viewbox.width;
       viewbox_height = viewbox.y + viewbox.height;
     }
-
-  if (viewbox_width == 0 || viewbox_height == 0)
+#else
+  /* In librsvg before 2.46.0, guess the viewbox from the image dimensions.  */
+  RsvgDimensionData dimension_data;
+  rsvg_handle_get_dimensions (rsvg_handle, &dimension_data);
+  viewbox_width = dimension_data.width;
+  viewbox_height = dimension_data.height;
 #endif
-  {
-    /* The functions used above to get the geometry of the visible
-       area of the SVG are only available in librsvg 2.46 and above,
-       so in certain circumstances this code path can result in some
-       parts of the SVG being cropped.  */
-    RsvgDimensionData dimension_data;
-
-    rsvg_handle_get_dimensions (rsvg_handle, &dimension_data);
-
-    viewbox_width = dimension_data.width;
-    viewbox_height = dimension_data.height;
-  }
 
   compute_image_size (viewbox_width, viewbox_height, img,
                       &width, &height);



reply via email to

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