From 0028a7a8411ff420bc9dbeceff16faf36fcc1bcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 5 Nov 2024 09:08:29 +0200 Subject: [PATCH] pango: Fix `LayoutLine::x_ranges()` bindings The returned array has 2*n_ranges elements, not just n_ranges. Fixes https://github.com/gtk-rs/gtk-rs-core/issues/1563 --- pango/Gir.toml | 3 +++ pango/src/auto/layout_line.rs | 17 ----------------- pango/src/layout.rs | 17 +++++++++++++++++ 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/pango/Gir.toml b/pango/Gir.toml index 559179c13703..cf3136ac5a65 100644 --- a/pango/Gir.toml +++ b/pango/Gir.toml @@ -383,6 +383,9 @@ status = "generate" [[object.function]] name = "x_to_index" manual = true + [[object.function]] + name = "get_x_ranges" + manual = true [[object]] name = "Pango.Matrix" diff --git a/pango/src/auto/layout_line.rs b/pango/src/auto/layout_line.rs index c077e5b562da..4ed931430529 100644 --- a/pango/src/auto/layout_line.rs +++ b/pango/src/auto/layout_line.rs @@ -90,23 +90,6 @@ impl LayoutLine { unsafe { ffi::pango_layout_line_get_start_index(self.to_glib_none().0) } } - #[doc(alias = "pango_layout_line_get_x_ranges")] - #[doc(alias = "get_x_ranges")] - pub fn x_ranges(&self, start_index: i32, end_index: i32) -> Vec { - unsafe { - let mut ranges = std::ptr::null_mut(); - let mut n_ranges = std::mem::MaybeUninit::uninit(); - ffi::pango_layout_line_get_x_ranges( - self.to_glib_none().0, - start_index, - end_index, - &mut ranges, - n_ranges.as_mut_ptr(), - ); - FromGlibContainer::from_glib_full_num(ranges, n_ranges.assume_init() as _) - } - } - #[doc(alias = "pango_layout_line_index_to_x")] pub fn index_to_x(&self, index_: i32, trailing: bool) -> i32 { unsafe { diff --git a/pango/src/layout.rs b/pango/src/layout.rs index bfc16cbba8f1..dc56cc789ca8 100644 --- a/pango/src/layout.rs +++ b/pango/src/layout.rs @@ -90,4 +90,21 @@ impl LayoutLine { is_inside, } } + + #[doc(alias = "pango_layout_line_get_x_ranges")] + #[doc(alias = "get_x_ranges")] + pub fn x_ranges(&self, start_index: i32, end_index: i32) -> Vec { + unsafe { + let mut ranges = std::ptr::null_mut(); + let mut n_ranges = std::mem::MaybeUninit::uninit(); + ffi::pango_layout_line_get_x_ranges( + self.to_glib_none().0, + start_index, + end_index, + &mut ranges, + n_ranges.as_mut_ptr(), + ); + FromGlibContainer::from_glib_full_num(ranges, 2 * n_ranges.assume_init() as usize) + } + } }