-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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 NullReferenceException in Gestures.PointerReleased #15117
Merged
maxkatz6
merged 5 commits into
AvaloniaUI:master
from
zabolotnev:fix/NRE_in_Gestures_PointerReleased
Apr 5, 2024
Merged
Avoid NullReferenceException in Gestures.PointerReleased #15117
maxkatz6
merged 5 commits into
AvaloniaUI:master
from
zabolotnev:fix/NRE_in_Gestures_PointerReleased
Apr 5, 2024
Conversation
This file contains 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
@dotnet-policy-service agree |
827419d
to
0c965be
Compare
You can test this PR using the following package version. |
maxkatz6
reviewed
Mar 26, 2024
You can test this PR using the following package version. |
maxkatz6
approved these changes
Apr 5, 2024
maxkatz6
pushed a commit
that referenced
this pull request
Apr 6, 2024
* refs #14249 Avoid NullReferenceException in Gestures.PointerReleased * refs #14249 Track current gesture state with single readonly struct * Update from review * Moved the last click location from the GestureState record to a separate field. (#14249) --------- Co-authored-by: Заболотнев Юрий <zabolotnev@promit-ek.ru>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What does the pull request do?
PR allows you to avoid crashes during multi-touch input #14249. This is not a complete fix as I'm not sure the new behavior is correct.
What is the current behavior?
The bug is described in #14249. In my case, I created an application with one large button. I pressed the Linux device's touch display several times with three fingers. After a few touches the app crashes with message:
Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
at Avalonia.Input.Gestures.PointerReleased(RoutedEventArgs ev)
What is the updated/expected behavior with this PR?
The application does not crash.
How was the solution implemented (if it's not obvious)?
There is three ways to avoid NRE here:
PointerReleased
before raising the event. In this case theHoldingState.Completed
event will not be raised in some cases. Is it good or bad? I don't know.s_lastHeldPointer.Type
in separate field. EventHoldingState.Completed
will be raised even ifs_lastHeldPointer
isnull
. I think this is better than the first case.s_lastHeldPointer
might benull
and causes NRE and rewrite (refactor?) this code.I decided to take the second path as it is more reliable. I also changed the
PointerPressed
andPointerMoved
methods to uses_lastHeldPointerType
field just for consistency. These two methods do not throw NRE exceptions.Checklist
Breaking changes
Obsoletions / Deprecations
Fixed issues