Skip to content

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

Commit

Restarting to update no longer freezes the desktop app for up to 30 seconds. Restart now (settings), the tray's Restart and Quit stopped the runner on the main thread, where Windows runs the settings' commands and menus; the runner, stopping, updates the tray, which waits for the main thread, so both waited until runner::shutdown's 30-second timeout ran out and Windows showed g1t as Not Responding. Restart and quit now stop the runner and install on a thread of their own (updates::leave), and the settings' plain restart does the same.

Checked:
cargo check of g1t-desktop.
G1t-Session:
ses_01m4ypcdt1e7h9c728e5bbs4py
syntaqxcommitted Parent631b599Browse files
2 files+32−90/2 viewed
+3−2
227227 from_settings(&webview).or_else(|_| from_site_page(&app, &webview))?;
228228 if updates::ready(&app).is_some() {
229229 updates::restart(&app);
230+ } else {
231+ updates::leave(&app, |app| app.restart());
230232 }
231− runner::shutdown(&app);
232− app.restart()
233+ Ok(())
233234 }
234235
235236 /// The settings window's "Restart now": installs the downloaded update and starts it.
+29−7
156156 if ready(app).is_none() {
157157 return;
158158 }
159− crate::runner::shutdown(app);
160− if install(app) {
161− app.restart();
162− }
159+ leave(app, |app| {
160+ if install(app) {
161+ app.restart();
162+ }
163+ });
163164 }
164165
165166 /// Quit, stopping the runner and installing a downloaded update on the way out.
166167 pub fn quit(app: &AppHandle) {
167− crate::runner::shutdown(app);
168− install(app);
169− app.exit(0);
168+ leave(app, |app| {
169+ install(app);
170+ app.exit(0);
171+ });
172+}
173+
174+/// Stops the runner, then `then`, on a thread of its own. Restart and quit
175+/// are asked on the main thread (menus, and the settings' commands, which
176+/// Windows runs there), and the runner, stopping, updates the tray, which
177+/// waits for the main thread: waiting on the runner there froze g1t until
178+/// its 30 seconds ran out.
179+pub fn leave(app: &AppHandle, then: impl FnOnce(&AppHandle) + Send + 'static) {
180+ let app = app.clone();
181+ let spawned = std::thread::Builder::new().name("g1t-leave".into()).spawn({
182+ let app = app.clone();
183+ move || {
184+ crate::runner::shutdown(&app);
185+ then(&app);
186+ }
187+ });
188+ if spawned.is_err() {
189+ crate::runner::shutdown(&app);
190+ app.exit(0);
191+ }
170192 }

Comments

Sign in to comment.