Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-54582

QQuickTextInput::acceptableInputChanged() sometimes not emitted if string is modified by validator

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P3: Somewhat important P3: Somewhat important
    • None
    • 5.8
    • None

      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:

      1. wasAcceptable is set from m_acceptableInput, then
      2. m_acceptableInput is updated (from the result of calling validate(), then
      3. QQuickTextInputPrivate::internalSetText() is called, which ends up calling
      4. 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.

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            Unassigned Unassigned
            fdv Fredrik de Vibe
            Votes:
            3 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes