fix(UI): ensure GTK calls are executed on the main thread to prevent segfaults
This commit is contained in:
@@ -91,14 +91,19 @@ pub fn get_app_info<R: Runtime>(
|
|||||||
}
|
}
|
||||||
let cloned = id.clone();
|
let cloned = id.clone();
|
||||||
|
|
||||||
std::thread::spawn(move || match crate::xdg::get_app_info(info) {
|
// GTK calls are not thread-safe and must run on the main thread.
|
||||||
Ok(info) => window.emit(&id, info),
|
// Schedule the work on the GTK/GLib main thread to avoid random segfaults.
|
||||||
Err(err) => window.emit(
|
glib::idle_add_local(move || {
|
||||||
&id,
|
let _ = match crate::xdg::get_app_info(info.clone()) {
|
||||||
Error {
|
Ok(info) => window.emit(&id, info),
|
||||||
error: err.to_string(),
|
Err(err) => window.emit(
|
||||||
},
|
&id,
|
||||||
),
|
Error {
|
||||||
|
error: err.to_string(),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
};
|
||||||
|
glib::ControlFlow::Break
|
||||||
});
|
});
|
||||||
|
|
||||||
Ok(cloned)
|
Ok(cloned)
|
||||||
|
|||||||
Reference in New Issue
Block a user