Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.8
-
None
Description
TL;DR:
If QValidator::validate() modifies its input string, and returns the same State both before and after the modification to the string, QQuickTextInputPrivate::acceptableInputChanged() will not be emitted, even if the State was different before the call to validate().
Full story:
When using a QValidator that modifies the input string to validate(), QQuickTextInput::acceptableInputChanged() is not emitted in some cases when it should be. The reason for this is that in QQuickTextInputPrivate::finishChange(), the following happens:
- wasAcceptable is set from m_acceptableInput, then
- m_acceptableInput is updated (from the result of calling validate(), then
- QQuickTextInputPrivate::internalSetText() is called, which ends up calling
- QQuickTextInputPrivate::finishChange() once again.
Now, if validate() returns Acceptable the first time it is called (in the first invocation of finishChange()), in 2, m_acceptableInput will be set to true. If the previous state was false, wasAcceptable will be false, and later in finishChange(), as wasAcceptable is not equal to m_acceptableInput, acceptableInputChanged() should have been emitted. However, as the input was modified, internalSetText() was called, followed by a return from finishChange().
Next, in 4, wasAcceptable is again set to the value of m_acceptableInput (which was set in 2 - to true in this example), after which validate() is again called. If validate() still returns the same state as in 2, wasAcceptable and m_acceptableInput will now have the same value (true in this example), and acceptableInputChanged() will not be emitted.
Attachments
Issue Links
- is duplicated by
-
QTBUG-75817 TextInput does not update acceptableInput when input is changed in validate
- Closed