fix(UI): ensure GTK calls are executed on the main thread to prevent segfaults
This commit is contained in:
@@ -91,7 +91,10 @@ pub fn get_app_info<R: Runtime>(
|
||||
}
|
||||
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.
|
||||
// Schedule the work on the GTK/GLib main thread to avoid random segfaults.
|
||||
glib::idle_add_local(move || {
|
||||
let _ = match crate::xdg::get_app_info(info.clone()) {
|
||||
Ok(info) => window.emit(&id, info),
|
||||
Err(err) => window.emit(
|
||||
&id,
|
||||
@@ -99,6 +102,8 @@ pub fn get_app_info<R: Runtime>(
|
||||
error: err.to_string(),
|
||||
},
|
||||
),
|
||||
};
|
||||
glib::ControlFlow::Break
|
||||
});
|
||||
|
||||
Ok(cloned)
|
||||
|
||||
Reference in New Issue
Block a user