mirror of
https://github.com/AgentSeal/codeburn.git
synced 2026-11-24 22:09:14 +00:00
fix(windows): --quit reaches a running app again
The early return that answered --quit before the Tauri builder ran also skipped the thing that delivers it. Handing a second launch's argv to the instance that is already running is the single-instance plugin's job, and the plugin only gets to do it if the builder runs, so returning first meant the running app never heard the request: the desktop app's Menu bar switch dropped the Run value and sent --quit, and the tray app carried on. It is answered in setup now, where a launch that reached that point is by definition the only instance: with nothing running it is the one being asked to go, and it exits without showing anything. With something running the plugin delivers the argv and this process never reaches setup at all. Found by driving the switch against the installed app rather than by a test: the argv parsing this rests on was unit-tested and correct, and the delivery it depends on was not something a unit test could see.
This commit is contained in:
parent
35f3c14977
commit
eb6f5de6f0
1 changed files with 11 additions and 7 deletions
|
|
@ -93,13 +93,6 @@ pub fn parse_second_launch(args: &[String]) -> SecondLaunch {
|
|||
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run() {
|
||||
// `--quit` aimed at an app that is not running would otherwise start one and leave it
|
||||
// there, which is the opposite of the request. Nothing has been built yet, so there is
|
||||
// nothing to tear down.
|
||||
if parse_second_launch(&std::env::args().collect::<Vec<_>>()) == SecondLaunch::Quit {
|
||||
return;
|
||||
}
|
||||
|
||||
tauri::Builder::default()
|
||||
// Must be registered before any other plugin so it can intercept a second launch.
|
||||
.plugin(tauri_plugin_single_instance::init(|app, args, _cwd| {
|
||||
|
|
@ -112,6 +105,16 @@ pub fn run() {
|
|||
.plugin(tauri_plugin_shell::init())
|
||||
.plugin(tauri_plugin_opener::init())
|
||||
.setup(|app| {
|
||||
// `--quit` with nothing running: this launch is the instance being asked to go,
|
||||
// so it goes without ever showing anything. It cannot be answered before the
|
||||
// builder runs, because handing the argv to an instance that IS running is the
|
||||
// single-instance plugin's job, and returning early meant the running app never
|
||||
// heard the request at all.
|
||||
if parse_second_launch(&std::env::args().collect::<Vec<_>>()) == SecondLaunch::Quit {
|
||||
app.handle().exit(0);
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
app.manage(AppState {
|
||||
cli: Mutex::new(CodeburnCli::resolve()),
|
||||
config: Mutex::new(CurrencyConfig::load_or_default()),
|
||||
|
|
@ -1127,6 +1130,7 @@ mod commands {
|
|||
crate::dock::popup_context_menu(&app).map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
|
||||
/// Everything the Capacity Dock reads out of `windows-dock.json`: whether it is on, its
|
||||
/// scale, appearance, gauge shape and provider set. One free-form object, so a new dock
|
||||
/// preference costs no Rust.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue