From fbd14c849ba3b492cebc71d3caadb18579b768d1 Mon Sep 17 00:00:00 2001 From: Ward from fusion-voyager-3 Date: Sat, 16 Mar 2024 02:39:49 +0300 Subject: [PATCH] move from gio thread to std thread to fix async terminal logging --- debian/changelog | 2 +- src/build_ui/mod.rs | 28 +++++++++++++++++----------- src/style.css | 1 - 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/debian/changelog b/debian/changelog index 97c7d9b..91720eb 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -pika-drivers (1.0.0-100pika4) pikauwu; urgency=medium +pika-drivers (1.0.0-100pika5) pikauwu; urgency=medium * Temp internet check fix diff --git a/src/build_ui/mod.rs b/src/build_ui/mod.rs index 36024cc..b90b929 100644 --- a/src/build_ui/mod.rs +++ b/src/build_ui/mod.rs @@ -326,7 +326,6 @@ fn get_drivers( let driver_package_removeble = driver.removeble.to_owned(); gio::spawn_blocking(move || loop { - thread::sleep(Duration::from_secs(5)); let command_installed_status = Command::new("dpkg") .args(["-s", &driver_package_ind2]) .output() @@ -336,6 +335,7 @@ fn get_drivers( } else { driver_status_loop_sender.send_blocking(false).expect("channel needs to be open") } + thread::sleep(Duration::from_secs(6)); }); let driver_package_ind = driver.driver.to_owned(); @@ -491,19 +491,22 @@ fn get_drivers( .expect("systemctl reboot failed to start"); } }); - gio::spawn_blocking(clone!(@strong log_loop_sender, @strong log_status_loop_sender, @strong driver_package_ind => move || { - let command = driver_modify(log_loop_sender, &driver_package_ind); + let log_status_loop_sender_clone = log_status_loop_sender.clone(); + let log_loop_sender_clone= log_loop_sender.clone(); + let driver_package_ind_clone = driver_package_ind.clone(); + std::thread::spawn(move || { + let command = driver_modify(log_loop_sender_clone, &driver_package_ind_clone); match command { Ok(_) => { println!("Status: Driver modify Successful"); - log_status_loop_sender.send_blocking(true).expect("The channel needs to be open."); + log_status_loop_sender_clone.send_blocking(true).expect("The channel needs to be open."); } Err(_) => { println!("Status: Driver modify Failed"); - log_status_loop_sender.send_blocking(false).expect("The channel needs to be open."); + log_status_loop_sender_clone.send_blocking(false).expect("The channel needs to be open."); } } - })); + }); })); driver_remove_button.connect_clicked(clone!(@weak driver_install_log_terminal,@weak driver_install_log_terminal_buffer, @weak driver_install_dialog, @strong log_loop_sender, @strong log_status_loop_sender, @strong driver_package_ind => move |_| { driver_install_log_terminal_buffer.delete(&mut driver_install_log_terminal_buffer.bounds().0, &mut driver_install_log_terminal_buffer.bounds().1); @@ -518,19 +521,22 @@ fn get_drivers( .expect("systemctl reboot failed to start"); } }); - gio::spawn_blocking(clone!(@strong log_loop_sender, @strong log_status_loop_sender, @strong driver_package_ind => move || { - let command = driver_modify(log_loop_sender, &driver_package_ind); + let log_status_loop_sender_clone = log_status_loop_sender.clone(); + let log_loop_sender_clone= log_loop_sender.clone(); + let driver_package_ind_clone = driver_package_ind.clone(); + std::thread::spawn(move || { + let command = driver_modify(log_loop_sender_clone, &driver_package_ind_clone); match command { Ok(_) => { println!("Status: Driver modify Successful"); - log_status_loop_sender.send_blocking(true).expect("The channel needs to be open."); + log_status_loop_sender_clone.send_blocking(true).expect("The channel needs to be open."); } Err(_) => { println!("Status: Driver modify Failed"); - log_status_loop_sender.send_blocking(false).expect("The channel needs to be open."); + log_status_loop_sender_clone.send_blocking(false).expect("The channel needs to be open."); } } - })); + }); })); // drivers_list_row.append(&driver_expander_row); diff --git a/src/style.css b/src/style.css index a9e3cf8..4f7d3cd 100644 --- a/src/style.css +++ b/src/style.css @@ -6,7 +6,6 @@ color: red; } - .startLabel { font-size: 14px; }