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

Scan all Qt source for single-char assumptions on QLocale accessors

XMLWordPrintable

    • Icon: Epic Epic
    • Resolution: Unresolved
    • Icon: P2: Important P2: Important
    • None
    • None
    • Core: Locales (i18n)
    • None
    • qlocale-qt5-char-to-qt6-string
    • All
    • 13
    • Foundation PM Staging
    • ece0b0279 (dev), d398c0a2a (6.10), 70803b9e7 (6.9), 860749f43 (tqtc/lts-6.8), d4d9142f3 (tqtc/lts-6.5), e5662cab2 (tqtc/esm-5.15)

      Throughout our code the callers of QLocale APIs that I upgraded from returning QChar to returning QString at 6.0 may still be assuming single-character values.
      Examples:

      • qtbase/src/widgets/widgets/qspinbox.cpp comparing copy.at(0) == locale.decimalPoint() and similar. (QTBUG-138521)
        • Same file, later using dec = copy.indexOf(locale.decimalPoint()); but later assuming dec + 1 is where to look for what follows it.
      • Qt-dev/qtbase/src/corelib/serialization/qtextstream.cpp comparing data[0] to negativeSign() and positiveSign() returns. mmutz brought this to my attention, sparking this ticket: he is fixing it. (QTBUG-138484)
      • Same file, QTextStreamPrivate::getReal() looping while (getChar(&c) and assuming it can compare c.toLower() – itself potentially problematic – with the toLower() of various QLocale no-longer-single-char values. It needs to use case-insensitive starts-with tests on the stream of characters and consume them chunkwise.
      • qtdeclarative/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp testing QCOMPARE(object->property("decimalPoint").toString().at(0), locale.decimalPoint()); and similar for the other functions, rather than doing a startsWith() test.
      • qtcharts/src/charts/axis/valueaxis/valueaxislabel.cpp testing event->text().at(0) != locale.decimalPoint() and similar for negative sign (neglecting positive) and exponential; also ignoring group separator; and testing event->text().at(0).isDigit() assumes BMP digits.

      Scan code for calls to these functions

          QString decimalPoint() const;
          QString groupSeparator() const;
          QString percent() const;
          QString zeroDigit() const;
          QString negativeSign() const;
          QString positiveSign() const;
          QString exponential() const;
      

      and check for any callers assuming single-character returns (like they used to get in Qt 5). For now (with CLDR v47's data) every locale has single-UTF-16 fractional-part (misnamed "decimal point") and grouping separators, so fixes for the first two are relatively low priority; but all the others are multi-UTF-16 in at least some locales.

        For Gerrit Dashboard: QTBUG-138475
        # Subject Branch Project Status CR V

            Eddy Edward Welbourne
            Eddy Edward Welbourne
            Vladimir Minenko Vladimir Minenko
            Alex Blasche Alex Blasche
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: