pentamassiv / gtk4-layer-shell-gir

Unsafe bindings and a safe wrapper for gtk4-layer-shell, automatically generated from a .gir file
MIT License
21 stars 1 forks source link

Tooltips cause segfaults. #22

Closed elijahimmer closed 8 months ago

elijahimmer commented 8 months ago

Description

having tool tips, via WidgetExt::set_tooltip_text(), setting the text in a widget builder, or connecting to the query tool tip widget causes a segfault when the tooltip is shown.

I made a basic example at https://github.com/elijahimmer/layer-shell-tt-test

This includes both GTK3 (which works) and GTK4 test. This only happens when init_layer_shell() is on the window, and applies to any widgets in the window as far as I have tested.

Tested on the compositor: Hyprland Operating system: Nixos Lib

Reproducible Code

use gtk4::prelude::*;
use gtk4::{Application, ApplicationWindow, Label};
use gtk4_layer_shell::LayerShell;

fn main() {
    let application = Application::builder()
        .application_id("segfault.please")
        .build();

    application.connect_activate(|app| {
        let label = Label::new(Some("Does the Tooltip work?"));

        let window = ApplicationWindow::builder()
            .application(app)
            .tooltip_text("test")
            .child(&label)
            .build();

        window.init_layer_shell();

        window.present();
    });

    application.run();
}

All you have to do is hover over the text to cause a tooltip to appear. In the repo https://github.com/elijahimmer/layer-shell-tt-test I also ported it to GTK3 and it works fine.

This looks like it could be a similar issue to #21 because they are both signal based, (well, I guess signals are basically everything in GTK)

EDIT 1: I added a few more tests to the repo, and the issue only occurs if the tooltip is actually show, I used WidgetExt::connect_query_tooltip() and when the inner function returns false (don't show) it doesn't crash. I don't know enough about how GTK or the layer shell works to do more than speculate about what is happening.

I think this could be a upstream issue, but I haven't tested it in C so I didn't wanna go upstream per-maturely. Also: Awesome library bindings, thanks for all you work.

pentamassiv commented 8 months ago

I don't think this is an issue with the Rust wrapper, but with the underlying C library. There is an issue that looks related: https://github.com/wmww/gtk4-layer-shell

elijahimmer commented 8 months ago

I didn't check the closed issues, I see it now, I thought it was upstream but I didn't see the issue and didn't wanna go to upstream prematurely. Thanks for the quick response.

pentamassiv commented 8 months ago

No worries :-)