Force recreating windows on config change (#1284)
Fixes the regression from #1236 preventing hot reload. This can be made granular, e.g. for changes that don't effect all windows or css chnages not requiring a full window restart
This commit is contained in:
parent
b6b7bc8453
commit
29fa1587c3
1 changed files with 20 additions and 14 deletions
|
@ -217,7 +217,10 @@ impl<B: DisplayBackend> App<B> {
|
||||||
.filter(|(win_id, ..)| win_id.is_empty() || win_id == id)
|
.filter(|(win_id, ..)| win_id.is_empty() || win_id == id)
|
||||||
.map(|(_, n, v)| (n.clone(), v.clone()))
|
.map(|(_, n, v)| (n.clone(), v.clone()))
|
||||||
.collect();
|
.collect();
|
||||||
self.open_window(&WindowArguments::new_from_args(id.to_string(), config_name.clone(), window_args)?)
|
self.open_window(
|
||||||
|
&WindowArguments::new_from_args(id.to_string(), config_name.clone(), window_args)?,
|
||||||
|
false,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.filter_map(Result::err);
|
.filter_map(Result::err);
|
||||||
|
@ -242,16 +245,19 @@ impl<B: DisplayBackend> App<B> {
|
||||||
let result = if should_toggle && is_open {
|
let result = if should_toggle && is_open {
|
||||||
self.close_window(&instance_id)
|
self.close_window(&instance_id)
|
||||||
} else {
|
} else {
|
||||||
self.open_window(&WindowArguments {
|
self.open_window(
|
||||||
instance_id,
|
&WindowArguments {
|
||||||
window_name,
|
instance_id,
|
||||||
pos,
|
window_name,
|
||||||
size,
|
pos,
|
||||||
monitor,
|
size,
|
||||||
anchor,
|
monitor,
|
||||||
duration,
|
anchor,
|
||||||
args: args.unwrap_or_default().into_iter().collect(),
|
duration,
|
||||||
})
|
args: args.unwrap_or_default().into_iter().collect(),
|
||||||
|
},
|
||||||
|
false,
|
||||||
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
sender.respond_with_result(result)?;
|
sender.respond_with_result(result)?;
|
||||||
|
@ -385,13 +391,13 @@ impl<B: DisplayBackend> App<B> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn open_window(&mut self, window_args: &WindowArguments) -> Result<()> {
|
fn open_window(&mut self, window_args: &WindowArguments, dirty: bool) -> Result<()> {
|
||||||
let instance_id = &window_args.instance_id;
|
let instance_id = &window_args.instance_id;
|
||||||
self.failed_windows.remove(instance_id);
|
self.failed_windows.remove(instance_id);
|
||||||
log::info!("Opening window {} as '{}'", window_args.window_name, instance_id);
|
log::info!("Opening window {} as '{}'", window_args.window_name, instance_id);
|
||||||
|
|
||||||
// if an instance of this is already running and arguments haven't change, only update duration
|
// if an instance of this is already running and arguments haven't change, only update duration
|
||||||
let reuse_window = if self.open_windows.contains_key(instance_id) {
|
let reuse_window = if !dirty && self.open_windows.contains_key(instance_id) {
|
||||||
if self.instance_id_to_args.get(instance_id).is_some_and(|args| window_args.can_reuse_window_with_args(args)) {
|
if self.instance_id_to_args.get(instance_id).is_some_and(|args| window_args.can_reuse_window_with_args(args)) {
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
|
@ -530,7 +536,7 @@ impl<B: DisplayBackend> App<B> {
|
||||||
let window_arguments = self.instance_id_to_args.get(instance_id).with_context(|| {
|
let window_arguments = self.instance_id_to_args.get(instance_id).with_context(|| {
|
||||||
format!("Cannot reopen window, initial parameters were not saved correctly for {instance_id}")
|
format!("Cannot reopen window, initial parameters were not saved correctly for {instance_id}")
|
||||||
})?;
|
})?;
|
||||||
self.open_window(&window_arguments.clone())?;
|
self.open_window(&window_arguments.clone(), true)?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue