Add launch crash detection with detailed error dialog, fix all warnings

This commit is contained in:
2026-02-27 20:23:10 +02:00
parent e20759d1cb
commit 11c754a8c1
16 changed files with 324 additions and 70 deletions

View File

@@ -24,6 +24,7 @@ use crate::ui::library_view::{LibraryState, LibraryView};
use crate::ui::preferences;
use crate::ui::security_report;
use crate::ui::update_dialog;
use crate::ui::widgets;
mod imp {
use super::*;
@@ -588,18 +589,46 @@ impl DriftwoodWindow {
launch_action.connect_activate(move |_, param| {
let Some(window) = window_weak.upgrade() else { return };
let Some(record_id) = param.and_then(|p| p.get::<i64>()) else { return };
let db = window.database().clone();
if let Ok(Some(record)) = db.get_appimage_by_id(record_id) {
let appimage_path = std::path::Path::new(&record.path);
match launcher::launch_appimage(&db, record_id, appimage_path, "gui_context", &[], &[]) {
launcher::LaunchResult::Started { child, method } => {
log::info!("Context menu launched: {} (PID: {}, method: {})", record.path, child.id(), method.as_str());
let toast_overlay = window.imp().toast_overlay.get().unwrap().clone();
let window_ref = window.clone();
let (path_str, app_name) = {
let db = window.database();
match db.get_appimage_by_id(record_id) {
Ok(Some(r)) => {
let name = r.app_name.clone().unwrap_or_else(|| r.filename.clone());
(r.path.clone(), name)
}
launcher::LaunchResult::Failed(msg) => {
_ => return,
}
};
glib::spawn_future_local(async move {
let path_bg = path_str.clone();
let result = gio::spawn_blocking(move || {
let bg_db = crate::core::database::Database::open().expect("DB open");
let appimage_path = std::path::Path::new(&path_bg);
launcher::launch_appimage(&bg_db, record_id, appimage_path, "gui_context", &[], &[])
}).await;
match result {
Ok(launcher::LaunchResult::Started { child, method }) => {
log::info!("Launched: {} (PID: {}, method: {})", path_str, child.id(), method.as_str());
}
Ok(launcher::LaunchResult::Crashed { exit_code, stderr, .. }) => {
log::error!("App crashed (exit {}): {}", exit_code.unwrap_or(-1), stderr);
widgets::show_crash_dialog(&window_ref, &app_name, exit_code, &stderr);
}
Ok(launcher::LaunchResult::Failed(msg)) => {
log::error!("Failed to launch: {}", msg);
let toast = adw::Toast::builder()
.title(&format!("Could not launch: {}", msg))
.timeout(5)
.build();
toast_overlay.add_toast(toast);
}
Err(_) => {
log::error!("Launch task panicked");
}
}
}
});
});
}
self.add_action(&launch_action);