Improve readability of code that uses the Qt signed size type

During the container BoF session at the Qt Contributor Summit 2017 the
name of the signed size type became a subject of discussion in the
context of readability of code using this type and the intention of
using it for all length, size and count properties throughout the entire
framework in future versions of Qt.

This change proposes qsizetype as new name for qssize_t to emphasize the
readability of code over POSIX compatibility, the former being
potentially more relevant than the latter to the majority of users of
Qt.

Change-Id: Idb99cb4a8782703c054fa463a9e5af23a918e7f3
Reviewed-by: Samuel Gaist <samuel.gaist@edeltech.ch>
Reviewed-by: David Faure <david.faure@kdab.com>
This commit is contained in:
Simon Hausmann 2017-10-10 09:42:41 +02:00 committed by Antti Kokko
parent 8298956eb0
commit 984ad61249
25 changed files with 111 additions and 111 deletions

View File

@ -160,8 +160,8 @@ Q_STATIC_ASSERT_X(std::numeric_limits<float>::radix == 2,
// not required by the definition of size_t, but we depend on this // not required by the definition of size_t, but we depend on this
Q_STATIC_ASSERT_X(sizeof(size_t) == sizeof(void *), "size_t and a pointer don't have the same size"); Q_STATIC_ASSERT_X(sizeof(size_t) == sizeof(void *), "size_t and a pointer don't have the same size");
Q_STATIC_ASSERT(sizeof(size_t) == sizeof(qssize_t)); // implied by the definition Q_STATIC_ASSERT(sizeof(size_t) == sizeof(qsizetype)); // implied by the definition
Q_STATIC_ASSERT((std::is_same<qssize_t, qptrdiff>::value)); Q_STATIC_ASSERT((std::is_same<qsizetype, qptrdiff>::value));
/*! /*!
\class QFlag \class QFlag
@ -824,7 +824,7 @@ Q_STATIC_ASSERT((std::is_same<qssize_t, qptrdiff>::value));
*/ */
/*! /*!
\typedef qssize_t \typedef qsizetype
\relates <QtGlobal> \relates <QtGlobal>
\since 5.10 \since 5.10
@ -833,7 +833,7 @@ Q_STATIC_ASSERT((std::is_same<qssize_t, qptrdiff>::value));
This type is guaranteed to be the same size as a \c size_t on all This type is guaranteed to be the same size as a \c size_t on all
platforms supported by Qt. platforms supported by Qt.
Note that qssize_t is signed. Use \c size_t for unsigned values. Note that qsizetype is signed. Use \c size_t for unsigned values.
\sa qptrdiff \sa qptrdiff
*/ */

View File

@ -439,7 +439,7 @@ namespace QtPrivate {
sizeof(void *) == sizeof(quintptr) sizeof(void *) == sizeof(quintptr)
&& sizeof(void *) == sizeof(qptrdiff) && sizeof(void *) == sizeof(qptrdiff)
size_t and qssize_t are not guaranteed to be the same size as a pointer, but size_t and qsizetype are not guaranteed to be the same size as a pointer, but
they usually are. they usually are.
*/ */
template <int> struct QIntegerForSize; template <int> struct QIntegerForSize;
@ -456,7 +456,7 @@ typedef QIntegerForSize<Q_PROCESSOR_WORDSIZE>::Unsigned qregisteruint;
typedef QIntegerForSizeof<void*>::Unsigned quintptr; typedef QIntegerForSizeof<void*>::Unsigned quintptr;
typedef QIntegerForSizeof<void*>::Signed qptrdiff; typedef QIntegerForSizeof<void*>::Signed qptrdiff;
typedef qptrdiff qintptr; typedef qptrdiff qintptr;
using qssize_t = QIntegerForSizeof<std::size_t>::Signed; using qsizetype = QIntegerForSizeof<std::size_t>::Signed;
/* moc compats (signals/slots) */ /* moc compats (signals/slots) */
#ifndef QT_MOC_COMPAT #ifndef QT_MOC_COMPAT

View File

@ -93,7 +93,7 @@ DECLSPEC_IMPORT BOOLEAN WINAPI SystemFunction036(PVOID RandomBuffer, ULONG Rando
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
#if defined(Q_PROCESSOR_X86) && QT_COMPILER_SUPPORTS_HERE(RDRND) #if defined(Q_PROCESSOR_X86) && QT_COMPILER_SUPPORTS_HERE(RDRND)
static qssize_t qt_random_cpu(void *buffer, qssize_t count) Q_DECL_NOTHROW; static qsizetype qt_random_cpu(void *buffer, qsizetype count) Q_DECL_NOTHROW;
# ifdef Q_PROCESSOR_X86_64 # ifdef Q_PROCESSOR_X86_64
# define _rdrandXX_step _rdrand64_step # define _rdrandXX_step _rdrand64_step
@ -101,7 +101,7 @@ static qssize_t qt_random_cpu(void *buffer, qssize_t count) Q_DECL_NOTHROW;
# define _rdrandXX_step _rdrand32_step # define _rdrandXX_step _rdrand32_step
# endif # endif
static QT_FUNCTION_TARGET(RDRND) qssize_t qt_random_cpu(void *buffer, qssize_t count) Q_DECL_NOTHROW static QT_FUNCTION_TARGET(RDRND) qsizetype qt_random_cpu(void *buffer, qsizetype count) Q_DECL_NOTHROW
{ {
unsigned *ptr = reinterpret_cast<unsigned *>(buffer); unsigned *ptr = reinterpret_cast<unsigned *>(buffer);
unsigned *end = ptr + count; unsigned *end = ptr + count;
@ -122,7 +122,7 @@ out:
return ptr - reinterpret_cast<unsigned *>(buffer); return ptr - reinterpret_cast<unsigned *>(buffer);
} }
#else #else
static qssize_t qt_random_cpu(void *, qssize_t) static qsizetype qt_random_cpu(void *, qsizetype)
{ {
return 0; return 0;
} }
@ -136,10 +136,10 @@ enum {
struct QRandomGenerator::SystemGenerator struct QRandomGenerator::SystemGenerator
{ {
#if QT_CONFIG(getentropy) #if QT_CONFIG(getentropy)
static qssize_t fillBuffer(void *buffer, qssize_t count) Q_DECL_NOTHROW static qsizetype fillBuffer(void *buffer, qsizetype count) Q_DECL_NOTHROW
{ {
// getentropy can read at most 256 bytes, so break the reading // getentropy can read at most 256 bytes, so break the reading
qssize_t read = 0; qsizetype read = 0;
while (count - read > 256) { while (count - read > 256) {
// getentropy can't fail under normal circumstances // getentropy can't fail under normal circumstances
int ret = getentropy(reinterpret_cast<uchar *>(buffer) + read, 256); int ret = getentropy(reinterpret_cast<uchar *>(buffer) + read, 256);
@ -195,24 +195,24 @@ struct QRandomGenerator::SystemGenerator
Q_DECL_CONSTEXPR SystemGenerator() : fdp1 Q_BASIC_ATOMIC_INITIALIZER(0) {} Q_DECL_CONSTEXPR SystemGenerator() : fdp1 Q_BASIC_ATOMIC_INITIALIZER(0) {}
qssize_t fillBuffer(void *buffer, qssize_t count) qsizetype fillBuffer(void *buffer, qsizetype count)
{ {
int fd = openDevice(); int fd = openDevice();
if (Q_UNLIKELY(fd < 0)) if (Q_UNLIKELY(fd < 0))
return 0; return 0;
qint64 n = qt_safe_read(fd, buffer, count); qint64 n = qt_safe_read(fd, buffer, count);
return qMax<qssize_t>(n, 0); // ignore any errors return qMax<qsizetype>(n, 0); // ignore any errors
} }
#elif defined(Q_OS_WIN) && !defined(Q_OS_WINRT) #elif defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
qssize_t fillBuffer(void *buffer, qssize_t count) Q_DECL_NOTHROW qsizetype fillBuffer(void *buffer, qsizetype count) Q_DECL_NOTHROW
{ {
auto RtlGenRandom = SystemFunction036; auto RtlGenRandom = SystemFunction036;
return RtlGenRandom(buffer, ULONG(count)) ? count: 0; return RtlGenRandom(buffer, ULONG(count)) ? count: 0;
} }
#elif defined(Q_OS_WINRT) #elif defined(Q_OS_WINRT)
qssize_t fillBuffer(void *, qssize_t) Q_DECL_NOTHROW qsizetype fillBuffer(void *, qsizetype) Q_DECL_NOTHROW
{ {
// always use the fallback // always use the fallback
return 0; return 0;
@ -243,7 +243,7 @@ struct QRandomGenerator::SystemGenerator
#if defined(Q_OS_WIN) #if defined(Q_OS_WIN)
static void fallback_update_seed(unsigned) {} static void fallback_update_seed(unsigned) {}
static void fallback_fill(quint32 *ptr, qssize_t left) Q_DECL_NOTHROW static void fallback_fill(quint32 *ptr, qsizetype left) Q_DECL_NOTHROW
{ {
// on Windows, rand_s is a high-quality random number generator // on Windows, rand_s is a high-quality random number generator
// and it requires no seeding // and it requires no seeding
@ -255,14 +255,14 @@ static void fallback_fill(quint32 *ptr, qssize_t left) Q_DECL_NOTHROW
} }
#elif QT_CONFIG(getentropy) #elif QT_CONFIG(getentropy)
static void fallback_update_seed(unsigned) {} static void fallback_update_seed(unsigned) {}
static void fallback_fill(quint32 *, qssize_t) Q_DECL_NOTHROW static void fallback_fill(quint32 *, qsizetype) Q_DECL_NOTHROW
{ {
// no fallback necessary, getentropy cannot fail under normal circumstances // no fallback necessary, getentropy cannot fail under normal circumstances
Q_UNREACHABLE(); Q_UNREACHABLE();
} }
#elif defined(Q_OS_BSD4) #elif defined(Q_OS_BSD4)
static void fallback_update_seed(unsigned) {} static void fallback_update_seed(unsigned) {}
static void fallback_fill(quint32 *ptr, qssize_t left) Q_DECL_NOTHROW static void fallback_fill(quint32 *ptr, qsizetype left) Q_DECL_NOTHROW
{ {
// BSDs have arc4random(4) and these work even in chroot(2) // BSDs have arc4random(4) and these work even in chroot(2)
arc4random_buf(ptr, left * sizeof(*ptr)); arc4random_buf(ptr, left * sizeof(*ptr));
@ -281,7 +281,7 @@ Q_NEVER_INLINE
#ifdef Q_CC_GNU #ifdef Q_CC_GNU
__attribute__((cold)) // this function is pretty big, so optimize for size __attribute__((cold)) // this function is pretty big, so optimize for size
#endif #endif
static void fallback_fill(quint32 *ptr, qssize_t left) Q_DECL_NOTHROW static void fallback_fill(quint32 *ptr, qsizetype left) Q_DECL_NOTHROW
{ {
quint32 scratch[12]; // see element count below quint32 scratch[12]; // see element count below
quint32 *end = scratch; quint32 *end = scratch;
@ -358,7 +358,7 @@ Q_NEVER_INLINE void QRandomGenerator::SystemGenerator::generate(quint32 *begin,
Q_DECL_NOEXCEPT_EXPR(FillBufferNoexcept) Q_DECL_NOEXCEPT_EXPR(FillBufferNoexcept)
{ {
quint32 *buffer = begin; quint32 *buffer = begin;
qssize_t count = end - begin; qsizetype count = end - begin;
if (Q_UNLIKELY(uint(qt_randomdevice_control) & SetRandomData)) { if (Q_UNLIKELY(uint(qt_randomdevice_control) & SetRandomData)) {
uint value = uint(qt_randomdevice_control) & RandomDataMask; uint value = uint(qt_randomdevice_control) & RandomDataMask;
@ -366,14 +366,14 @@ Q_NEVER_INLINE void QRandomGenerator::SystemGenerator::generate(quint32 *begin,
return; return;
} }
qssize_t filled = 0; qsizetype filled = 0;
if (qt_has_hwrng() && (uint(qt_randomdevice_control) & SkipHWRNG) == 0) if (qt_has_hwrng() && (uint(qt_randomdevice_control) & SkipHWRNG) == 0)
filled += qt_random_cpu(buffer, count); filled += qt_random_cpu(buffer, count);
if (filled != count && (uint(qt_randomdevice_control) & SkipSystemRNG) == 0) { if (filled != count && (uint(qt_randomdevice_control) & SkipSystemRNG) == 0) {
qssize_t bytesFilled = qsizetype bytesFilled =
fillBuffer(buffer + filled, (count - filled) * qssize_t(sizeof(*buffer))); fillBuffer(buffer + filled, (count - filled) * qsizetype(sizeof(*buffer)));
filled += bytesFilled / qssize_t(sizeof(*buffer)); filled += bytesFilled / qsizetype(sizeof(*buffer));
} }
if (filled) if (filled)
fallback_update_seed(*buffer); fallback_update_seed(*buffer);
@ -677,7 +677,7 @@ inline QRandomGenerator::SystemGenerator &QRandomGenerator::SystemGenerator::sel
*/ */
/*! /*!
\fn QRandomGenerator::QRandomGenerator(const quint32 *seedBuffer, qssize_t len) \fn QRandomGenerator::QRandomGenerator(const quint32 *seedBuffer, qsizetype len)
\overload \overload
Initializes this QRandomGenerator object with \a len values found in Initializes this QRandomGenerator object with \a len values found in
@ -853,7 +853,7 @@ inline QRandomGenerator::SystemGenerator &QRandomGenerator::SystemGenerator::sel
*/ */
/*! /*!
\fn void QRandomGenerator::fillRange(UInt *buffer, qssize_t count) \fn void QRandomGenerator::fillRange(UInt *buffer, qsizetype count)
Generates \a count 32- or 64-bit quantities (depending on the type \c UInt) Generates \a count 32- or 64-bit quantities (depending on the type \c UInt)
and stores them in the buffer pointed by \a buffer. This is the most and stores them in the buffer pointed by \a buffer. This is the most

View File

@ -55,10 +55,10 @@ public:
QRandomGenerator(quint32 seedValue = 1) QRandomGenerator(quint32 seedValue = 1)
: QRandomGenerator(&seedValue, 1) : QRandomGenerator(&seedValue, 1)
{} {}
template <qssize_t N> QRandomGenerator(const quint32 (&seedBuffer)[N]) template <qsizetype N> QRandomGenerator(const quint32 (&seedBuffer)[N])
: QRandomGenerator(seedBuffer, seedBuffer + N) : QRandomGenerator(seedBuffer, seedBuffer + N)
{} {}
QRandomGenerator(const quint32 *seedBuffer, qssize_t len) QRandomGenerator(const quint32 *seedBuffer, qsizetype len)
: QRandomGenerator(seedBuffer, seedBuffer + len) : QRandomGenerator(seedBuffer, seedBuffer + len)
{} {}
Q_CORE_EXPORT QRandomGenerator(std::seed_seq &sseq) Q_DECL_NOTHROW; Q_CORE_EXPORT QRandomGenerator(std::seed_seq &sseq) Q_DECL_NOTHROW;
@ -131,7 +131,7 @@ public:
} }
template <typename UInt, IfValidUInt<UInt> = true> template <typename UInt, IfValidUInt<UInt> = true>
void fillRange(UInt *buffer, qssize_t count) void fillRange(UInt *buffer, qsizetype count)
{ {
_fillRange(buffer, buffer + count); _fillRange(buffer, buffer + count);
} }
@ -215,10 +215,10 @@ public:
QRandomGenerator64(quint32 seedValue = 1) QRandomGenerator64(quint32 seedValue = 1)
: QRandomGenerator(seedValue) : QRandomGenerator(seedValue)
{} {}
template <qssize_t N> QRandomGenerator64(const quint32 (&seedBuffer)[N]) template <qsizetype N> QRandomGenerator64(const quint32 (&seedBuffer)[N])
: QRandomGenerator(seedBuffer) : QRandomGenerator(seedBuffer)
{} {}
QRandomGenerator64(const quint32 *seedBuffer, qssize_t len) QRandomGenerator64(const quint32 *seedBuffer, qsizetype len)
: QRandomGenerator(seedBuffer, len) : QRandomGenerator(seedBuffer, len)
{} {}
QRandomGenerator64(std::seed_seq &sseq) Q_DECL_NOTHROW QRandomGenerator64(std::seed_seq &sseq) Q_DECL_NOTHROW

View File

@ -86,8 +86,8 @@ public:
} }
const QChar *m_data; const QChar *m_data;
qssize_t m_len; qsizetype m_len;
qssize_t m_pos = 0; qsizetype m_pos = 0;
QChar m_splitChar = QLatin1Char('/'); QChar m_splitChar = QLatin1Char('/');
}; };

View File

@ -74,8 +74,8 @@ QT_BEGIN_NAMESPACE
struct QTemporaryFileName struct QTemporaryFileName
{ {
QFileSystemEntry::NativePath path; QFileSystemEntry::NativePath path;
qssize_t pos; qsizetype pos;
qssize_t length; qsizetype length;
QTemporaryFileName(const QString &templateName); QTemporaryFileName(const QString &templateName);
QFileSystemEntry::NativePath generateNext(); QFileSystemEntry::NativePath generateNext();

View File

@ -576,7 +576,7 @@ int qt_repeatCount(QStringView s)
if (s.isEmpty()) if (s.isEmpty())
return 0; return 0;
const QChar c = s.front(); const QChar c = s.front();
qssize_t j = 1; qsizetype j = 1;
while (j < s.size() && s.at(j) == c) while (j < s.size() && s.at(j) == c)
++j; ++j;
return int(j); return int(j);
@ -3443,7 +3443,7 @@ bool QLocaleData::validateChars(QStringView str, NumberMode numMode, QByteArray
bool dec = false; bool dec = false;
int decDigitCnt = 0; int decDigitCnt = 0;
for (qssize_t i = 0; i < str.size(); ++i) { for (qsizetype i = 0; i < str.size(); ++i) {
char c = digitToCLocale(str.at(i)); char c = digitToCLocale(str.at(i));
if (c >= '0' && c <= '9') { if (c >= '0' && c <= '9') {

View File

@ -160,9 +160,9 @@ static inline bool qt_ends_with(QStringView haystack, QStringView needle, Qt::Ca
static inline bool qt_ends_with(QStringView haystack, QLatin1String needle, Qt::CaseSensitivity cs); static inline bool qt_ends_with(QStringView haystack, QLatin1String needle, Qt::CaseSensitivity cs);
static inline bool qt_ends_with(QStringView haystack, QChar needle, Qt::CaseSensitivity cs); static inline bool qt_ends_with(QStringView haystack, QChar needle, Qt::CaseSensitivity cs);
qssize_t QtPrivate::qustrlen(const ushort *str) Q_DECL_NOTHROW qsizetype QtPrivate::qustrlen(const ushort *str) Q_DECL_NOTHROW
{ {
qssize_t result = 0; qsizetype result = 0;
#ifdef __SSE2__ #ifdef __SSE2__
// find the 16-byte alignment immediately prior or equal to str // find the 16-byte alignment immediately prior or equal to str

View File

@ -55,7 +55,7 @@ template <typename T> class QVector;
namespace QtPrivate { namespace QtPrivate {
Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qssize_t qustrlen(const ushort *str) Q_DECL_NOTHROW; Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype qustrlen(const ushort *str) Q_DECL_NOTHROW;
Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QStringView lhs, QStringView rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW; Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QStringView lhs, QStringView rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW;
Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QStringView lhs, QLatin1String rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW; Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QStringView lhs, QLatin1String rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW;

View File

@ -120,7 +120,7 @@
*/ */
/*! /*!
\fn QStringIterator::QStringIterator(QStringView string, qssize_t idx) \fn QStringIterator::QStringIterator(QStringView string, qsizetype idx)
Constructs an iterator over the contents of \a string. The iterator will point Constructs an iterator over the contents of \a string. The iterator will point
before position \a idx in the string. before position \a idx in the string.

View File

@ -62,7 +62,7 @@ class QStringIterator
QString::const_iterator i, pos, e; QString::const_iterator i, pos, e;
Q_STATIC_ASSERT((std::is_same<QString::const_iterator, const QChar *>::value)); Q_STATIC_ASSERT((std::is_same<QString::const_iterator, const QChar *>::value));
public: public:
explicit QStringIterator(QStringView string, qssize_t idx = 0) explicit QStringIterator(QStringView string, qsizetype idx = 0)
: i(string.begin()), : i(string.begin()),
pos(i + idx), pos(i + idx),
e(string.end()) e(string.end())

View File

@ -131,9 +131,9 @@ QT_BEGIN_NAMESPACE
/*! /*!
\typedef QStringView::size_type \typedef QStringView::size_type
Alias for qssize_t. Provided for compatibility with the STL. Alias for qsizetype. Provided for compatibility with the STL.
Unlike other Qt classes, QStringView uses qssize_t as its \c size_type, to allow Unlike other Qt classes, QStringView uses qsizetype as its \c size_type, to allow
accepting data from \c{std::basic_string} without truncation. The Qt API functions, accepting data from \c{std::basic_string} without truncation. The Qt API functions,
for example length(), return \c int, while the STL-compatible functions, for example for example length(), return \c int, while the STL-compatible functions, for example
size(), return \c size_type. size(), return \c size_type.
@ -224,7 +224,7 @@ QT_BEGIN_NAMESPACE
*/ */
/*! /*!
\fn QStringView::QStringView(const Char *str, qssize_t len) \fn QStringView::QStringView(const Char *str, qsizetype len)
Constructs a string view on \a str with length \a len. Constructs a string view on \a str with length \a len.
@ -486,7 +486,7 @@ QT_BEGIN_NAMESPACE
*/ */
/*! /*!
\fn qssize_t QStringView::size() const \fn qsizetype QStringView::size() const
Returns the size of this string view, in UTF-16 code points (that is, Returns the size of this string view, in UTF-16 code points (that is,
surrogate pairs count as two for the purposes of this function, the same surrogate pairs count as two for the purposes of this function, the same
@ -510,7 +510,7 @@ QT_BEGIN_NAMESPACE
*/ */
/*! /*!
\fn QChar QStringView::operator[](qssize_t n) const \fn QChar QStringView::operator[](qsizetype n) const
Returns the character at position \a n in this string view. Returns the character at position \a n in this string view.
@ -520,7 +520,7 @@ QT_BEGIN_NAMESPACE
*/ */
/*! /*!
\fn QChar QStringView::at(qssize_t n) const \fn QChar QStringView::at(qsizetype n) const
Returns the character at position \a n in this string view. Returns the character at position \a n in this string view.
@ -582,7 +582,7 @@ QT_BEGIN_NAMESPACE
*/ */
/*! /*!
\fn QStringView QStringView::mid(qssize_t start) const \fn QStringView QStringView::mid(qsizetype start) const
Returns the substring starting at position \a start in this object, Returns the substring starting at position \a start in this object,
and extending to the end of the string. and extending to the end of the string.
@ -593,7 +593,7 @@ QT_BEGIN_NAMESPACE
*/ */
/*! /*!
\fn QStringView QStringView::mid(qssize_t start, qssize_t length) const \fn QStringView QStringView::mid(qsizetype start, qsizetype length) const
\overload \overload
Returns the substring of length \a length starting at position Returns the substring of length \a length starting at position
@ -606,7 +606,7 @@ QT_BEGIN_NAMESPACE
*/ */
/*! /*!
\fn QStringView QStringView::left(qssize_t length) const \fn QStringView QStringView::left(qsizetype length) const
Returns the substring of length \a length starting at position Returns the substring of length \a length starting at position
0 in this object. 0 in this object.
@ -617,7 +617,7 @@ QT_BEGIN_NAMESPACE
*/ */
/*! /*!
\fn QStringView QStringView::right(qssize_t length) const \fn QStringView QStringView::right(qsizetype length) const
Returns the substring of length \a length starting at position Returns the substring of length \a length starting at position
size() - \a length in this object. size() - \a length in this object.
@ -628,7 +628,7 @@ QT_BEGIN_NAMESPACE
*/ */
/*! /*!
\fn QStringView QStringView::chopped(qssize_t length) const \fn QStringView QStringView::chopped(qsizetype length) const
Returns the substring of length size() - \a length starting at the Returns the substring of length size() - \a length starting at the
beginning of this object. beginning of this object.
@ -641,7 +641,7 @@ QT_BEGIN_NAMESPACE
*/ */
/*! /*!
\fn void QStringView::truncate(qssize_t length) \fn void QStringView::truncate(qsizetype length)
Truncates this string view to length \a length. Truncates this string view to length \a length.
@ -653,7 +653,7 @@ QT_BEGIN_NAMESPACE
*/ */
/*! /*!
\fn void QStringView::chop(qssize_t length) \fn void QStringView::chop(qsizetype length)
Truncates this string view by \a length characters. Truncates this string view by \a length characters.

View File

@ -111,7 +111,7 @@ public:
#endif #endif
typedef const QChar value_type; typedef const QChar value_type;
typedef std::ptrdiff_t difference_type; typedef std::ptrdiff_t difference_type;
typedef qssize_t size_type; typedef qsizetype size_type;
typedef value_type &reference; typedef value_type &reference;
typedef value_type &const_reference; typedef value_type &const_reference;
typedef value_type *pointer; typedef value_type *pointer;
@ -139,24 +139,24 @@ private:
using if_compatible_qstring_like = typename std::enable_if<std::is_same<T, QString>::value || std::is_same<T, QStringRef>::value, bool>::type; using if_compatible_qstring_like = typename std::enable_if<std::is_same<T, QString>::value || std::is_same<T, QStringRef>::value, bool>::type;
template <typename Char, size_t N> template <typename Char, size_t N>
static Q_DECL_CONSTEXPR qssize_t lengthHelperArray(const Char (&)[N]) Q_DECL_NOTHROW static Q_DECL_CONSTEXPR qsizetype lengthHelperArray(const Char (&)[N]) Q_DECL_NOTHROW
{ {
return qssize_t(N - 1); return qsizetype(N - 1);
} }
template <typename Char> template <typename Char>
static qssize_t lengthHelperPointer(const Char *str) Q_DECL_NOTHROW static qsizetype lengthHelperPointer(const Char *str) Q_DECL_NOTHROW
{ {
#if defined(Q_CC_GNU) && !defined(Q_CC_CLANG) && !defined(Q_CC_INTEL) #if defined(Q_CC_GNU) && !defined(Q_CC_CLANG) && !defined(Q_CC_INTEL)
if (__builtin_constant_p(*str)) { if (__builtin_constant_p(*str)) {
qssize_t result = 0; qsizetype result = 0;
while (*str++) while (*str++)
++result; ++result;
} }
#endif #endif
return QtPrivate::qustrlen(reinterpret_cast<const ushort *>(str)); return QtPrivate::qustrlen(reinterpret_cast<const ushort *>(str));
} }
static qssize_t lengthHelperPointer(const QChar *str) Q_DECL_NOTHROW static qsizetype lengthHelperPointer(const QChar *str) Q_DECL_NOTHROW
{ {
return QtPrivate::qustrlen(reinterpret_cast<const ushort *>(str)); return QtPrivate::qustrlen(reinterpret_cast<const ushort *>(str));
} }
@ -174,7 +174,7 @@ public:
: QStringView() {} : QStringView() {}
template <typename Char, if_compatible_char<Char> = true> template <typename Char, if_compatible_char<Char> = true>
Q_DECL_CONSTEXPR QStringView(const Char *str, qssize_t len) Q_DECL_CONSTEXPR QStringView(const Char *str, qsizetype len)
: m_size((Q_ASSERT(len >= 0), Q_ASSERT(str || !len), len)), : m_size((Q_ASSERT(len >= 0), Q_ASSERT(str || !len), len)),
m_data(castHelper(str)) {} m_data(castHelper(str)) {}
@ -204,20 +204,20 @@ public:
#else #else
template <typename String, if_compatible_qstring_like<String> = true> template <typename String, if_compatible_qstring_like<String> = true>
QStringView(const String &str) Q_DECL_NOTHROW QStringView(const String &str) Q_DECL_NOTHROW
: QStringView(str.isNull() ? nullptr : str.data(), qssize_t(str.size())) {} : QStringView(str.isNull() ? nullptr : str.data(), qsizetype(str.size())) {}
#endif #endif
template <typename StdBasicString, if_compatible_string<StdBasicString> = true> template <typename StdBasicString, if_compatible_string<StdBasicString> = true>
QStringView(const StdBasicString &str) Q_DECL_NOTHROW QStringView(const StdBasicString &str) Q_DECL_NOTHROW
: QStringView(str.data(), qssize_t(str.size())) {} : QStringView(str.data(), qsizetype(str.size())) {}
Q_REQUIRED_RESULT inline QString toString() const; // defined in qstring.h Q_REQUIRED_RESULT inline QString toString() const; // defined in qstring.h
Q_REQUIRED_RESULT Q_DECL_CONSTEXPR qssize_t size() const Q_DECL_NOTHROW { return m_size; } Q_REQUIRED_RESULT Q_DECL_CONSTEXPR qsizetype size() const Q_DECL_NOTHROW { return m_size; }
Q_REQUIRED_RESULT const_pointer data() const Q_DECL_NOTHROW { return reinterpret_cast<const_pointer>(m_data); } Q_REQUIRED_RESULT const_pointer data() const Q_DECL_NOTHROW { return reinterpret_cast<const_pointer>(m_data); }
Q_REQUIRED_RESULT Q_DECL_CONSTEXPR const storage_type *utf16() const Q_DECL_NOTHROW { return m_data; } Q_REQUIRED_RESULT Q_DECL_CONSTEXPR const storage_type *utf16() const Q_DECL_NOTHROW { return m_data; }
Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QChar operator[](qssize_t n) const Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QChar operator[](qsizetype n) const
{ return Q_ASSERT(n >= 0), Q_ASSERT(n < size()), QChar(m_data[n]); } { return Q_ASSERT(n >= 0), Q_ASSERT(n < size()), QChar(m_data[n]); }
// //
@ -229,22 +229,22 @@ public:
Q_REQUIRED_RESULT QByteArray toLocal8Bit() const { return QtPrivate::convertToLocal8Bit(*this); } Q_REQUIRED_RESULT QByteArray toLocal8Bit() const { return QtPrivate::convertToLocal8Bit(*this); }
Q_REQUIRED_RESULT inline QVector<uint> toUcs4() const; // defined in qvector.h Q_REQUIRED_RESULT inline QVector<uint> toUcs4() const; // defined in qvector.h
Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QChar at(qssize_t n) const { return (*this)[n]; } Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QChar at(qsizetype n) const { return (*this)[n]; }
Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QStringView mid(qssize_t pos) const Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QStringView mid(qsizetype pos) const
{ return Q_ASSERT(pos >= 0), Q_ASSERT(pos <= size()), QStringView(m_data + pos, m_size - pos); } { return Q_ASSERT(pos >= 0), Q_ASSERT(pos <= size()), QStringView(m_data + pos, m_size - pos); }
Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QStringView mid(qssize_t pos, qssize_t n) const Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QStringView mid(qsizetype pos, qsizetype n) const
{ return Q_ASSERT(pos >= 0), Q_ASSERT(n >= 0), Q_ASSERT(pos + n <= size()), QStringView(m_data + pos, n); } { return Q_ASSERT(pos >= 0), Q_ASSERT(n >= 0), Q_ASSERT(pos + n <= size()), QStringView(m_data + pos, n); }
Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QStringView left(qssize_t n) const Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QStringView left(qsizetype n) const
{ return Q_ASSERT(n >= 0), Q_ASSERT(n <= size()), QStringView(m_data, n); } { return Q_ASSERT(n >= 0), Q_ASSERT(n <= size()), QStringView(m_data, n); }
Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QStringView right(qssize_t n) const Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QStringView right(qsizetype n) const
{ return Q_ASSERT(n >= 0), Q_ASSERT(n <= size()), QStringView(m_data + m_size - n, n); } { return Q_ASSERT(n >= 0), Q_ASSERT(n <= size()), QStringView(m_data + m_size - n, n); }
Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QStringView chopped(qssize_t n) const Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QStringView chopped(qsizetype n) const
{ return Q_ASSERT(n >= 0), Q_ASSERT(n <= size()), QStringView(m_data, m_size - n); } { return Q_ASSERT(n >= 0), Q_ASSERT(n <= size()), QStringView(m_data, m_size - n); }
Q_DECL_RELAXED_CONSTEXPR void truncate(qssize_t n) Q_DECL_RELAXED_CONSTEXPR void truncate(qsizetype n)
{ Q_ASSERT(n >= 0); Q_ASSERT(n <= size()); m_size = n; } { Q_ASSERT(n >= 0); Q_ASSERT(n <= size()); m_size = n; }
Q_DECL_RELAXED_CONSTEXPR void chop(qssize_t n) Q_DECL_RELAXED_CONSTEXPR void chop(qsizetype n)
{ Q_ASSERT(n >= 0); Q_ASSERT(n <= size()); m_size -= n; } { Q_ASSERT(n >= 0); Q_ASSERT(n <= size()); m_size -= n; }
Q_REQUIRED_RESULT QStringView trimmed() const Q_DECL_NOTHROW { return QtPrivate::trimmed(*this); } Q_REQUIRED_RESULT QStringView trimmed() const Q_DECL_NOTHROW { return QtPrivate::trimmed(*this); }
@ -291,7 +291,7 @@ public:
Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QChar first() const { return front(); } Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QChar first() const { return front(); }
Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QChar last() const { return back(); } Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QChar last() const { return back(); }
private: private:
qssize_t m_size; qsizetype m_size;
const storage_type *m_data; const storage_type *m_data;
}; };
Q_DECLARE_TYPEINFO(QStringView, Q_PRIMITIVE_TYPE); Q_DECLARE_TYPEINFO(QStringView, Q_PRIMITIVE_TYPE);

View File

@ -49,10 +49,10 @@ QT_BEGIN_NAMESPACE
static void swapPixel01(QImage *image) // 1-bpp: swap 0 and 1 pixels static void swapPixel01(QImage *image) // 1-bpp: swap 0 and 1 pixels
{ {
qssize_t i; qsizetype i;
if (image->depth() == 1 && image->colorCount() == 2) { if (image->depth() == 1 && image->colorCount() == 2) {
uint *p = (uint *)image->bits(); uint *p = (uint *)image->bits();
qssize_t nbytes = static_cast<qssize_t>(image->sizeInBytes()); qsizetype nbytes = static_cast<qsizetype>(image->sizeInBytes());
for (i=0; i<nbytes/4; i++) { for (i=0; i<nbytes/4; i++) {
*p = ~*p; *p = ~*p;
p++; p++;

View File

@ -130,7 +130,7 @@ QImageData * QImageData::create(const QSize &size, QImage::Format format)
if (std::numeric_limits<int>::max()/depth < width if (std::numeric_limits<int>::max()/depth < width
|| bytes_per_line <= 0 || bytes_per_line <= 0
|| height <= 0 || height <= 0
|| std::numeric_limits<qssize_t>::max()/uint(bytes_per_line) < height || std::numeric_limits<qsizetype>::max()/uint(bytes_per_line) < height
|| std::numeric_limits<int>::max()/sizeof(uchar *) < uint(height)) || std::numeric_limits<int>::max()/sizeof(uchar *) < uint(height))
return 0; return 0;
@ -1470,7 +1470,7 @@ int QImage::byteCount() const
\sa byteCount(), bytesPerLine(), bits(), {QImage#Image Information}{Image \sa byteCount(), bytesPerLine(), bits(), {QImage#Image Information}{Image
Information} Information}
*/ */
qssize_t QImage::sizeInBytes() const qsizetype QImage::sizeInBytes() const
{ {
return d ? d->nbytes : 0; return d ? d->nbytes : 0;
} }

View File

@ -217,7 +217,7 @@ public:
#if QT_DEPRECATED_SINCE(5, 10) #if QT_DEPRECATED_SINCE(5, 10)
QT_DEPRECATED int byteCount() const; QT_DEPRECATED int byteCount() const;
#endif #endif
qssize_t sizeInBytes() const; qsizetype sizeInBytes() const;
uchar *scanLine(int); uchar *scanLine(int);
const uchar *scanLine(int) const; const uchar *scanLine(int) const;

View File

@ -823,8 +823,8 @@ static bool convert_indexed8_to_ARGB_PM_inplace(QImageData *data, Qt::ImageConve
const int depth = 32; const int depth = 32;
const qssize_t dst_bytes_per_line = ((data->width * depth + 31) >> 5) << 2; const qsizetype dst_bytes_per_line = ((data->width * depth + 31) >> 5) << 2;
const qssize_t nbytes = dst_bytes_per_line * data->height; const qsizetype nbytes = dst_bytes_per_line * data->height;
uchar *const newData = (uchar *)realloc(data->data, nbytes); uchar *const newData = (uchar *)realloc(data->data, nbytes);
if (!newData) if (!newData)
return false; return false;
@ -877,8 +877,8 @@ static bool convert_indexed8_to_ARGB_inplace(QImageData *data, Qt::ImageConversi
const int depth = 32; const int depth = 32;
const qssize_t dst_bytes_per_line = ((data->width * depth + 31) >> 5) << 2; const qsizetype dst_bytes_per_line = ((data->width * depth + 31) >> 5) << 2;
const qssize_t nbytes = dst_bytes_per_line * data->height; const qsizetype nbytes = dst_bytes_per_line * data->height;
uchar *const newData = (uchar *)realloc(data->data, nbytes); uchar *const newData = (uchar *)realloc(data->data, nbytes);
if (!newData) if (!newData)
return false; return false;
@ -945,8 +945,8 @@ static bool convert_indexed8_to_RGB16_inplace(QImageData *data, Qt::ImageConvers
const int depth = 16; const int depth = 16;
const qssize_t dst_bytes_per_line = ((data->width * depth + 31) >> 5) << 2; const qsizetype dst_bytes_per_line = ((data->width * depth + 31) >> 5) << 2;
const qssize_t nbytes = dst_bytes_per_line * data->height; const qsizetype nbytes = dst_bytes_per_line * data->height;
uchar *const newData = (uchar *)realloc(data->data, nbytes); uchar *const newData = (uchar *)realloc(data->data, nbytes);
if (!newData) if (!newData)
return false; return false;
@ -1002,8 +1002,8 @@ static bool convert_RGB_to_RGB16_inplace(QImageData *data, Qt::ImageConversionFl
const int depth = 16; const int depth = 16;
const qssize_t dst_bytes_per_line = ((data->width * depth + 31) >> 5) << 2; const qsizetype dst_bytes_per_line = ((data->width * depth + 31) >> 5) << 2;
const qssize_t src_bytes_per_line = data->bytes_per_line; const qsizetype src_bytes_per_line = data->bytes_per_line;
quint32 *src_data = (quint32 *) data->data; quint32 *src_data = (quint32 *) data->data;
quint16 *dst_data = (quint16 *) data->data; quint16 *dst_data = (quint16 *) data->data;
@ -1257,9 +1257,9 @@ void dither_to_Mono(QImageData *dst, const QImageData *src,
} }
uchar *dst_data = dst->data; uchar *dst_data = dst->data;
qssize_t dst_bpl = dst->bytes_per_line; qsizetype dst_bpl = dst->bytes_per_line;
const uchar *src_data = src->data; const uchar *src_data = src->data;
qssize_t src_bpl = src->bytes_per_line; qsizetype src_bpl = src->bytes_per_line;
switch (dithermode) { switch (dithermode) {
case Diffuse: { case Diffuse: {
@ -1912,8 +1912,8 @@ static void convert_Indexed8_to_Alpha8(QImageData *dest, const QImageData *src,
if (simpleCase) if (simpleCase)
memcpy(dest->data, src->data, src->bytes_per_line * src->height); memcpy(dest->data, src->data, src->bytes_per_line * src->height);
else { else {
qssize_t size = src->bytes_per_line * src->height; qsizetype size = src->bytes_per_line * src->height;
for (qssize_t i = 0; i < size; ++i) { for (qsizetype i = 0; i < size; ++i) {
dest->data[i] = translate[src->data[i]]; dest->data[i] = translate[src->data[i]];
} }
} }
@ -1936,8 +1936,8 @@ static void convert_Indexed8_to_Grayscale8(QImageData *dest, const QImageData *s
if (simpleCase) if (simpleCase)
memcpy(dest->data, src->data, src->bytes_per_line * src->height); memcpy(dest->data, src->data, src->bytes_per_line * src->height);
else { else {
qssize_t size = src->bytes_per_line * src->height; qsizetype size = src->bytes_per_line * src->height;
for (qssize_t i = 0; i < size; ++i) { for (qsizetype i = 0; i < size; ++i) {
dest->data[i] = translate[src->data[i]]; dest->data[i] = translate[src->data[i]];
} }
} }

View File

@ -71,12 +71,12 @@ struct Q_GUI_EXPORT QImageData { // internal image data
int width; int width;
int height; int height;
int depth; int depth;
qssize_t nbytes; // number of bytes data qsizetype nbytes; // number of bytes data
qreal devicePixelRatio; qreal devicePixelRatio;
QVector<QRgb> colortable; QVector<QRgb> colortable;
uchar *data; uchar *data;
QImage::Format format; QImage::Format format;
qssize_t bytes_per_line; qsizetype bytes_per_line;
int ser_no; // serial number int ser_no; // serial number
int detach_no; int detach_no;

View File

@ -191,7 +191,7 @@ void QBlittablePlatformPixmap::fromImage(const QImage &image,
uchar *mem = thisImg->bits(); uchar *mem = thisImg->bits();
const uchar *bits = correctFormatPic.constBits(); const uchar *bits = correctFormatPic.constBits();
qssize_t bytesCopied = 0; qsizetype bytesCopied = 0;
while (bytesCopied < correctFormatPic.sizeInBytes()) { while (bytesCopied < correctFormatPic.sizeInBytes()) {
memcpy(mem,bits,correctFormatPic.bytesPerLine()); memcpy(mem,bits,correctFormatPic.bytesPerLine());
mem += thisImg->bytesPerLine(); mem += thisImg->bytesPerLine();

View File

@ -2383,7 +2383,7 @@ static void QT_FASTCALL fetchTransformedBilinearARGB32PM_fast_rotate_helper(uint
__m128i v_fy = _mm_setr_epi32(fy, fy + fdy, fy + fdy + fdy, fy + fdy + fdy + fdy); __m128i v_fy = _mm_setr_epi32(fy, fy + fdy, fy + fdy + fdy, fy + fdy + fdy + fdy);
const uchar *textureData = image.imageData; const uchar *textureData = image.imageData;
const qssize_t bytesPerLine = image.bytesPerLine; const qsizetype bytesPerLine = image.bytesPerLine;
const __m128i vbpl = _mm_shufflelo_epi16(_mm_cvtsi32_si128(bytesPerLine/4), _MM_SHUFFLE(0, 0, 0, 0)); const __m128i vbpl = _mm_shufflelo_epi16(_mm_cvtsi32_si128(bytesPerLine/4), _MM_SHUFFLE(0, 0, 0, 0));
while (b < boundedEnd - 3) { while (b < boundedEnd - 3) {
@ -4959,7 +4959,7 @@ static void blend_transformed_tiled_argb(int count, const QSpan *spans, void *us
int image_width = data->texture.width; int image_width = data->texture.width;
int image_height = data->texture.height; int image_height = data->texture.height;
const qssize_t scanline_offset = data->texture.bytesPerLine / 4; const qsizetype scanline_offset = data->texture.bytesPerLine / 4;
if (data->fast_matrix) { if (data->fast_matrix) {
// The increment pr x in the scanline // The increment pr x in the scanline

View File

@ -685,7 +685,7 @@ void QT_FASTCALL fetchTransformedBilinearARGB32PM_fast_rotate_helper_avx2(uint *
v_fy = _mm256_add_epi32(v_fy, _mm256_mullo_epi32(_mm256_set1_epi32(fdy), v_index)); v_fy = _mm256_add_epi32(v_fy, _mm256_mullo_epi32(_mm256_set1_epi32(fdy), v_index));
const uchar *textureData = image.imageData; const uchar *textureData = image.imageData;
const qssize_t bytesPerLine = image.bytesPerLine; const qsizetype bytesPerLine = image.bytesPerLine;
const __m256i vbpl = _mm256_set1_epi16(bytesPerLine/4); const __m256i vbpl = _mm256_set1_epi16(bytesPerLine/4);
while (b < boundedEnd - 7) { while (b < boundedEnd - 7) {

View File

@ -293,7 +293,7 @@ struct QTextureData
int y1; int y1;
int x2; int x2;
int y2; int y2;
qssize_t bytesPerLine; qsizetype bytesPerLine;
QImage::Format format; QImage::Format format;
const QVector<QRgb> *colorTable; const QVector<QRgb> *colorTable;
bool hasAlpha; bool hasAlpha;
@ -847,7 +847,7 @@ inline void qt_memfill(T *dest, T value, int count)
template <class T> Q_STATIC_TEMPLATE_FUNCTION template <class T> Q_STATIC_TEMPLATE_FUNCTION
inline void qt_rectfill(T *dest, T value, inline void qt_rectfill(T *dest, T value,
int x, int y, int width, int height, qssize_t stride) int x, int y, int width, int height, qsizetype stride)
{ {
char *d = reinterpret_cast<char*>(dest + x) + y * stride; char *d = reinterpret_cast<char*>(dest + x) + y * stride;
if (uint(stride) == (width * sizeof(T))) { if (uint(stride) == (width * sizeof(T))) {

View File

@ -994,7 +994,7 @@ void QRasterPaintEnginePrivate::drawImage(const QPointF &pt,
Q_ASSERT(img.depth() >= 8); Q_ASSERT(img.depth() >= 8);
qssize_t srcBPL = img.bytesPerLine(); qsizetype srcBPL = img.bytesPerLine();
const uchar *srcBits = img.bits(); const uchar *srcBits = img.bits();
int srcSize = img.depth() >> 3; // This is the part that is incompatible with lower than 8-bit.. int srcSize = img.depth() >> 3; // This is the part that is incompatible with lower than 8-bit..
int iw = img.width(); int iw = img.width();
@ -1043,7 +1043,7 @@ void QRasterPaintEnginePrivate::drawImage(const QPointF &pt,
// call the blend function... // call the blend function...
int dstSize = rasterBuffer->bytesPerPixel(); int dstSize = rasterBuffer->bytesPerPixel();
qssize_t dstBPL = rasterBuffer->bytesPerLine(); qsizetype dstBPL = rasterBuffer->bytesPerLine();
func(rasterBuffer->buffer() + x * dstSize + y * dstBPL, dstBPL, func(rasterBuffer->buffer() + x * dstSize + y * dstBPL, dstBPL,
srcBits, srcBPL, srcBits, srcBPL,
iw, ih, iw, ih,
@ -2318,8 +2318,8 @@ void QRasterPaintEngine::drawImage(const QRectF &r, const QImage &img, const QRe
clippedSourceRect = clippedSourceRect.intersected(img.rect()); clippedSourceRect = clippedSourceRect.intersected(img.rect());
const qssize_t dbpl = d->rasterBuffer->bytesPerLine(); const qsizetype dbpl = d->rasterBuffer->bytesPerLine();
const qssize_t sbpl = img.bytesPerLine(); const qsizetype sbpl = img.bytesPerLine();
uchar *dst = d->rasterBuffer->buffer(); uchar *dst = d->rasterBuffer->buffer();
uint bpp = img.depth() >> 3; uint bpp = img.depth() >> 3;
@ -2828,7 +2828,7 @@ bool QRasterPaintEngine::drawCachedGlyphs(int numGlyphs, const glyph_t *glyphs,
cache->fillInPendingGlyphs(); cache->fillInPendingGlyphs();
const QImage &image = cache->image(); const QImage &image = cache->image();
qssize_t bpl = image.bytesPerLine(); qsizetype bpl = image.bytesPerLine();
int depth = image.depth(); int depth = image.depth();
int rightShift = 0; int rightShift = 0;

View File

@ -461,9 +461,9 @@ void tst_QStringView::fromLiteral(const Char *arg) const
const Char *null = nullptr; const Char *null = nullptr;
const Char empty[] = { 0 }; const Char empty[] = { 0 };
QCOMPARE(QStringView(null).size(), qssize_t(0)); QCOMPARE(QStringView(null).size(), qsizetype(0));
QCOMPARE(QStringView(null).data(), nullptr); QCOMPARE(QStringView(null).data(), nullptr);
QCOMPARE(QStringView(empty).size(), qssize_t(0)); QCOMPARE(QStringView(empty).size(), qsizetype(0));
QCOMPARE(static_cast<const void*>(QStringView(empty).data()), QCOMPARE(static_cast<const void*>(QStringView(empty).data()),
static_cast<const void*>(empty)); static_cast<const void*>(empty));

View File

@ -3441,10 +3441,10 @@ void tst_QImage::hugeQImage()
QVERIFY(!image.isNull()); QVERIFY(!image.isNull());
QCOMPARE(image.height(), 25000); QCOMPARE(image.height(), 25000);
QCOMPARE(image.width(), 25000); QCOMPARE(image.width(), 25000);
QCOMPARE(image.sizeInBytes(), qssize_t(25000)*25000*4); QCOMPARE(image.sizeInBytes(), qsizetype(25000)*25000*4);
QCOMPARE(image.bytesPerLine(), 25000 * 4); QCOMPARE(image.bytesPerLine(), 25000 * 4);
QCOMPARE(image.constScanLine(24990), image.constBits() + qssize_t(25000)*24990*4); QCOMPARE(image.constScanLine(24990), image.constBits() + qsizetype(25000)*24990*4);
image.setPixel(20000, 24990, 0xffaabbcc); image.setPixel(20000, 24990, 0xffaabbcc);
QCOMPARE(image.pixel(20000, 24990), 0xffaabbcc); QCOMPARE(image.pixel(20000, 24990), 0xffaabbcc);