-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
AppExit should be an observer event rather than a BufferedEvent #20408 #20442
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
Closed
+74
−69
Closed
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
eb9776c
AppExit should be an observer event rather than a BufferedEvent #20408
martinfrances107 2cbb9ff
Update crates/bevy_winit/src/system.rs
martinfrances107 7580f03
Merge branch 'main' into app_exit
martinfrances107 bd5574a
fn should_exit() better handling of AppExitRes
martinfrances107 3b9eb60
Renamed observer
martinfrances107 1b18bb6
Merge branch 'main' into app_exit
martinfrances107 c6325c1
Merge branch 'main' into app_exit
martinfrances107 3a05fce
Merge branch 'main' into app_exit
martinfrances107 0cf17b1
No longer adding a event via app.add_event::<AppExit>(), so EventRegi…
martinfrances107 4460fc2
TimePlugin::build() may or may not need to handle the event registry.
martinfrances107 1b97a85
Merge branch 'main' into app_exit
martinfrances107 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,7 @@ use bevy_a11y::AccessibilityRequested; | |
use bevy_app::{App, Last, Plugin}; | ||
use bevy_ecs::prelude::*; | ||
use bevy_window::{exit_on_all_closed, CursorOptions, Window, WindowCreated}; | ||
use system::{changed_cursor_options, changed_windows, check_keyboard_focus_lost, despawn_windows}; | ||
use system::{changed_cursor_options, changed_windows, check_keyboard_focus_lost, on_app_exit}; | ||
pub use system::{create_monitors, create_windows}; | ||
#[cfg(all(target_family = "wasm", target_os = "unknown"))] | ||
pub use winit::platform::web::CustomCursorExtWebSys; | ||
|
@@ -132,7 +132,9 @@ impl<T: BufferedEvent> Plugin for WinitPlugin<T> { | |
|
||
app.init_resource::<WinitMonitors>() | ||
.init_resource::<WinitSettings>() | ||
.insert_resource(DisplayHandleWrapper(event_loop.owned_display_handle())) | ||
.insert_resource(DisplayHandleWrapper(event_loop.owned_display_handle())); | ||
|
||
app.add_observer(on_app_exit) | ||
.add_event::<RawWinitWindowEvent>() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why split up this chain? Also |
||
.set_runner(|app| winit_runner(app, event_loop)) | ||
.add_systems( | ||
|
@@ -142,7 +144,6 @@ impl<T: BufferedEvent> Plugin for WinitPlugin<T> { | |
// so we don't need to care about its ordering relative to `changed_windows` | ||
changed_windows.ambiguous_with(exit_on_all_closed), | ||
changed_cursor_options, | ||
despawn_windows, | ||
check_keyboard_focus_lost, | ||
) | ||
.chain(), | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think something is going wrong here, if I understand correctly you will only return a
Some
if any nonAppExit::Success
has been triggered (as a result ofregister_app_exit_error
). However in the old code, aSome(AppExit::Success
would still be emitted if there is at least 1 event and none of them are errors.In other words, I believe your version would simply not exit upon
AppExit::Success