diff options
author | Liang Qi <liang.qi@qt.io> | 2016-04-29 16:09:54 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2016-04-29 17:55:20 +0200 |
commit | b894a8def5d9107663e4968d2d395f5ef3059125 (patch) | |
tree | f894c50c9e5cbdd7ec102291eb94979977ce5b37 /src/corelib | |
parent | d2304a28ca657634253af26ad803c7f292e6f4cc (diff) | |
parent | 002112e80516a29efbb6cef721d74c5fc39fc19d (diff) |
Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts:
mkspecs/features/qml_module.prf
mkspecs/features/qt_common.prf
src/gui/text/qzip.cpp
src/plugins/platforms/cocoa/qnsview.mm
src/plugins/platforms/windows/array.h
src/testlib/qtestcase.cpp
src/widgets/dialogs/qfilesystemmodel.h
Change-Id: Ie41c5868415b81f7693c80e045497035504bb210
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/global/qcompilerdetection.h | 17 | ||||
-rw-r--r-- | src/corelib/itemmodels/qidentityproxymodel.h | 1 | ||||
-rw-r--r-- | src/corelib/kernel/qcoreapplication.cpp | 2 | ||||
-rw-r--r-- | src/corelib/kernel/qmetatype.h | 2 | ||||
-rw-r--r-- | src/corelib/kernel/qobject.cpp | 6 | ||||
-rw-r--r-- | src/corelib/tools/qarraydata.cpp | 13 | ||||
-rw-r--r-- | src/corelib/tools/qlist.h | 2 | ||||
-rw-r--r-- | src/corelib/tools/qstring.cpp | 14 | ||||
-rw-r--r-- | src/corelib/tools/qvarlengtharray.h | 7 | ||||
-rw-r--r-- | src/corelib/tools/qvector.h | 2 |
10 files changed, 48 insertions, 18 deletions
diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index 86d027eb35..a08fde8bb0 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -105,6 +105,12 @@ # endif # define Q_DECL_EXPORT __declspec(dllexport) # define Q_DECL_IMPORT __declspec(dllimport) +# if _MSC_VER >= 1800 +# define QT_MAKE_UNCHECKED_ARRAY_ITERATOR(x) stdext::make_unchecked_array_iterator(x) +# endif +# if _MSC_VER >= 1500 +# define QT_MAKE_CHECKED_ARRAY_ITERATOR(x, N) stdext::make_checked_array_iterator(x, size_t(N)) +# endif /* Intel C++ disguising as Visual C++: the `using' keyword avoids warnings */ # if defined(__INTEL_COMPILER) # define Q_DECL_VARIABLE_DEPRECATED @@ -1106,6 +1112,11 @@ # define Q_ALIGNOF(x) alignof(x) #endif +#if defined(Q_COMPILER_ALIGNAS) +# undef Q_DECL_ALIGN +# define Q_DECL_ALIGN(n) alignas(n) +#endif + /* * Fallback macros to certain compiler features */ @@ -1174,6 +1185,12 @@ #ifndef Q_DECL_CONST_FUNCTION # define Q_DECL_CONST_FUNCTION Q_DECL_PURE_FUNCTION #endif +#ifndef QT_MAKE_UNCHECKED_ARRAY_ITERATOR +# define QT_MAKE_UNCHECKED_ARRAY_ITERATOR(x) (x) +#endif +#ifndef QT_MAKE_CHECKED_ARRAY_ITERATOR +# define QT_MAKE_CHECKED_ARRAY_ITERATOR(x, N) (x) +#endif /* * SG10's SD-6 feature detection and some useful extensions from Clang and GCC diff --git a/src/corelib/itemmodels/qidentityproxymodel.h b/src/corelib/itemmodels/qidentityproxymodel.h index 7a75f42d81..e93740c1a2 100644 --- a/src/corelib/itemmodels/qidentityproxymodel.h +++ b/src/corelib/itemmodels/qidentityproxymodel.h @@ -62,6 +62,7 @@ public: QModelIndex mapFromSource(const QModelIndex& sourceIndex) const Q_DECL_OVERRIDE; QModelIndex mapToSource(const QModelIndex& proxyIndex) const Q_DECL_OVERRIDE; QModelIndex parent(const QModelIndex& child) const Q_DECL_OVERRIDE; + using QObject::parent; int rowCount(const QModelIndex& parent = QModelIndex()) const Q_DECL_OVERRIDE; QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE; bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent) Q_DECL_OVERRIDE; diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 0c1c37c89d..7bb2e7a78c 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -419,7 +419,7 @@ QCoreApplicationPrivate::QCoreApplicationPrivate(int &aargc, char **aargv, uint if (!isArgvModified(argc, argv)) { origArgc = argc; origArgv = new char *[argc]; - std::copy(argv, argv + argc, origArgv); + std::copy(argv, argv + argc, QT_MAKE_CHECKED_ARRAY_ITERATOR(origArgv, argc)); } #endif // Q_OS_WIN && !Q_OS_WINRT diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index ebe118dce4..b68dbacbd3 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -1189,6 +1189,7 @@ public: public: template<class T> QAssociativeIterableImpl(const T*p) : _iterable(p) + , _iterator(Q_NULLPTR) , _metaType_id_key(qMetaTypeId<typename T::key_type>()) , _metaType_flags_key(QTypeInfo<typename T::key_type>::isPointer) , _metaType_id_value(qMetaTypeId<typename T::mapped_type>()) @@ -1208,6 +1209,7 @@ public: QAssociativeIterableImpl() : _iterable(Q_NULLPTR) + , _iterator(Q_NULLPTR) , _metaType_id_key(QMetaType::UnknownType) , _metaType_flags_key(0) , _metaType_id_value(QMetaType::UnknownType) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index fc5e6abf00..2b0eff3708 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -2151,8 +2151,8 @@ void QObject::deleteLater() Returns a translated version of \a sourceText, optionally based on a \a disambiguation string and value of \a n for strings containing plurals; - otherwise returns \a sourceText itself if no appropriate translated string - is available. + otherwise returns QString::fromUtf8(\a sourceText) if no appropriate + translated string is available. Example: \snippet ../widgets/mainwindows/sdi/mainwindow.cpp implicit tr context @@ -2178,7 +2178,7 @@ void QObject::deleteLater() translators while performing translations is not supported. Doing so will probably result in crashes or other undesirable behavior. - \sa trUtf8(), QCoreApplication::translate(), {Internationalization with Qt} + \sa QCoreApplication::translate(), {Internationalization with Qt} */ /*! diff --git a/src/corelib/tools/qarraydata.cpp b/src/corelib/tools/qarraydata.cpp index 21ad799e25..bf336a8f31 100644 --- a/src/corelib/tools/qarraydata.cpp +++ b/src/corelib/tools/qarraydata.cpp @@ -38,6 +38,7 @@ ****************************************************************************/ #include <QtCore/qarraydata.h> +#include <QtCore/private/qnumeric_p.h> #include <QtCore/private/qtools_p.h> #include <stdlib.h> @@ -93,16 +94,22 @@ QArrayData *QArrayData::allocate(size_t objectSize, size_t alignment, if (capacity > std::numeric_limits<size_t>::max() / objectSize) return 0; - size_t alloc = objectSize * capacity; + size_t alloc; + if (mul_overflow(objectSize, capacity, &alloc)) + return 0; - // Make sure qAllocMore won't overflow. + // Make sure qAllocMore won't overflow qAllocMore. if (headerSize > size_t(MaxAllocSize) || alloc > size_t(MaxAllocSize) - headerSize) return 0; capacity = qAllocMore(int(alloc), int(headerSize)) / int(objectSize); } - size_t allocSize = headerSize + objectSize * capacity; + size_t allocSize; + if (mul_overflow(objectSize, capacity, &allocSize)) + return 0; + if (add_overflow(allocSize, headerSize, &allocSize)) + return 0; QArrayData *header = static_cast<QArrayData *>(::malloc(allocSize)); if (header) { diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h index 5509c3adce..ec279769eb 100644 --- a/src/corelib/tools/qlist.h +++ b/src/corelib/tools/qlist.h @@ -852,7 +852,7 @@ inline bool QList<T>::op_eq_impl(const QList &l, QListData::ArrayCompatibleLayou const T *lb = reinterpret_cast<const T*>(l.p.begin()); const T *b = reinterpret_cast<const T*>(p.begin()); const T *e = reinterpret_cast<const T*>(p.end()); - return std::equal(b, e, lb); + return std::equal(b, e, QT_MAKE_CHECKED_ARRAY_ITERATOR(lb, l.p.size())); } template <typename T> diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index c3aae2fd22..9f968978dc 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -712,8 +712,8 @@ static int findChar(const QChar *str, int len, QChar ch, int from, } #define REHASH(a) \ - if (sl_minus_1 < (int)sizeof(int) * CHAR_BIT) \ - hashHaystack -= (a) << sl_minus_1; \ + if (sl_minus_1 < sizeof(uint) * CHAR_BIT) \ + hashHaystack -= uint(a) << sl_minus_1; \ hashHaystack <<= 1 inline bool qIsUpper(char ch) @@ -3096,8 +3096,9 @@ int qFindString( const ushort *needle = (const ushort *)needle0; const ushort *haystack = (const ushort *)haystack0 + from; const ushort *end = (const ushort *)haystack0 + (l-sl); - const int sl_minus_1 = sl-1; - int hashNeedle = 0, hashHaystack = 0, idx; + const uint sl_minus_1 = sl - 1; + uint hashNeedle = 0, hashHaystack = 0; + int idx; if (cs == Qt::CaseSensitive) { for (idx = 0; idx < sl; ++idx) { @@ -3172,10 +3173,11 @@ static int lastIndexOfHelper(const ushort *haystack, int from, const ushort *nee const ushort *end = haystack; haystack += from; - const int sl_minus_1 = sl-1; + const uint sl_minus_1 = sl - 1; const ushort *n = needle+sl_minus_1; const ushort *h = haystack+sl_minus_1; - int hashNeedle = 0, hashHaystack = 0, idx; + uint hashNeedle = 0, hashHaystack = 0; + int idx; if (cs == Qt::CaseSensitive) { for (idx = 0; idx < sl; ++idx) { diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h index 24574dc90b..c3ac104399 100644 --- a/src/corelib/tools/qvarlengtharray.h +++ b/src/corelib/tools/qvarlengtharray.h @@ -102,7 +102,8 @@ public: QVarLengthArray<T, Prealloc> &operator=(std::initializer_list<T> list) { resize(list.size()); - std::copy(list.begin(), list.end(), this->begin()); + std::copy(list.begin(), list.end(), + QT_MAKE_CHECKED_ARRAY_ITERATOR(this->begin(), this->size())); return *this; } #endif @@ -473,7 +474,7 @@ Q_OUTOFLINE_TEMPLATE typename QVarLengthArray<T, Prealloc>::iterator QVarLengthA int l = int(aend - ptr); int n = l - f; if (QTypeInfo<T>::isComplex) { - std::copy(ptr + l, ptr + s, ptr + f); + std::copy(ptr + l, ptr + s, QT_MAKE_CHECKED_ARRAY_ITERATOR(ptr + f, s - f)); T *i = ptr + s; T *b = ptr + s - n; while (i != b) { @@ -495,7 +496,7 @@ bool operator==(const QVarLengthArray<T, Prealloc1> &l, const QVarLengthArray<T, const T *rb = r.begin(); const T *b = l.begin(); const T *e = l.end(); - return std::equal(b, e, rb); + return std::equal(b, e, QT_MAKE_CHECKED_ARRAY_ITERATOR(rb, r.size())); } template <typename T, int Prealloc1, int Prealloc2> diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index 806a127cc2..557bec9676 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -773,7 +773,7 @@ bool QVector<T>::operator==(const QVector<T> &v) const const T *vb = v.d->begin(); const T *b = d->begin(); const T *e = d->end(); - return std::equal(b, e, vb); + return std::equal(b, e, QT_MAKE_CHECKED_ARRAY_ITERATOR(vb, v.d->size)); } template <typename T> |