resolve stack overflow and improve MaskedTextBox behavior #16819
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?
This PR prevents a stack overflow in the binding system when a property is changed during processing of an
OnPropertyChanged
event handler tied to the same property.#16746
How was the solution implemented (if it's not obvious)?
The method call at 1. triggers event handlers in user code. When the method finishes, the event
e
has obsolete values. If sent out, the old values look like a new change, set the value back to what it was, and cause an infinite loop.I added a check to see if the value has changed, and if so, to stop sending obsolete new values.
I also enhanced the MaskedTextBox to remember the original empty value, so clearing the control will return back to null or empty string, depending on the original value.
I added a way for the user application to suppress updating the source value as needed. This prevents the control from updating the source until actual keystrokes are received, instead of filling the source with an empty mask value initially (when the initial value is null or empty string). This is the previous behavior of the control before the binding system went through the major refactoring. See #13970
Fixed issues
Fixes #16746