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

QByteArray::toDouble() behavior changed on whitespaces only string

    XMLWordPrintable

Details

    • All
    • 61b17127a (dev), 4e785f1da (6.9), 3125001ea (tqtc/lts-6.8)

    Description

      On Qt 5.9 a string with only white-spaces (eg. '  ') passed to QByteArray::toDouble() will produce a failed convertion with the ok flag set to false.

      But since at least Qt 5.12, the ok flag is now true.

      While with QString::toDouble(), it remained false until now.

      Tested on Qt 5.12, 5.15, 6.2, 6.8.

      The attached program allows to the issue.

      Qt 5.9 output:

      QByteArray: "   " val: 0 ok: false
      QByteArray: " " val: 0 ok: false
      QByteArray: "" val: 0 ok: false
      QString: "   " val: 0 ok: false
      QString: " " val: 0 ok: false
      QString: "" val: 0 ok: false 

      Qt 5.12 and later output:

      QByteArray: "   " val: 0 ok: true
      QByteArray: " " val: 0 ok: true
      QByteArray: "" val: 0 ok: false
      QString: "   " val: 0 ok: false
      QString: " " val: 0 ok: false
      QString: "" val: 0 ok: false 

      This seems like an old bug but I have not found any other issue on this or a documentation about this change.

      Attachments

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

        Activity

          People

            thiago Thiago Macieira
            rreignier Romain Reignier
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes