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 possible crash when Control overrides mouse input on Area2D #81006

Conversation

KurtBliss
Copy link
Contributor

Made Viewport::_cleanup_mouseover_colliders queue up mouse_exit and mouse_shape_exit signals to emit and at the end of the function's execution to avoid potential crashes.

Fixes #79371

Made Viewport::_cleanup_mouseover_colliders queue up mouse_exit and
mouse_shape_exit signals to emit and at the end of the function's
execution to avoid potential crashes.
@KurtBliss KurtBliss requested a review from a team as a code owner August 25, 2023 22:11
@AThousandShips AThousandShips added this to the 4.2 milestone Aug 26, 2023
Copy link
Contributor

@Sauermann Sauermann left a comment

Choose a reason for hiding this comment

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

The reason for the crash was that during a for(const KeyValue<ObjectID, uint64_t> &E : physics_2d_mouseover)-loop the variable physics_2d_mouseover was changed.

So this fix makes sense independently of my initial thoughts regarding mouse-over handling.

Have tested the PR with the MRP of the linked issue and can no longer replicate the crash.

@KurtBliss
Copy link
Contributor Author

I was thinking at first this method would be good incase of another function or variable could retrigger Viewport::_cleanup_mouseover_colliders immediately like changing the control.mouse_default_cursor_shape in the MRP. But after checking if using the get_viewport().warp_mouse(position : Vector2) could cause a immediate retrigger, it didn't, idk may of been better with Sauermann initial thought on it. Not really sure.

@akien-mga akien-mga changed the title Fixed, chance of crash when Control overrides mouse input on Area2D Fix possible crash when Control overrides mouse input on Area2D Aug 28, 2023
@akien-mga akien-mga merged commit 8b8b6d1 into godotengine:master Aug 28, 2023
@KurtBliss KurtBliss deleted the Chance-of-crash-when-Control-overrides-mouse-input-on-Area2D-#79371 branch August 28, 2023 13:09
@akien-mga
Copy link
Member

Thanks!

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

Successfully merging this pull request may close these issues.

Chance of crash when Control overrides mouse input on Area2D
4 participants