Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] The function pango::LayoutLine::x_ranges return a malformed value #1563

Closed
GrounzerLiu opened this issue Nov 5, 2024 · 1 comment · Fixed by #1564
Closed

[BUG] The function pango::LayoutLine::x_ranges return a malformed value #1563

GrounzerLiu opened this issue Nov 5, 2024 · 1 comment · Fixed by #1564
Labels
bug Something isn't working

Comments

@GrounzerLiu
Copy link

Bug description

Pango.LayoutLine.get_x_ranges
The Pango documentation states that the length of the ranges is 2 * n_ranges.

    pub fn x_ranges(&self, start_index: i32, end_index: i32) -> Vec<i32> {
        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 _)
        }
    }

Here, FromGlibContainer::from_glib_full_num(ranges, n_ranges.assume_init() as _) should be FromGlibContainer::from_glib_full_num(ranges, (2 * n_ranges.assume_init()) as _).

@GrounzerLiu GrounzerLiu added the bug Something isn't working label Nov 5, 2024
sdroege added a commit to sdroege/gtk-rs-core that referenced this issue Nov 5, 2024
The returned array has 2*n_ranges elements, not just n_ranges.

Fixes gtk-rs#1563
@sdroege
Copy link
Member

sdroege commented Nov 5, 2024

Thanks, see #1564

sdroege added a commit to sdroege/gtk-rs-core that referenced this issue Nov 8, 2024
The returned array has 2*n_ranges elements, not just n_ranges.

Fixes gtk-rs#1563
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants