| ... | ... | @@ -342,6 +342,8 @@ struct App { |
| 342 | 342 | /// Files and folders to open, as File, Open does, once the window opens. |
| 343 | 343 | opening: Vec<PathBuf>, |
| 344 | 344 | state: Option<State>, |
| 345 | /// The staged update to swap in once the app has quit. |
| 346 | restart: Option<PathBuf>, |
| 345 | 347 | startup_error: Option<Box<dyn Error>>, |
| 346 | 348 | } |
| 347 | 349 | |
| ... | ... | @@ -5792,6 +5794,15 @@ impl ApplicationHandler<UserEvent> for App { |
| 5792 | 5794 | .min(); |
| 5793 | 5795 | event_loop.set_control_flow(next.map_or(ControlFlow::Wait, ControlFlow::WaitUntil)); |
| 5794 | 5796 | } |
| 5797 | |
| 5798 | /// Drops the window's state while the event loop still holds the Wayland connection the |
| 5799 | /// clipboard's thread and the surface use; `run_app` closes it on returning. |
| 5800 | fn exiting(&mut self, _: &ActiveEventLoop) { |
| 5801 | self.restart = self |
| 5802 | .state |
| 5803 | .take() |
| 5804 | .and_then(|state| state.updates.restarting()); |
| 5805 | } |
| 5795 | 5806 | } |
| 5796 | 5807 | |
| 5797 | 5808 | fn write_png(path: &Path, size: [u32; 2], pixels: &[u8]) -> Result<(), Box<dyn Error>> { |
| ... | ... | @@ -6094,15 +6105,12 @@ fn launch() -> Result<(), Box<dyn Error>> { |
| 6094 | 6105 | substitutes, |
| 6095 | 6106 | screenshot, |
| 6096 | 6107 | state: None, |
| 6108 | restart: None, |
| 6097 | 6109 | startup_error: None, |
| 6098 | 6110 | }; |
| 6099 | 6111 | event_loop.run_app(&mut app)?; |
| 6100 | | let restart = app |
| 6101 | | .state |
| 6102 | | .as_ref() |
| 6103 | | .and_then(|state| state.updates.restarting()); |
| 6104 | | if let Some(staged) = restart { |
| 6105 | | update::relaunch(&staged)?; |
| 6112 | if let Some(staged) = &app.restart { |
| 6113 | update::relaunch(staged)?; |
| 6106 | 6114 | } |
| 6107 | 6115 | app.startup_error.map_or(Ok(()), Err) |
| 6108 | 6116 | } |