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

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

    XMLWordPrintable

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:

      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.

      Attachments

        Issue Links

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

          Activity

            People

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

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes