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

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

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3: Somewhat important
    • 6.10.0 Beta3
    • 5.12, 5.13, 5.14, 5.15, 6.0, 6.1, 6.2, 6.3, 6.4, 6.5, 6.6, 6.7, 6.8
    • None
    • All
    • 61b17127a (dev)

    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

        1. main.cpp
          0.7 kB
          Romain Reignier
        For Gerrit Dashboard: QTBUG-137038
        # Subject Branch Project Status CR V

        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 is 1 open Gerrit change