diff options
author | Liang Qi <liang.qi@qt.io> | 2019-08-13 09:46:17 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2019-08-13 09:46:17 +0200 |
commit | 1dade1bd8ad13a16152aff36351ac570b5b9fdf6 (patch) | |
tree | eafed5710b34c327a98381ca15fe1985a6487b10 /src/corelib/tools | |
parent | d45908e24292a41ff7838366b34be7340bf9fda5 (diff) | |
parent | fb703aea697b12de4810deec9f8605fd062208bd (diff) |
Merge remote-tracking branch 'origin/5.13' into dev
Conflicts:
mkspecs/win32-clang-msvc/qmake.conf
src/corelib/tools/qlist.h
src/gui/painting/qcompositionfunctions.cpp
src/gui/painting/qtriangulator_p.h
src/gui/text/qfontengine_p.h
src/network/kernel/qhostinfo_p.h
src/platformsupport/fontdatabases/freetype/qfontengine_ft.cpp
Done-With: Allan Sandfeld Jensen <allan.jensen@qt.io>
Change-Id: Ib8a0308cf77224c4fbdcf56778fdac4a43e37798
Diffstat (limited to 'src/corelib/tools')
-rw-r--r-- | src/corelib/tools/qbitarray.cpp | 20 | ||||
-rw-r--r-- | src/corelib/tools/qcryptographichash.cpp | 8 | ||||
-rw-r--r-- | src/corelib/tools/qlist.h | 4 |
3 files changed, 17 insertions, 15 deletions
diff --git a/src/corelib/tools/qbitarray.cpp b/src/corelib/tools/qbitarray.cpp index 4e8e3c241e..f0b81cce66 100644 --- a/src/corelib/tools/qbitarray.cpp +++ b/src/corelib/tools/qbitarray.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. -** Copyright (C) 2016 Intel Corporation. +** Copyright (C) 2019 Intel Corporation. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -132,12 +132,12 @@ QT_BEGIN_NAMESPACE * We overallocate the byte array by 1 byte. The first user bit is at * d.data()[1]. On the extra first byte, we store the difference between the * number of bits in the byte array (including this byte) and the number of - * bits in the bit array. Therefore, it's always a number between 8 and 15. + * bits in the bit array. Therefore, for a non-empty QBitArray, it's always a + * number between 8 and 15. For the empty one, d is the an empty QByteArray and + * *d.constData() is the QByteArray's terminating NUL (0) byte. * * This allows for fast calculation of the bit array size: * inline int size() const { return (d.size() << 3) - *d.constData(); } - * - * Note: for an array of zero size, *d.constData() is the QByteArray implicit NUL. */ /*! @@ -154,8 +154,8 @@ QBitArray::QBitArray(int size, bool value) uchar* c = reinterpret_cast<uchar*>(d.data()); memset(c + 1, value ? 0xff : 0, d.size() - 1); *c = d.size()*8 - size; - if (value && size && size % 8) - *(c+1+size/8) &= (1 << (size%8)) - 1; + if (value && size && size & 7) + *(c+1+size/8) &= (1 << (size & 7)) - 1; } /*! \fn int QBitArray::size() const @@ -227,8 +227,8 @@ void QBitArray::resize(int size) uchar* c = reinterpret_cast<uchar*>(d.data()); if (size > (s << 3)) memset(c + s, 0, d.size() - s); - else if ( size % 8) - *(c+1+size/8) &= (1 << (size%8)) - 1; + else if (size & 7) + *(c+1+size/8) &= (1 << (size & 7)) - 1; *c = d.size()*8 - size; } } @@ -326,6 +326,8 @@ void QBitArray::fill(bool value, int begin, int end) QBitArray QBitArray::fromBits(const char *data, qsizetype size) { QBitArray result; + if (size == 0) + return result; qsizetype nbytes = (size + 7) / 8; result.d = QByteArray(nbytes + 1, Qt::Uninitialized); @@ -334,7 +336,7 @@ QBitArray QBitArray::fromBits(const char *data, qsizetype size) // clear any unused bits from the last byte if (size & 7) - bits[nbytes] &= 0xffU >> (size & 7); + bits[nbytes] &= 0xffU >> (8 - (size & 7)); *bits = result.d.size() * 8 - size; return result; diff --git a/src/corelib/tools/qcryptographichash.cpp b/src/corelib/tools/qcryptographichash.cpp index ee7657789c..fa8d21e07a 100644 --- a/src/corelib/tools/qcryptographichash.cpp +++ b/src/corelib/tools/qcryptographichash.cpp @@ -391,19 +391,19 @@ void QCryptographicHash::addData(const char *data, int length) break; case RealSha3_224: case Keccak_224: - sha3Update(&d->sha3Context, reinterpret_cast<const BitSequence *>(data), length*8); + sha3Update(&d->sha3Context, reinterpret_cast<const BitSequence *>(data), quint64(length) * 8); break; case RealSha3_256: case Keccak_256: - sha3Update(&d->sha3Context, reinterpret_cast<const BitSequence *>(data), length*8); + sha3Update(&d->sha3Context, reinterpret_cast<const BitSequence *>(data), quint64(length) * 8); break; case RealSha3_384: case Keccak_384: - sha3Update(&d->sha3Context, reinterpret_cast<const BitSequence *>(data), length*8); + sha3Update(&d->sha3Context, reinterpret_cast<const BitSequence *>(data), quint64(length) * 8); break; case RealSha3_512: case Keccak_512: - sha3Update(&d->sha3Context, reinterpret_cast<const BitSequence *>(data), length*8); + sha3Update(&d->sha3Context, reinterpret_cast<const BitSequence *>(data), quint64(length) * 8); break; #endif } diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h index 471e16886f..be987c359b 100644 --- a/src/corelib/tools/qlist.h +++ b/src/corelib/tools/qlist.h @@ -112,7 +112,7 @@ struct Q_CORE_EXPORT QListData { void remove(int i); void remove(int i, int n); void move(int from, int to); - inline int size() const noexcept { return d->end - d->begin; } + inline int size() const noexcept { return int(d->end - d->begin); } // q6sizetype inline bool isEmpty() const noexcept { return d->end == d->begin; } inline void **at(int i) const noexcept { return d->array + d->begin + i; } inline void **begin() const noexcept { return d->array + d->begin; } @@ -1051,7 +1051,7 @@ int lastIndexOf(const QList<T> &list, const U &u, int from) Node *n = reinterpret_cast<Node *>(list.p.at(from + 1)); while (n-- != b) { if (n->t() == u) - return n - b; + return typename QList<T>::difference_type(n - b); } } return -1; |