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

Fix EguiUserTextures related crash when gui feature is nabled and bevy-egui is used #442

Merged
merged 1 commit into from
Jan 10, 2024

Conversation

mrafaj
Copy link
Contributor

@mrafaj mrafaj commented Jan 10, 2024

When the egui feature is enabled and the egui flag is used on a project using both bevy-egui and leafwing-input-manager, the program crashes with the following error:

thread 'Compute Task Pool (3)' panicked at C:\Users\Korisnik\.cargo\registry\src\index.crates.io-6f17d22bba15001f\bevy_ecs-0.12.1\src\system\system_param.rs:544:17:
Resource requested by leafwing_input_manager::systems::update_action_state<egui_test::Action> does not exist: bevy_egui::EguiUserTextures
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Encountered a panic in system `leafwing_input_manager::systems::update_action_state<egui_test::Action>`!
Encountered a panic in system `bevy_app::main_schedule::Main::run_main`!

This fixes the crash by replacing the request for EguiContexts done by leafwing_input_manager::systems::update_action_state with a query for EguiContext, as EguiContexts is jut a shortcut to getting to both the EguiUserTextures resource and the EguiContext query with maybe_egui.ctx_mut() returning the Context object of Egui's primary window. This PR fixes the crash as the EguiUserTextures resource is no longer being requested since it doesn't need to be for the egui feature.

Copy link
Contributor

@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.

Great! I've seen reports of this but couldn't track it down.

@alice-i-cecile alice-i-cecile enabled auto-merge (squash) January 10, 2024 15:32
@alice-i-cecile alice-i-cecile merged commit cda8d12 into Leafwing-Studios:main Jan 10, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants