Launching 2 windows one after another never succeeds #948
-
So I am working on a fairly large project which requires a 'launcher' windows which allows for pre-configuring the main application. The launcher overrides the should_close function of Application, so that when the user has pre-configured the app, the launcher can close and in its place show the main window. The code to do this is as so in main.rs pub static mut launcher_ok: bool = false; // Launcher will set this when it finishes and if configuration was OK
....
let launcher_settings = settings.clone();
launcher::Launcher::run(launcher_settings); // Launch launcher
// Launcher execution finished. See if launcher was successful, then continue to launch the main window.
println!("Here: Launcher state: {}", unsafe {launcher_ok});
if unsafe { launcher_ok } {
settings.window.resizable = true;
settings.window.min_size = Some((1280, 720));
settings.window.size = (1280, 720);
openstar::OpenStarWindow::run(settings.clone());
} The issue here is that even though launcher terminates gracefully, it seems to terminate the entire application when it gracefully exits, rather than simply returning from the Is there any way of having this sort of behaviour in iced? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
If this is the default behaviour of iced::Application::run, is it possible to mark the function as noreturn? |
Beta Was this translation helpful? Give feedback.
-
@rnd-ash It's already documented on Application::run:
This behavior isn't specified (or needed) by Personally, I'd make so that when the user tries to close the application, you first write to some config file, and then launch the main application (a different binary) and on the main application you read that config file. If you have any other questions or would like help with something, I'd recommend joining Iced's zulipchat (you'll probably get a faster answer there)! |
Beta Was this translation helpful? Give feedback.
@rnd-ash It's already documented on Application::run:
This behavior isn't specified (or needed) by
iced
itself, it's a consequence (or limitation) of usingwinit
as a shell implementation (by defaulticed
useswinit
as the window manager), and looking at their documentation you find that there is an alternative, but it's not recommended and has it's caveats (see run_return).Personally, I'd make so that when the user tries to close the application, you first write to some config file, and then launch the main application (a different binary) and on the ma…