From ec6c7f447dc8f33a9d2340e8556d05ab20700cbd Mon Sep 17 00:00:00 2001 From: Gabriele Musco Date: Sat, 17 Jun 2023 11:34:56 +0200 Subject: [PATCH] fix: calibration synchronization --- src/ui/libsurvive_setup_window.rs | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/src/ui/libsurvive_setup_window.rs b/src/ui/libsurvive_setup_window.rs index 0e796d8..a34ff09 100644 --- a/src/ui/libsurvive_setup_window.rs +++ b/src/ui/libsurvive_setup_window.rs @@ -1,10 +1,7 @@ use crate::{profile::Profile, runner::Runner}; -use gtk::{ - glib::{self, ffi::gboolean}, - prelude::*, -}; +use gtk::{glib, prelude::*}; use relm4::prelude::*; -use std::{cell::Cell, collections::HashMap, path::Path, time::Duration}; +use std::{cell::Cell, collections::HashMap, path::Path, rc::Rc, time::Duration}; const NO_FILE_MSG: &str = "(No file selected)"; const CALIBRATION_RUN_TIME_SECONDS: f64 = 30.0; @@ -29,7 +26,7 @@ pub struct LibsurviveSetupWindow { filefilter_listmodel: gtk::gio::ListStore, #[tracker::do_not_track] - calibration_running: Cell, + calibration_running: Rc>, #[tracker::do_not_track] first_run_done: bool, #[tracker::do_not_track] @@ -71,7 +68,7 @@ impl LibsurviveSetupWindow { fn on_close_request( sender: &relm4::ComponentSender, carousel: &adw::Carousel, - calibration_running: &Cell, + calibration_running: &Rc>, progressbar: >k::ProgressBar, page1: &adw::StatusPage, ) -> gtk::Inhibit { @@ -97,12 +94,6 @@ impl SimpleComponent for LibsurviveSetupWindow { set_modal: true, set_default_size: (520, 400), set_hide_on_close: true, - // connect_close_request[sender, carousel, page1, progressbar] => move |_| { - // carousel.scroll_to(&page1, true); - // progressbar.set_fraction(0.0); - // sender.input(LibsurviveSetupMsg::SetSteamLighthousePath(None)); - // gtk::Inhibit(false) - // }, gtk::Box { set_orientation: gtk::Orientation::Vertical, set_hexpand: true, @@ -347,10 +338,10 @@ impl SimpleComponent for LibsurviveSetupWindow { runner.start(); { let timer_sender = sender.clone(); - let continue_watching = self.calibration_running.clone(); + let cont = self.calibration_running.clone(); glib::timeout_add_local(Duration::from_millis(1000), move || { timer_sender.input(LibsurviveSetupMsg::TickCalibrationRunner); - return glib::Continue(continue_watching.get()); + return glib::Continue(cont.get()); }); } self.calibration_runner = Some(runner); @@ -422,7 +413,7 @@ impl SimpleComponent for LibsurviveSetupWindow { } fn init( - init: Self::Init, + _init: Self::Init, root: &Self::Root, sender: relm4::ComponentSender, ) -> relm4::ComponentParts { @@ -441,7 +432,7 @@ impl SimpleComponent for LibsurviveSetupWindow { .build(), profile: None, calibration_runner: None, - calibration_running: Cell::new(false), + calibration_running: Rc::new(Cell::new(false)), first_run_done: false, calibration_seconds_elapsed: 0.0, tracker: 0,