Skip to content

Commit

Permalink
Merge pull request #35 from 0323pin/main
Browse files Browse the repository at this point in the history
Fixes #34
  • Loading branch information
Kl4rry authored Jun 19, 2024
2 parents 183c2e0 + e7ef57a commit 289e047
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ mod cli;
mod image_io;

#[derive(Serialize, Deserialize, Debug, Default)]
pub struct Config {
struct Config {
maximized: bool,
preferences: Preferences,
}
Expand Down Expand Up @@ -211,7 +211,7 @@ impl<'a> WindowHandler<'a> {
}

impl WindowHandler<'_> {
pub fn main_loop(mut self) -> Config {
pub fn main_loop(mut self) {
let WindowHandler {
event_loop,
mut app,
Expand All @@ -222,9 +222,6 @@ impl WindowHandler<'_> {
mut wgpu,
} = self;

let mut config = Config::default();
let config_ref = &mut config;

let _ = event_loop.run(move |event, event_loop| match event {
Event::Resumed => wgpu.window.set_visible(true),
Event::NewEvents(..) => wgpu.window.request_redraw(),
Expand Down Expand Up @@ -407,17 +404,16 @@ impl WindowHandler<'_> {
},
Event::LoopExiting => {
wgpu.window.set_visible(false);
let maximized = wgpu.window.is_maximized();
*config_ref = Config {
maximized,
let data = Config {
maximized: wgpu.window.is_maximized(),
preferences: PREFERENCES.lock().unwrap().clone(),
};
confy::store("simp", None, data).unwrap();
std::process::exit(0);
}
Event::UserEvent(mut event) => app.handle_user_event(&wgpu, &mut event),
_ => (),
});

config
}
}

Expand Down Expand Up @@ -457,9 +453,5 @@ fn main() {
.app
.queue(Op::LoadPath(PathBuf::from(path), true))
}

let config = window_handler.main_loop();
if let Err(err) = confy::store("simp", None, config) {
eprintln!("{err}");
};
window_handler.main_loop();
}

1 comment on commit 289e047

@0323pin
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kl4rry It actually builds with Rust-1.76, so I've merged the update.
It will make into the coming stable release 🚀

Please sign in to comment.