slint-ui / slint

Slint is a declarative GUI toolkit to build native user interfaces for Rust, C++, or JavaScript apps.
https://slint.dev
Other
17.31k stars 585 forks source link

`slint::quit_event_loop()` causes QObject Timers error #6627

Open DASPRiD opened 3 hours ago

DASPRiD commented 3 hours ago

Given the following (overly simplified) example:

let app_window = AppWindow::new()?;

app_window.window().on_close_requested(|| {
    // Ignore that this is here, it's actually in a completely different part of
    // my program, but for simplicity I have it here.
    let _ = slint::quit_event_loop();
    CloseRequestResponse::HideWindow
});

std::thread::spawn({
    let handle = app_window.as_ref();
    move || {
        std::thread::sleep(Duration::from_secs(1));

        handle.upgrade_in_event_loop(|handle| {
            handle.show().unwrap();
        }).unwrap();
    }
})

slint::run_event_loop_until_quit()?;

Once I close the window to trigger slint::quit_event_loop(), the program exits as expected (with exit code 0), but emits the following error message, which I assume is coming from QT:

QObject::~QObject: Timers cannot be stopped from another thread

I also once saw the following message instead, though I couldn't reproduce that since:

QMutex: destroying locked mutex

DASPRiD commented 2 hours ago

My current workaround is to simply disable the QT backend and use winit on all systems, I guess there's not really any downside to that?