From d8a18d8c67d6906a77e3f4599d4e3d384c371b46 Mon Sep 17 00:00:00 2001 From: bisspector Date: Mon, 25 Sep 2023 09:43:44 +0200 Subject: [PATCH] fix: fixed the confirm apply dialog timer not stopping after choosing an option --- lact-gui/src/app/mod.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lact-gui/src/app/mod.rs b/lact-gui/src/app/mod.rs index 53bc19ff..825b7ab4 100644 --- a/lact-gui/src/app/mod.rs +++ b/lact-gui/src/app/mod.rs @@ -16,6 +16,7 @@ use lact_daemon::MODULE_CONF_PATH; use root_stack::RootStack; use std::cell::RefCell; use std::rc::Rc; +use std::sync::atomic::AtomicBool; use std::time::Duration; use tracing::{debug, error, trace, warn}; @@ -431,10 +432,14 @@ impl App { .buttons(ButtonsType::YesNo) .transient_for(&self.window) .build(); + let confirmed = Rc::new(AtomicBool::new(false)); glib::source::timeout_add_local( Duration::from_secs(1), - clone!(@strong dialog, @strong self as app, @strong gpu_id => move || { + clone!(@strong dialog, @strong self as app, @strong gpu_id, @strong confirmed => move || { + if confirmed.load(std::sync::atomic::Ordering::SeqCst) { + return Continue(false) + } delay -= 1; let text = confirmation_text(delay); @@ -452,6 +457,8 @@ impl App { ); dialog.run_async(clone!(@strong self as app => move |diag, response| { + confirmed.store(true, std::sync::atomic::Ordering::SeqCst); + let command = match response { ResponseType::Yes => ConfirmCommand::Confirm, _ => ConfirmCommand::Revert,