Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-6879

Qt Creator different project templates are using QString::fromAscii() instead of QString::fromLatin1()

XMLWordPrintable

    • 051569b998d3804b54a04bdc7edea3e9526063ed

      Some Qt Creator's project templates have something similar to the next line:

      const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.'));

      share/qtcreator/templates/qtquickapp/qmlapplicationviewer/qmlapplicationviewer.cpp
      share/qtcreator/templates/mobileapp/mainwindow.cpp
      share/qtcreator/templates/html5app/html5applicationviewer/html5applicationviewer.cpp

      It is used at ...::setOrientation() method.

      I think - QString::fromLatin1() should be used instead.

      QString::fromAscii() is invalid because:

      http://developer.qt.nokia.com/doc/qt-4.8/qstring.html#fromAscii

      ============
      Note that, despite the name, this function actually uses the codec defined by QTextCodec::setCodecForCStrings() to convert str to Unicode. Depending on the codec, it may not accept valid US-ASCII (ANSI X3.4-1986) input. If no codec has been set, this function does the same as fromLatin1().
      ============

      So it depends to the codec, and the current codec even might convert qVersion() output to something totally unusable.

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

            portale Alessandro Portale
            mdn Denis Mingulov
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes