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

Avoid unwraps in winit fullscreen handling code #11735

Merged
merged 2 commits into from Feb 10, 2024

Conversation

Friz64
Copy link
Contributor

@Friz64 Friz64 commented Feb 6, 2024

Objective

Solution

  • Replace the unwraps with warnings. Ignore the fullscreen request, do nothing instead.

Copy link
Contributor

github-actions bot commented Feb 6, 2024

Welcome, new contributor!

Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨

@alice-i-cecile alice-i-cecile added C-Bug An unexpected or incorrect behavior A-Windowing Platform-agnostic interface layer to run your app in C-Crash A sudden unexpected crash labels Feb 6, 2024
Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

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

I'd definitely like to avoid panicking here, but I don't love the nested options in an already dense area of code. Is there another way to express this control flow?

@BD103
Copy link
Member

BD103 commented Feb 6, 2024

I'd definitely like to avoid panicking here, but I don't love the nested options in an already dense area of code. Is there another way to express this control flow?

I believe this is probably the best it can be. if let is about as concise you can get when matching a single pattern. If there was a method on Result such as result.run_if_err(|| warn!(...)) this could be shortened, but no such function exists in the standard library. (Nor does this warrant creating our own.) It's not pretty, but it's safer handling errors explicitly than panicking.

On the other hand, this line can be shortened to a let else:

if let Some(winit_window) = winit_windows.get_window(entity) {

let Some(winit_window) = winit_windows.get_window(entity) else {
    continue;
};

@Friz64, could you implement that change in your PR?

@Friz64
Copy link
Contributor Author

Friz64 commented Feb 6, 2024

@Friz64, could you implement that change in your PR?

Good suggestion, done.

Copy link
Contributor

@pablo-lua pablo-lua left a comment

Choose a reason for hiding this comment

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

Simplified the code in some areas and avoided the unwrap with warnings, all good!

@alice-i-cecile alice-i-cecile added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Feb 10, 2024
@mockersf mockersf added this pull request to the merge queue Feb 10, 2024
Merged via the queue into bevyengine:main with commit d939c44 Feb 10, 2024
24 checks passed
@Friz64 Friz64 deleted the wayland-fullscreen-fix branch February 10, 2024 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Windowing Platform-agnostic interface layer to run your app in C-Bug An unexpected or incorrect behavior C-Crash A sudden unexpected crash S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wayland panic and crash
5 participants