UI: Set default string size arg for QT_UTF8 / QString::fromUtf8

Our QT_UTF8(str) macro uses QString::fromUtf8(str) with no size
argument. In Qt5, QString::fromUtf8 uses a default value of -1 for the
size arg. If size is -1, it is taken to be strlen(str). In Qt6,
QString::fromUtf8 doesn't use a default value for the size arg, but has
the same behavior if you manually specify -1 for the size. Let's
manually specify -1 to maintain the same behavior between Qt5 and Qt6.

https://doc.qt.io/qt-5/qstring.html#fromUtf8
https://doc.qt.io/qt-6/qstring.html#fromUtf8
This commit is contained in:
Ryan Foster 2021-03-09 09:11:09 -05:00
parent 37971e7bf9
commit 05d29aa4e3

View file

@ -28,12 +28,7 @@
#include <memory>
#include <vector>
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#define QT_UTF8(str) QString::fromUtf8(str, -1)
#else
#define QT_UTF8(str) QString::fromUtf8(str)
#endif
#define QT_TO_UTF8(str) str.toUtf8().constData()
class QDataStream;