Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Support exiting event loop without quitting program #2187

Closed
surban opened this issue Feb 7, 2022 · 9 comments
Closed

Feature request: Support exiting event loop without quitting program #2187

surban opened this issue Feb 7, 2022 · 9 comments

Comments

@surban
Copy link

surban commented Feb 7, 2022

I am using winit via eframe for a command line application. The app displays a window for the user to provide some input. After the window is closed I would like winit to exit the event loop and return from EventLoop::run, so that the app can continue running.

However this is currently impossible because the return type is ! and std::process::exit is called when the event loop is exited.

See also emilk/egui#1223

@maroider
Copy link
Member

maroider commented Feb 7, 2022

@surban
Copy link
Author

surban commented Feb 11, 2022

Unfortunately, according to the egui developers this is not working properly, see emilk/egui#1223 (comment).

@maroider
Copy link
Member

My intuition is that even if run_return leads to "very jittery resizing of windows", such behaviour should only manifest if one repeatedly returns and re-enters the event loop. For your use-case, which seems to call for exiting the event loop a single time once you've shown your prompt, seems like it might work without much of an issue. run uses run_return under the hood, so I don't think there's much room for additional bugs to sneak in (ignoring the previously mentioned "return + re-enter" case).

@kchibisov
Copy link
Member

I'm not sure what the issue to solve here, run just calls run_return on desktop platforms iirc. run_return isn't possible on mobile iirc, but that's about it.

@lucafulgenzi
Copy link

@surban I am in the same situation as you, have you found an alternative method? Or have you changed libraries, if so could you tell me which one you used?

@rib
Copy link
Contributor

rib commented Dec 10, 2022

I'm not sure what the issue to solve here, run just calls run_return on desktop platforms iirc. run_return isn't possible on mobile iirc, but that's about it.

run_return should be ok on Android I think (at least I can't think of a reason off the top of my head why it wouldn't work)

@lucafulgenzi
Copy link

It is not for android

@rib
Copy link
Contributor

rib commented Dec 10, 2022

It is not for android

yeah, I was just thinking about the comment about run_return potentially not being supported on mobile. I've added a quote to clarify what I was commenting on.

@surban
Copy link
Author

surban commented Dec 11, 2022

@surban I am in the same situation as you, have you found an alternative method? Or have you changed libraries, if so could you tell me which one you used?

I haven't tried myself, but wasn't this fixed in egui in emilk/egui#1889 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

5 participants