From bdd67963ecc484e0ac125574fa40b588946ab64c Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Sun, 30 Jul 2023 20:59:14 +0000 Subject: [PATCH] drop QVarLengthArray and replace it with QStdVector internally Signed-off-by: Ivailo Monev --- package/freebsd/pkg-plist | 2 - scripts/namefsck.py | 1 - src/core/CMakeLists.txt | 2 - src/core/codecs/qtextcodec.cpp | 10 +- src/core/io/qdir.cpp | 4 +- src/core/kernel/qcoreapplication.cpp | 5 +- src/core/kernel/qeventdispatcher_unix_p.h | 4 +- src/core/kernel/qmetaobject.cpp | 18 +- src/core/kernel/qobject.cpp | 4 +- src/core/kernel/qobject_p.h | 22 +- src/core/tools/qcontainerfwd.h | 1 - src/core/tools/qlocale_p.h | 10 +- src/core/tools/qstring.cpp | 28 +- src/core/tools/qvarlengtharray.h | 381 ------------- src/core/tools/qvarlengtharray.qdoc | 540 ------------------- src/core/tools/qvector.cpp | 8 +- src/dbus/qdbusintegrator.cpp | 6 +- src/dbus/qdbusmetaobject.cpp | 17 +- src/declarative/qml/parser/qdeclarativejs.g | 6 +- .../qml/parser/qdeclarativejsparser.cpp | 6 +- src/declarative/qml/qdeclarativeboundsignal.cpp | 2 +- src/declarative/qml/qdeclarativenotifier_p.h | 2 +- .../qml/qdeclarativeobjectscriptclass.cpp | 14 +- src/declarative/qml/qdeclarativeproperty.cpp | 2 +- src/declarative/qml/qdeclarativevme.cpp | 28 +- src/gui/dialogs/qwizard.cpp | 6 +- src/gui/graphicsview/qgridlayoutengine.cpp | 8 +- src/gui/image/qimage.cpp | 4 +- src/gui/kernel/qgridlayout.cpp | 3 +- src/gui/painting/qbackingstore.cpp | 4 +- src/gui/painting/qpaintengine_raster.cpp | 2 +- src/gui/painting/qpaintengineex.cpp | 1 - src/gui/painting/qpainter.cpp | 4 +- src/gui/painting/qpainterpath.cpp | 1 - src/gui/painting/qpainterpath_p.h | 11 +- src/gui/painting/qpdf.cpp | 4 +- src/gui/painting/qregion.cpp | 4 +- src/gui/text/qfontengine.cpp | 11 +- src/gui/text/qfontengine_p.h | 6 +- src/gui/text/qtextdocument.cpp | 5 +- src/gui/text/qtextdocumentlayout.cpp | 8 +- src/gui/text/qtextengine.cpp | 5 +- src/gui/text/qtextlayout.cpp | 1 - src/gui/text/qtexttable.cpp | 4 +- src/gui/widgets/qsplitter.cpp | 6 +- src/imports/particles/qdeclarativeparticles.cpp | 1 - src/script/api/qscriptvalue.cpp | 12 +- src/script/bridge/qscriptqobject.cpp | 24 +- src/svg/qsvghandler.cpp | 8 +- src/test/qtestcase.cpp | 4 +- src/tools/qdbus/qdbuscpp2xml.cpp | 6 +- src/tools/uic/cpp/cppwriteincludes.cpp | 1 - tests/auto/qdbusthreading/tst_qdbusthreading.cpp | 5 +- tests/auto/qvarlengtharray/CMakeLists.txt | 3 - tests/auto/qvarlengtharray/tst_qvarlengtharray.cpp | 591 --------------------- tests/benchmarks/core/io/qdir/tree/4.6.0-list.txt | 2 - .../graphicsview/qgraphicsview/chiptester/chip.cpp | 4 +- 57 files changed, 168 insertions(+), 1714 deletions(-) delete mode 100644 src/core/tools/qvarlengtharray.h delete mode 100644 src/core/tools/qvarlengtharray.qdoc delete mode 100644 tests/auto/qvarlengtharray/CMakeLists.txt delete mode 100644 tests/auto/qvarlengtharray/tst_qvarlengtharray.cpp diff --git a/package/freebsd/pkg-plist b/package/freebsd/pkg-plist index 537e5705a..76963a51a 100644 --- a/package/freebsd/pkg-plist +++ b/package/freebsd/pkg-plist @@ -148,7 +148,6 @@ include/katie/QtCore/QTimerEvent include/katie/QtCore/QTranslator include/katie/QtCore/QTypeInfo include/katie/QtCore/QUrl -include/katie/QtCore/QVarLengthArray include/katie/QtCore/QVariant include/katie/QtCore/QVariantHash include/katie/QtCore/QVariantList @@ -258,7 +257,6 @@ include/katie/QtCore/qtimer.h include/katie/QtCore/qtranslator.h include/katie/QtCore/qurl.h include/katie/QtCore/qvariant.h -include/katie/QtCore/qvarlengtharray.h include/katie/QtCore/qvector.h include/katie/QtCore/qwaitcondition.h include/katie/QtDBus/QDBusAbstractAdaptor diff --git a/scripts/namefsck.py b/scripts/namefsck.py index 76979f0f7..b18919b9b 100755 --- a/scripts/namefsck.py +++ b/scripts/namefsck.py @@ -585,7 +585,6 @@ classlist = [ "QUrl", "QVBoxLayout", "QValidator", - "QVarLengthArray", "QVariant", "QVariantAnimation", "QVariantHash", diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index a06e35e2d..201a5e484 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -9,7 +9,6 @@ set(EXTRA_CORE_LIBS ) set(CORE_PUBLIC_HEADERS - QVarLengthArray QList QProcess QBuffer @@ -214,7 +213,6 @@ set(CORE_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/tools/qtextboundaryfinder.h ${CMAKE_CURRENT_SOURCE_DIR}/tools/qtimeline.h ${CMAKE_CURRENT_SOURCE_DIR}/tools/qelapsedtimer.h - ${CMAKE_CURRENT_SOURCE_DIR}/tools/qvarlengtharray.h ${CMAKE_CURRENT_SOURCE_DIR}/tools/qvector.h ${CMAKE_CURRENT_SOURCE_DIR}/tools/qiterator.h ${CMAKE_CURRENT_SOURCE_DIR}/tools/qpair.h diff --git a/src/core/codecs/qtextcodec.cpp b/src/core/codecs/qtextcodec.cpp index f181e9300..0865e72d7 100644 --- a/src/core/codecs/qtextcodec.cpp +++ b/src/core/codecs/qtextcodec.cpp @@ -24,13 +24,13 @@ #include "qlist.h" #include "qfile.h" -#include "qvarlengtharray.h" #include "qstringlist.h" #include "qlocale.h" #include "qlocale_tools_p.h" #include "qtextcodec_p.h" #include "qmutex.h" #include "qhash.h" +#include "qstdcontainers_p.h" #include "qcorecommon_p.h" #include "qdebug.h" @@ -1091,7 +1091,7 @@ QString QTextCodecPrivate::convertTo(const char *data, int length, const char* c ucnv_setSubstString(conv, questionmarkchar, 1, &error); const int maxbytes = UCNV_GET_MAX_BYTES_FOR_STRING(length, ucnv_getMaxCharSize(conv)); - QVarLengthArray result(maxbytes); + QStdVector result(maxbytes); error = U_ZERO_ERROR; const int convresult = ucnv_toUChars(conv, result.data(), maxbytes, data, length, &error); ucnv_close(conv); @@ -1115,7 +1115,7 @@ QByteArray QTextCodecPrivate::convertFrom(const QChar *unicode, int length, cons ucnv_setSubstString(conv, questionmarkchar, 1, &error); const int maxbytes = UCNV_GET_MAX_BYTES_FOR_STRING(length, ucnv_getMaxCharSize(conv)); - QVarLengthArray result(maxbytes); + QStdVector result(maxbytes); error = U_ZERO_ERROR; const int convresult = ucnv_fromUChars(conv, result.data(), maxbytes, reinterpret_cast(unicode), length, &error); @@ -1954,7 +1954,7 @@ QByteArray QTextConverter::fromUnicode(const QChar *data, int length) const } const int maxbytes = UCNV_GET_MAX_BYTES_FOR_STRING(length, ucnv_getMaxCharSize(conv)); - QVarLengthArray result(maxbytes); + QStdVector result(maxbytes); UErrorCode error = U_ZERO_ERROR; const int convresult = ucnv_fromUChars(conv, result.data(), maxbytes, reinterpret_cast(data), length, &error); @@ -1974,7 +1974,7 @@ QString QTextConverter::toUnicode(const char *data, int length) const } const int maxbytes = UCNV_GET_MAX_BYTES_FOR_STRING(length, ucnv_getMaxCharSize(conv)); - QVarLengthArray result(maxbytes); + QStdVector result(maxbytes); UErrorCode error = U_ZERO_ERROR; const int convresult = ucnv_toUChars(conv, result.data(), maxbytes, data, length, &error); // regardless if the data has BOM or not, BOMs shall be generated explicitly only by QTextStream diff --git a/src/core/io/qdir.cpp b/src/core/io/qdir.cpp index c221c6d8b..f02b77f8c 100644 --- a/src/core/io/qdir.cpp +++ b/src/core/io/qdir.cpp @@ -34,8 +34,8 @@ #include "qfilesystementry_p.h" #include "qfilesystemmetadata_p.h" #include "qfilesystemengine_p.h" -#include "qvarlengtharray.h" #include "qscopedpointer.h" +#include "qstdcontainers_p.h" #include "qcorecommon_p.h" #include @@ -212,7 +212,7 @@ inline void QDirPrivate::sortFileList(QDir::SortFlags sort, QFileInfoList &l, names->append(l.at(i).fileName()); } } else { - QVarLengthArray si(n); + QStdVector si(n); for (int i = 0; i < n; ++i) si[i].item = l.at(i); qSort(si.data(), si.data() + n, QDirSortItemComparator(sort)); diff --git a/src/core/kernel/qcoreapplication.cpp b/src/core/kernel/qcoreapplication.cpp index 8a2e98a62..e12c69b58 100644 --- a/src/core/kernel/qcoreapplication.cpp +++ b/src/core/kernel/qcoreapplication.cpp @@ -36,7 +36,6 @@ #include "qthreadpool.h" #include "qstandardpaths.h" #include "qelapsedtimer.h" -#include "qvarlengtharray.h" #include "qscopedpointer.h" #include "qlibraryinfo.h" #include "qthread_p.h" @@ -44,8 +43,8 @@ #include "qfactoryloader_p.h" #include "qlocale_p.h" #include "qeventdispatcher_unix_p.h" -#include "qcorecommon_p.h" #include "qstdcontainers_p.h" +#include "qcorecommon_p.h" #include #include @@ -1061,7 +1060,7 @@ void QCoreApplication::removePostedEvents(QObject *receiver, int eventType) //we will collect all the posted events for the QObject //and we'll delete after the mutex was unlocked - QVarLengthArray events; + QStdVector events; int n = data->postEventList.size(); int j = 0; diff --git a/src/core/kernel/qeventdispatcher_unix_p.h b/src/core/kernel/qeventdispatcher_unix_p.h index 1971e5daa..52b0436d6 100644 --- a/src/core/kernel/qeventdispatcher_unix_p.h +++ b/src/core/kernel/qeventdispatcher_unix_p.h @@ -36,7 +36,7 @@ #include "QtCore/qabstracteventdispatcher.h" #include "qabstracteventdispatcher_p.h" #include "qcore_unix_p.h" -#include "qvarlengtharray.h" +#include "qstdcontainers_p.h" #include #include @@ -98,7 +98,7 @@ public: QSockNotType(); ~QSockNotType(); - typedef QVarLengthArray List; + typedef QStdVector List; List list; fd_set select_fds; diff --git a/src/core/kernel/qmetaobject.cpp b/src/core/kernel/qmetaobject.cpp index 19bbd399b..67565dd70 100644 --- a/src/core/kernel/qmetaobject.cpp +++ b/src/core/kernel/qmetaobject.cpp @@ -22,19 +22,17 @@ #include "qmetaobject.h" #include "qmetatype.h" #include "qobject.h" - #include "qcoreapplication.h" #include "qcoreevent.h" #include "qdatastream.h" #include "qthread.h" -#include "qvarlengtharray.h" #include "qvariant.h" #include "qhash.h" #include "qdebug.h" #include "qsemaphore.h" - #include "qobject_p.h" #include "qmetaobject_p.h" +#include "qstdcontainers_p.h" #include @@ -153,7 +151,8 @@ QObject *QMetaObject::newInstance(QGenericArgument val0, if (idx != -1) constructorName.remove(0, idx+1); // remove qualified part } - QVarLengthArray sig; + QByteArray sig; + sig.reserve(constructorName.length() + 1); sig.append(constructorName.constData(), constructorName.length()); sig.append('('); @@ -1049,13 +1048,16 @@ bool QMetaObject::invokeMethod(QObject *obj, int len = qstrlen(member); if (len <= 0) return false; - QVarLengthArray sig; + QByteArray sig; + sig.reserve(len + 1); sig.append(member, len); sig.append('('); - const char *typeNames[] = {ret.name(), val0.name(), val1.name(), val2.name(), val3.name(), - val4.name(), val5.name(), val6.name(), val7.name(), val8.name(), - val9.name()}; + const char *typeNames[] = { + ret.name(), val0.name(), val1.name(), val2.name(), val3.name(), + val4.name(), val5.name(), val6.name(), val7.name(), val8.name(), + val9.name() + }; int paramCount; for (paramCount = 1; paramCount < MaximumParamCount; ++paramCount) { diff --git a/src/core/kernel/qobject.cpp b/src/core/kernel/qobject.cpp index 5daf71d48..f1b401600 100644 --- a/src/core/kernel/qobject.cpp +++ b/src/core/kernel/qobject.cpp @@ -2067,7 +2067,7 @@ bool QObject::connect(const QObject *sender, const QMetaMethod &signal, return false; } - QVarLengthArray signalSignature; + QStdVector signalSignature; QObjectPrivate::signalSignature(signal, &signalSignature); int signal_index; @@ -2319,7 +2319,7 @@ bool QObject::disconnect(const QObject *sender, const QMetaMethod &signal, } } - QVarLengthArray signalSignature; + QStdVector signalSignature; if (signal.mobj) QObjectPrivate::signalSignature(signal, &signalSignature); diff --git a/src/core/kernel/qobject_p.h b/src/core/kernel/qobject_p.h index 4af56ce38..90ac4feb8 100644 --- a/src/core/kernel/qobject_p.h +++ b/src/core/kernel/qobject_p.h @@ -33,11 +33,11 @@ // We mean it. // -#include "QtCore/qpointer.h" -#include "QtCore/qsharedpointer.h" -#include "QtCore/qcoreevent.h" -#include "QtCore/qmetaobject.h" -#include "QtCore/qvarlengtharray.h" +#include "qpointer.h" +#include "qsharedpointer.h" +#include "qcoreevent.h" +#include "qmetaobject.h" +#include "qstdcontainers_p.h" QT_BEGIN_NAMESPACE @@ -141,7 +141,7 @@ public: inline void disconnectNotify(const char *signal); static inline void signalSignature(const QMetaMethod &signal, - QVarLengthArray *result); + QStdVector *result); public: QString objectName; @@ -192,17 +192,21 @@ inline void QObjectPrivate::disconnectNotify(const char *signal) } inline void QObjectPrivate::signalSignature(const QMetaMethod &signal, - QVarLengthArray *result) + QStdVector *result) { Q_ASSERT(result); - const int signatureLength = qstrlen(signal.signature()); + const char* signatureData = signal.signature(); + const int signatureLength = qstrlen(signatureData); if (signatureLength == 0) { result->append((char)0); return; } result->reserve(signatureLength + 2); result->append((char)(QSIGNAL_CODE + '0')); - result->append(signal.signature(), signatureLength + 1); + for (int i = 0; i < signatureLength; i++) { + result->append(signatureData[i]); + } + result->append('\0'); } inline QObjectPrivate::Sender *QObjectPrivate::setCurrentSender(QObject *receiver, diff --git a/src/core/tools/qcontainerfwd.h b/src/core/tools/qcontainerfwd.h index a2abe38b9..611849034 100644 --- a/src/core/tools/qcontainerfwd.h +++ b/src/core/tools/qcontainerfwd.h @@ -37,7 +37,6 @@ template struct QPair; template class QQueue; template class QSet; template class QStack; -template class QVarLengthArray; template class QVector; QT_END_NAMESPACE diff --git a/src/core/tools/qlocale_p.h b/src/core/tools/qlocale_p.h index 5165c1d0c..e6c0d9f30 100644 --- a/src/core/tools/qlocale_p.h +++ b/src/core/tools/qlocale_p.h @@ -33,12 +33,10 @@ // We mean it. // -#include "QtCore/qstring.h" -#include "QtCore/qvarlengtharray.h" -#include "QtCore/qmetatype.h" - +#include "qstring.h" +#include "qmetatype.h" #include "qlocale.h" - +#include "qstdcontainers_p.h" QT_BEGIN_NAMESPACE @@ -131,7 +129,7 @@ public: static qint64 bytearrayToLongLong(const char *num, int base, bool *ok); static quint64 bytearrayToUnsLongLong(const char *num, int base, bool *ok); - typedef QVarLengthArray CharBuff; + typedef QStdVector CharBuff; bool numberToCLocale(const QString &num, GroupSeparatorMode group_sep_mode, CharBuff *result) const; diff --git a/src/core/tools/qstring.cpp b/src/core/tools/qstring.cpp index a998de3fe..dbd91d120 100644 --- a/src/core/tools/qstring.cpp +++ b/src/core/tools/qstring.cpp @@ -28,12 +28,12 @@ #include "qlocale_p.h" #include "qlocale_tools_p.h" #include "qstringmatcher.h" -#include "qvarlengtharray.h" #include "qhash.h" #include "qdebug.h" #include "qendian.h" #include "qmutex.h" #include "qbitarray.h" +#include "qstdcontainers_p.h" #include "qcorecommon_p.h" #ifndef QT_NO_TEXTCODEC @@ -1666,11 +1666,11 @@ QString &QString::replace(const QLatin1String &before, Qt::CaseSensitivity cs) { int alen = qstrlen(after.latin1()); - QVarLengthArray a(alen); + QStdVector a(alen); for (int i = 0; i < alen; ++i) a[i] = (uchar)after.latin1()[i]; int blen = qstrlen(before.latin1()); - QVarLengthArray b(blen); + QStdVector b(blen); for (int i = 0; i < blen; ++i) b[i] = (uchar)before.latin1()[i]; return replace(reinterpret_cast(b.constData()), blen, reinterpret_cast(a.constData()), alen, cs); @@ -1693,7 +1693,7 @@ QString &QString::replace(const QLatin1String &before, Qt::CaseSensitivity cs) { int blen = qstrlen(before.latin1()); - QVarLengthArray b(blen); + QStdVector b(blen); for (int i = 0; i < blen; ++i) b[i] = (uchar)before.latin1()[i]; return replace((const QChar *)b.data(), blen, after.constData(), after.d->size, cs); @@ -1716,7 +1716,7 @@ QString &QString::replace(const QString &before, Qt::CaseSensitivity cs) { int alen = qstrlen(after.latin1()); - QVarLengthArray a(alen); + QStdVector a(alen); for (int i = 0; i < alen; ++i) a[i] = (uchar)after.latin1()[i]; return replace(before.constData(), before.d->size, (const QChar *)a.data(), alen, cs); @@ -1737,7 +1737,7 @@ QString &QString::replace(const QString &before, QString &QString::replace(QChar c, const QLatin1String &after, Qt::CaseSensitivity cs) { int alen = qstrlen(after.latin1()); - QVarLengthArray a(alen); + QStdVector a(alen); for (int i = 0; i < alen; ++i) a[i] = (uchar)after.latin1()[i]; return replace(&c, 1, (const QChar *)a.data(), alen, cs); @@ -2324,7 +2324,7 @@ int QString::lastIndexOf(const QLatin1String &str, int from, Qt::CaseSensitivity if (from > delta) from = delta; - QVarLengthArray s(sl); + QStdVector s(sl); for (int i = 0; i < sl; ++i) s[i] = str.latin1()[i]; @@ -3144,7 +3144,7 @@ static QByteArray toLatin1_helper(const QChar *data, int length) if (!length) { return QByteArray(); } - QVarLengthArray result(length); + QStdVector result(length); for (int i = 0; i < length; i++) { const ushort ucs = data[i].unicode(); result[i] = (ucs > 0xff) ? '?' : char(ucs); @@ -3501,7 +3501,7 @@ QString QString::simplified() const if (d->size == 0) return *this; - QVarLengthArray result(d->size); + QStdVector result(d->size); const QChar *from = reinterpret_cast(d->data); const QChar *fromend = from + d->size; int outc = 0; @@ -4295,7 +4295,7 @@ QString QString::toLower() const UErrorCode error = U_ZERO_ERROR; const int maxchars = d->size + 1; // ICU will write zero-terminator - QVarLengthArray result(maxchars); + QStdVector result(maxchars); const int lowerresult = u_strToLower(result.data(), maxchars, reinterpret_cast(d->data), d->size, "C", &error); if (Q_UNLIKELY(lowerresult > maxchars || U_FAILURE(error))) { @@ -4315,7 +4315,7 @@ QString QString::toCaseFolded() const } UErrorCode error = U_ZERO_ERROR; const int maxchars = d->size + 1; // ICU will write zero-terminator - QVarLengthArray result(maxchars); + QStdVector result(maxchars); const int foldresult = u_strFoldCase(result.data(), maxchars, reinterpret_cast(d->data), d->size, U_FOLD_CASE_DEFAULT, &error); if (Q_UNLIKELY(foldresult > maxchars || U_FAILURE(error))) { @@ -4342,7 +4342,7 @@ QString QString::toUpper() const } UErrorCode error = U_ZERO_ERROR; const int maxchars = d->size + 1; // ICU will write zero-terminator - QVarLengthArray result(maxchars); + QStdVector result(maxchars); const int upperresult = u_strToUpper(result.data(), maxchars, reinterpret_cast(d->data), d->size, "C", &error); if (Q_UNLIKELY(upperresult > maxchars || U_FAILURE(error))) { @@ -7653,7 +7653,7 @@ int QStringRef::lastIndexOf(QLatin1String str, int from, Qt::CaseSensitivity cs) if (from > delta) from = delta; - QVarLengthArray s(sl); + QStdVector s(sl); for (int i = 0; i < sl; ++i) s[i] = str.latin1()[i]; @@ -7987,7 +7987,7 @@ static inline int qt_find_latin1_string(const QChar *haystack, int size, { const char *latin1 = needle.latin1(); int len = qstrlen(latin1); - QVarLengthArray s(len); + QStdVector s(len); for (int i = 0; i < len; ++i) s[i] = latin1[i]; diff --git a/src/core/tools/qvarlengtharray.h b/src/core/tools/qvarlengtharray.h deleted file mode 100644 index f65b1d91e..000000000 --- a/src/core/tools/qvarlengtharray.h +++ /dev/null @@ -1,381 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Copyright (C) 2016 Ivailo Monev -** -** This file is part of the QtCore module of the Katie Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QVARLENGTHARRAY_H -#define QVARLENGTHARRAY_H - -#include - -#include -#include -#include - -QT_BEGIN_NAMESPACE - -template -class Q_CORE_EXPORT QVarLengthArray -{ -public: - inline explicit QVarLengthArray(int size = 0); - - inline QVarLengthArray(const QVarLengthArray &other) - : a(0), s(0), ptr(nullptr) - { - append(other.constData(), other.size()); - } - - inline ~QVarLengthArray() { - if (QTypeInfo::isComplex) { - T *i = ptr + s; - while (i-- != ptr) { - i->~T(); - } - } - if (ptr) { - ::free(ptr); - } - } - inline QVarLengthArray &operator=(const QVarLengthArray &other) - { - if (this != &other) { - clear(); - append(other.constData(), other.size()); - } - return *this; - } - - inline void removeLast() { - Q_ASSERT(s > 0); - reallocData(s - 1, a); - } - inline int size() const { return s; } - inline int count() const { return s; } - inline bool isEmpty() const { return (s == 0); } - inline void resize(int size); - inline void clear() { resize(0); } - - inline int capacity() const { return a; } - inline void reserve(int size); - - inline T &operator[](int idx) { - Q_ASSERT(idx >= 0 && idx < s); - return ptr[idx]; - } - inline const T &operator[](int idx) const { - Q_ASSERT(idx >= 0 && idx < s); - return ptr[idx]; - } - inline const T &at(int idx) const { return operator[](idx); } - - T value(int i) const; - T value(int i, const T &defaultValue) const; - - inline void append(const T &t) { - const int newSize = s + 1; - if (newSize > a) { - reallocData(s, newSize); - } - const int idx = s++; - if (QTypeInfo::isComplex) { - new (ptr + idx) T(t); - } else { - ptr[idx] = t; - } - } - void append(const T *buf, int size); - inline QVarLengthArray &operator<<(const T &t) - { append(t); return *this; } - inline QVarLengthArray &operator+=(const T &t) - { append(t); return *this; } - - void prepend(const T &t); - void insert(int i, const T &t); - void insert(int i, int n, const T &t); - void replace(int i, const T &t); - void remove(int i); - void remove(int i, int n); - - inline T *data() { return ptr; } - inline const T *data() const { return ptr; } - inline const T * constData() const { return ptr; } - typedef int size_type; - typedef T value_type; - typedef value_type *pointer; - typedef const value_type *const_pointer; - typedef value_type &reference; - typedef const value_type &const_reference; - typedef qptrdiff difference_type; - - typedef T* iterator; - typedef const T* const_iterator; - - inline iterator begin() { return ptr; } - inline const_iterator begin() const { return ptr; } - inline const_iterator constBegin() const { return ptr; } - inline iterator end() { return ptr + s; } - inline const_iterator end() const { return ptr + s; } - inline const_iterator constEnd() const { return ptr + s; } - iterator insert(iterator before, int n, const T &x); - inline iterator insert(iterator before, const T &x) { return insert(before, 1, x); } - iterator erase(iterator begin, iterator end); - inline iterator erase(iterator pos) { return erase(pos, pos+1); } - -private: - void reallocData(int size, int alloc); - - int a; // capacity - int s; // size - T *ptr; // data -}; - -template -Q_INLINE_TEMPLATE QVarLengthArray::QVarLengthArray(int asize) - : a(asize), s(asize), ptr(nullptr) -{ - if (s <= 0) { - return; - } - ptr = static_cast(::malloc(s * sizeof(T))); - Q_CHECK_PTR(ptr); - if (QTypeInfo::isComplex) { - T *i = ptr + s; - while (i != ptr) { - new (--i) T(); - } - } -} - -template -Q_INLINE_TEMPLATE void QVarLengthArray::resize(int asize) -{ - reallocData(asize, qMax(asize, a)); -} - -template -Q_INLINE_TEMPLATE void QVarLengthArray::reserve(int asize) -{ - if (asize > a) { - reallocData(s, asize); - } -} - -template -Q_OUTOFLINE_TEMPLATE void QVarLengthArray::append(const T *abuf, int increment) -{ - if (increment <= 0) { - return; - } - - Q_ASSERT(abuf); - const int asize = s + increment; - - if (asize > a) { - reallocData(s, asize); - } - - if (QTypeInfo::isComplex) { - // call constructor for new objects (which can throw) - while (s < asize) { - new (ptr+(s++)) T(*abuf++); - } - } else { - ::memcpy(&ptr[s], abuf, increment * sizeof(T)); - s = asize; - } -} - -template -Q_OUTOFLINE_TEMPLATE void QVarLengthArray::reallocData(int asize, int aalloc) -{ - Q_ASSERT(aalloc >= asize); - T *oldPtr = ptr; - int osize = s; - - const int copySize = qMin(asize, osize); - if (aalloc != a) { - ptr = static_cast(::malloc(aalloc * sizeof(T))); - Q_CHECK_PTR(ptr); - s = 0; - a = aalloc; - - if (QTypeInfo::isStatic) { - // copy all the old elements - while (s < copySize) { - new (ptr+s) T(*(oldPtr+s)); - (oldPtr+s)->~T(); - s++; - } - } else { - ::memcpy(ptr, oldPtr, copySize * sizeof(T)); - } - } - s = copySize; - - if (QTypeInfo::isComplex) { - // destroy remaining old objects - while (osize > asize) { - (oldPtr+(--osize))->~T(); - } - } - - if (oldPtr && oldPtr != ptr) { - ::free(oldPtr); - } - - if (QTypeInfo::isComplex) { - // call default constructor for new objects (which can throw) - while (s < asize) { - new (ptr+(s++)) T; - } - } else { - s = asize; - } -} - -template -Q_OUTOFLINE_TEMPLATE T QVarLengthArray::value(int i) const -{ - if (i < 0 || i >= size()) { - return T(); - } - return at(i); -} - -template -Q_OUTOFLINE_TEMPLATE T QVarLengthArray::value(int i, const T &defaultValue) const -{ - return (i < 0 || i >= size()) ? defaultValue : at(i); -} - -template -inline void QVarLengthArray::insert(int i, const T &t) -{ - Q_ASSERT_X(i >= 0 && i <= s, "QVarLengthArray::insert", "index out of range"); - insert(begin() + i, 1, t); -} - -template -inline void QVarLengthArray::insert(int i, int n, const T &t) -{ - Q_ASSERT_X(i >= 0 && i <= s, "QVarLengthArray::insert", "index out of range"); - insert(begin() + i, n, t); -} - -template -inline void QVarLengthArray::remove(int i, int n) -{ - Q_ASSERT_X(i >= 0 && n >= 0 && i + n <= s, "QVarLengthArray::remove", "index out of range"); - erase(begin() + i, begin() + i + n); -} - -template -inline void QVarLengthArray::remove(int i) -{ - Q_ASSERT_X(i >= 0 && i < s, "QVarLengthArray::remove", "index out of range"); - erase(begin() + i, begin() + i + 1); -} - -template -inline void QVarLengthArray::prepend(const T &t) -{ - insert(begin(), 1, t); -} - -template -inline void QVarLengthArray::replace(int i, const T &t) -{ - Q_ASSERT_X(i >= 0 && i < s, "QVarLengthArray::replace", "index out of range"); - ptr[i] = t; -} - -template -Q_OUTOFLINE_TEMPLATE typename QVarLengthArray::iterator QVarLengthArray::insert(iterator before, size_type n, const T &t) -{ - int offset = int(before - ptr); - if (n != 0) { - resize(s + n); - if (QTypeInfo::isStatic) { - T *b = ptr + offset; - T *j = ptr + s; - T *i = j - n; - while (i != b) { - *--j = *--i; - } - i = b + n; - while (i != b) { - *--i = t; - } - } else { - T *b = ptr + offset; - T *i = b + n; - ::memmove(i, b, (s - offset - n) * sizeof(T)); - while (i != b) { - new (--i) T(t); - } - } - } - return ptr + offset; -} - -template -Q_OUTOFLINE_TEMPLATE typename QVarLengthArray::iterator QVarLengthArray::erase(iterator abegin, iterator aend) -{ - int f = int(abegin - ptr); - int l = int(aend - ptr); - int n = l - f; - if (QTypeInfo::isComplex) { - qCopy(ptr + l, ptr + s, ptr + f); - T *i = ptr + s; - T *b = ptr + s - n; - while (i != b) { - --i; - i->~T(); - } - } else { - ::memmove(ptr + f, ptr + l, (s - l) * sizeof(T)); - } - s -= n; - return ptr + f; -} - -template -bool operator==(const QVarLengthArray &l, const QVarLengthArray &r) -{ - if (l.size() != r.size()) { - return false; - } - for (int i = 0; i < l.size(); i++) { - if (l.at(i) != r.at(i)) { - return false; - } - } - return true; -} - -template -bool operator!=(const QVarLengthArray &l, const QVarLengthArray &r) -{ - return !(l == r); -} - -QT_END_NAMESPACE - -#endif // QVARLENGTHARRAY_H diff --git a/src/core/tools/qvarlengtharray.qdoc b/src/core/tools/qvarlengtharray.qdoc deleted file mode 100644 index 4c570d0f3..000000000 --- a/src/core/tools/qvarlengtharray.qdoc +++ /dev/null @@ -1,540 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Copyright (C) 2016 Ivailo Monev -** -** This file is part of the documentation of the Katie Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License Usage -** This file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: http://www.gnu.org/copyleft/fdl.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \class QVarLengthArray - \brief The QVarLengthArray class provides a low-level variable-length array. - - \ingroup tools - \reentrant - - The C++ language doesn't support variable-length arrays on the stack. - For example, the following code won't compile: - - \snippet doc/src/snippets/code/doc_src_qvarlengtharray.cpp 0 - - The alternative is to allocate the array on the heap (with - \c{new}): - - \snippet doc/src/snippets/code/doc_src_qvarlengtharray.cpp 1 - - However, if myfunc() is called very frequently from the - application's inner loop, heap allocation can be a major source - of slowdown. - - QVarLengthArray does not attempt to work around this gap in the - C++ language. It allocates elements on the heap, however the - option to reserve elements is there. - - QVarLengthArray's value type must be an \l{assignable data type}. - This covers most data types that are commonly used, but the - compiler won't let you, for example, store a QWidget as a value; - instead, store a QWidget *. - - QVarLengthArray, like QVector, provides a resizable array data - structure. The main differences between the two classes are: - - \list - \o QVarLengthArray's API is much more low-level. It provides no - iterators and lacks much of QVector's functionality. - - \o QVarLengthArray doesn't initialize the memory if the value is - a basic type. (QVector always does.) - - \o QVector uses \l{implicit sharing} as a memory optimization. - QVarLengthArray doesn't provide that feature; however, it - usually produces slightly better performance due to reduced - overhead, especially in tight loops. - \endlist - - In summary, QVarLengthArray is a low-level optimization class - that only makes sense in very specific cases. It is used a few - places inside Qt and was added to Qt's public API for the - convenience of advanced users. - - \sa QVector, QList -*/ - -/*! \fn QVarLengthArray::QVarLengthArray(int size) - - Constructs an array with an initial size of \a size elements. - - If the value type is a primitive type (e.g., char, int, float) or - a pointer type (e.g., QWidget *), the elements are not - initialized. For other types, the elements are initialized with a - \l{default-constructed value}. -*/ - -/*! \fn QVarLengthArray::~QVarLengthArray() - - Destroys the array. -*/ - -/*! \fn int QVarLengthArray::size() const - - Returns the number of elements in the array. - - \sa isEmpty(), resize() -*/ - -/*! \fn int QVarLengthArray::count() const - - Same as size(). - - \sa isEmpty(), resize() -*/ - -/*! \fn bool QVarLengthArray::isEmpty() const - - Returns true if the array has size 0; otherwise returns false. - - \sa size(), resize() -*/ - -/*! \fn void QVarLengthArray::clear() - - Removes all the elements from the array. - - Same as resize(0). -*/ - -/*! \fn void QVarLengthArray::resize(int size) - - Sets the size of the array to \a size. If \a size is greater than - the current size, elements are added to the end. If \a size is - less than the current size, elements are removed from the end. - - If the value type is a primitive type (e.g., char, int, float) or - a pointer type (e.g., QWidget *), new elements are not - initialized. For other types, the elements are initialized with a - \l{default-constructed value}. - - \sa size() -*/ - -/*! \fn int QVarLengthArray::capacity() const - - Returns the maximum number of elements that can be stored in the - array without forcing a reallocation. - - The sole purpose of this function is to provide a means of fine - tuning QVarLengthArray's memory usage. In general, you will rarely ever - need to call this function. If you want to know how many items are - in the array, call size(). - - \sa reserve() -*/ - -/*! \fn void QVarLengthArray::reserve(int size) - - Attempts to allocate memory for at least \a size elements. If you - know in advance how large the array can get, you can call this - function and if you call resize() often, you are likely to get - better performance. If \a size is an underestimate, the worst - that will happen is that the QVarLengthArray will be a bit - slower. - - The sole purpose of this function is to provide a means of fine - tuning QVarLengthArray's memory usage. In general, you will - rarely ever need to call this function. If you want to change the - size of the array, call resize(). - - \sa capacity() -*/ - -/*! \fn T &QVarLengthArray::operator[](int i) - - Returns a reference to the item at index position \a i. - - \a i must be a valid index position in the array (i.e., 0 <= \a i - < size()). - - \sa data(), at() -*/ - -/*! \fn const T &QVarLengthArray::operator[](int i) const - - \overload -*/ - - -/*! - \fn void QVarLengthArray::append(const T &t) - - Appends item \a t to the array, extending the array if necessary. - - \sa removeLast() -*/ - - -/*! - \fn inline void QVarLengthArray::removeLast() - \since 4.5 - - Decreases the size of the array by one. The allocated size is not changed. - - \sa append() -*/ - -/*! - \fn void QVarLengthArray::append(const T *buf, int size) - - Appends \a size amount of items referenced by \a buf to this array. -*/ - - -/*! \fn T *QVarLengthArray::data() - - Returns a pointer to the data stored in the array. The pointer can - be used to access and modify the items in the array. - - Example: - \snippet doc/src/snippets/code/doc_src_qvarlengtharray.cpp 3 - - The pointer remains valid as long as the array isn't reallocated. - - This function is mostly useful to pass an array to a function - that accepts a plain C++ array. - - \sa constData(), operator[]() -*/ - -/*! \fn const T *QVarLengthArray::data() const - - \overload -*/ - -/*! \fn const T *QVarLengthArray::constData() const - - Returns a const pointer to the data stored in the array. The - pointer can be used to access the items in the array. The - pointer remains valid as long as the array isn't reallocated. - - This function is mostly useful to pass an array to a function - that accepts a plain C++ array. - - \sa data(), operator[]() -*/ - -/*! \fn QVarLengthArray &QVarLengthArray::operator=(const QVarLengthArray &other) - Assigns \a other to this array and returns a reference to this array. - */ - -/*! \fn QVarLengthArray::QVarLengthArray(const QVarLengthArray &other) - Constructs a copy of \a other. - */ - -/*! \fn const T &QVarLengthArray::at(int i) const - - Returns a reference to the item at index position \a i. - - \a i must be a valid index position in the array (i.e., 0 <= \a i - < size()). - - \sa value(), operator[]() -*/ - -/*! \fn T QVarLengthArray::value(int i) const - - Returns the value at index position \a i. - - If the index \a i is out of bounds, the function returns - a \l{default-constructed value}. If you are certain that - \a i is within bounds, you can use at() instead, which is slightly - faster. - - \sa at(), operator[]() -*/ - -/*! \fn T QVarLengthArray::value(int i, const T &defaultValue) const - - \overload - - If the index \a i is out of bounds, the function returns - \a defaultValue. -*/ - -/*! - \typedef QVarLengthArray::size_type - \since 4.7 - - Typedef for int. Provided for STL compatibility. -*/ - -/*! - \typedef QVarLengthArray::value_type - \since 4.7 - - Typedef for T. Provided for STL compatibility. -*/ - -/*! - \typedef QVarLengthArray::difference_type - \since 4.7 - - Typedef for ptrdiff_t. Provided for STL compatibility. -*/ - -/*! - \typedef QVarLengthArray::pointer - \since 4.7 - - Typedef for T *. Provided for STL compatibility. -*/ - -/*! - \typedef QVarLengthArray::const_pointer - \since 4.7 - - Typedef for const T *. Provided for STL compatibility. -*/ - -/*! - \typedef QVarLengthArray::reference - \since 4.7 - - Typedef for T &. Provided for STL compatibility. -*/ - -/*! - \typedef QVarLengthArray::const_reference - \since 4.7 - - Typedef for const T &. Provided for STL compatibility. -*/ - -/*! - \typedef QVarLengthArray::const_iterator - \since 4.7 - - Typedef for const T *. Provided for STL compatibility. -*/ - -/*! - \typedef QVarLengthArray::iterator - \since 4.7 - - Typedef for T *. Provided for STL compatibility. -*/ - -/*! \fn void QVarLengthArray::prepend(const T &value) - - \since 4.8 - Inserts \a value at the beginning of the array. - - - This is the same as vector.insert(0, \a value). - - For large arrays, this operation can be slow (\l{linear time}), - because it requires moving all the items in the vector by one - position further in memory. If you want a container class that - provides a fast prepend() function, use QList instead. - - \sa append(), insert() -*/ - -/*! \fn void QVarLengthArray::replace(int i, const T &value) - - \since 4.8 - Replaces the item at index position \a i with \a value. - - \a i must be a valid index position in the array (i.e., 0 <= \a - i < size()). - - \sa operator[](), remove() -*/ - -/*! \fn void QVarLengthArray::remove(int i) - - \overload - \since 4.8 - - Removes the element at index position \a i. - - \sa insert(), replace() -*/ - -/*! \fn void QVarLengthArray::remove(int i, int count) - - \overload - \since 4.8 - - Removes \a count elements from the middle of the array, starting at - index position \a i. - - \sa insert(), replace() -*/ - -/*! \fn QVarLengthArray::iterator QVarLengthArray::begin() - \since 4.8 - - Returns an \l{STL-style iterator} pointing to the first item in - the array. - - \sa constBegin(), end() -*/ - -/*! \fn QVarLengthArray::const_iterator QVarLengthArray::begin() const - \since 4.8 - \overload -*/ - -/*! \fn QVarLengthArray::const_iterator QVarLengthArray::constBegin() const - \since 4.8 - - Returns a const \l{STL-style iterator} pointing to the first item - in the array. - - \sa begin(), constEnd() -*/ - -/*! \fn QVarLengthArray::iterator QVarLengthArray::end() - \since 4.8 - - Returns an \l{STL-style iterator} pointing to the imaginary item - after the last item in the array. - - \sa begin(), constEnd() -*/ - -/*! \fn QVarLengthArray::const_iterator QVarLengthArray::end() const - \since 4.8 - - \overload -*/ - -/*! \fn QVarLengthArray::const_iterator QVarLengthArray::constEnd() const - \since 4.8 - - Returns a const \l{STL-style iterator} pointing to the imaginary - item after the last item in the array. - - \sa constBegin(), end() -*/ - -/*! \fn QVarLengthArray::iterator QVarLengthArray::erase(iterator pos) - \since 4.8 - - Removes the item pointed to by the iterator \a pos from the - vector, and returns an iterator to the next item in the vector - (which may be end()). - - \sa insert(), remove() -*/ - -/*! \fn QVarLengthArray::iterator QVarLengthArray::erase(iterator begin, iterator end) - - \overload - \since 4.8 - - Removes all the items from \a begin up to (but not including) \a - end. Returns an iterator to the same item that \a end referred to - before the call. -*/ - -/*! \fn void QVarLengthArray::insert(int i, const T &value) - \since 4.8 - - Inserts \a value at index position \a i in the array. If \a i is - 0, the value is prepended to the vector. If \a i is size(), the - value is appended to the vector. - - For large arrays, this operation can be slow (\l{linear time}), - because it requires moving all the items at indexes \a i and - above by one position further in memory. - - \sa remove() -*/ - -/*! \fn void QVarLengthArray::insert(int i, int count, const T &value) - - \overload - \since 4.8 - - Inserts \a count copies of \a value at index position \a i in the - vector. -*/ - -/*! \fn QVarLengthArray::iterator QVarLengthArray::insert(iterator before, const T &value) - - \overload - \since 4.8 - - Inserts \a value in front of the item pointed to by the iterator - \a before. Returns an iterator pointing at the inserted item. -*/ - -/*! \fn QVarLengthArray::iterator QVarLengthArray::insert(iterator before, int count, const T &value) - - \since 4.8 - Inserts \a count copies of \a value in front of the item pointed to - by the iterator \a before. Returns an iterator pointing at the - first of the inserted items. -*/ - - - -/*! \fn bool operator==(const QVarLengthArray &left, const QVarLengthArray &right) - - \relates QVarLengthArray - \since 4.8 - Returns true if the two arrays, specified by \a left and \a right, are equal. - - Two arrays are considered equal if they contain the same values - in the same order. - - This function requires the value type to have an implementation - of \c operator==(). - - \sa operator!=() -*/ - -/*! \fn bool operator!=(const QVarLengthArray &left, const QVarLengthArray &right) - - \relates QVarLengthArray - \since 4.8 - Returns true if the two arrays, specified by \a left and \a right, are \e not equal. - - Two arrays are considered equal if they contain the same values - in the same order. - - This function requires the value type to have an implementation - of \c operator==(). - - \sa operator==() -*/ - -/*! \fn QVarLengthArray &QVarLengthArray::operator<<(const T &value) - - \since 4.8 - Appends \a value to the array and returns a reference to this - vector. - - \sa append(), operator+=() -*/ - -/*! \fn QVarLengthArray &QVarLengthArray::operator+=(const T &value) - - \since 4.8 - Appends \a value to the array and returns a reference to this - vector. - - \sa append(), operator<<() -*/ - diff --git a/src/core/tools/qvector.cpp b/src/core/tools/qvector.cpp index d0d882c3a..a714dd8a6 100644 --- a/src/core/tools/qvector.cpp +++ b/src/core/tools/qvector.cpp @@ -89,7 +89,7 @@ int QVectorData::grow(int sizeofTypedData, int size, int sizeofT, bool excessive stores its items in adjacent memory locations and provides fast index-based access. - QList\ and QVarLengthArray\ provide similar functionality. + QList\ provides similar functionality. Here's an overview: \list @@ -102,8 +102,6 @@ int QVectorData::grow(int sizeofTypedData, int size, int sizeofT, bool excessive if your items are larger than a pointer and you want to avoid the overhead of allocating them on the heap individually at insertion time, then use QVector. - \i If you want a low-level variable-size array, QVarLengthArray - may be sufficient. \endlist Here's an example of a QVector that stores integers and a QVector @@ -197,10 +195,6 @@ int QVectorData::grow(int sizeofTypedData, int size, int sizeofT, bool excessive QVector::iterator). In practice, these are rarely used, because you can use indexes into the QVector. - In addition to QVector, Qt also provides QVarLengthArray, a very - low-level class with little functionality that is optimized for - speed. - QVector does \e not support inserting, prepending, appending or replacing with references to its own values. Doing so will cause your application to abort with an error message. diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index 73e472068..6b34e88c5 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -27,7 +27,6 @@ #include "qstringlist.h" #include "qtimer.h" #include "qthread.h" - #include "qdbusargument.h" #include "qdbusconnection_p.h" #include "qdbusconnectionmanager_p.h" @@ -42,7 +41,6 @@ #include "qdbuscontext_p.h" #include "qdbuspendingcall_p.h" #include "qdbusintegrator_p.h" - #include "qdbusthreaddebug_p.h" @@ -113,7 +111,7 @@ Q_AUTOTEST_EXPORT qdbusThreadDebugFunc qdbusThreadDebug = 0; #endif typedef void (*QDBusSpyHook)(const QDBusMessage&); -typedef QVarLengthArray QDBusSpyHookList; +typedef QStdVector QDBusSpyHookList; Q_GLOBAL_STATIC(QDBusSpyHookList, qDBusSpyHookList) extern "C" { @@ -851,7 +849,7 @@ void QDBusConnectionPrivate::deliverCall(QObject *object, const QDBusMessage &ms "QDBusConnection: internal threading error", "function called for an object that is in another thread!!"); - QVarLengthArray params; + QStdVector params; params.reserve(metaTypes.count()); QVariantList auxParameters; diff --git a/src/dbus/qdbusmetaobject.cpp b/src/dbus/qdbusmetaobject.cpp index 711b53e92..bac447764 100644 --- a/src/dbus/qdbusmetaobject.cpp +++ b/src/dbus/qdbusmetaobject.cpp @@ -20,20 +20,17 @@ ****************************************************************************/ #include "qdbusmetaobject_p.h" - -#include -#include -#include -#include - +#include "qbytearray.h" +#include "qhash.h" +#include "qstring.h" #include "qdbusutil_p.h" #include "qdbuserror.h" #include "qdbusmetatype.h" #include "qdbusargument.h" #include "qdbusintrospection_p.h" #include "qdbusabstractinterface_p.h" - #include "qmetaobject_p.h" +#include "qstdcontainers_p.h" QT_BEGIN_NAMESPACE @@ -56,8 +53,8 @@ private: QByteArray name; QByteArray inputSignature; QByteArray outputSignature; - QVarLengthArray inputTypes; - QVarLengthArray outputTypes; + QStdVector inputTypes; + QStdVector outputTypes; int flags; }; @@ -355,7 +352,7 @@ void QDBusMetaObjectGenerator::write(QDBusMetaObject *obj) foreach (const Method &mm, methods) data_size += 2 + mm.inputTypes.count() + mm.outputTypes.count(); - QVarLengthArray idata(data_size + 1); + QStdVector idata(data_size + 1); QDBusMetaObjectPrivate *header = reinterpret_cast(idata.data()); header->revision = qmetaobjectrevision; diff --git a/src/declarative/qml/parser/qdeclarativejs.g b/src/declarative/qml/parser/qdeclarativejs.g index 53d419935..f224209f0 100644 --- a/src/declarative/qml/parser/qdeclarativejs.g +++ b/src/declarative/qml/parser/qdeclarativejs.g @@ -332,7 +332,7 @@ protected: /. #include "qdeclarativejsparser_p.h" -#include +#include "qstdcontainers_p.h" // // This file is automatically generated from qdeclarativejs.g. @@ -396,8 +396,8 @@ static inline AST::SourceLocation location(Lexer *lexer) AST::UiQualifiedId *Parser::reparseAsQualifiedId(AST::ExpressionNode *expr) { - QVarLengthArray nameIds; - QVarLengthArray locations; + QStdVector nameIds; + QStdVector locations; AST::ExpressionNode *it = expr; while (AST::FieldMemberExpression *m = AST::cast(it)) { diff --git a/src/declarative/qml/parser/qdeclarativejsparser.cpp b/src/declarative/qml/parser/qdeclarativejsparser.cpp index 0e82186a8..3235b9c55 100644 --- a/src/declarative/qml/parser/qdeclarativejsparser.cpp +++ b/src/declarative/qml/parser/qdeclarativejsparser.cpp @@ -27,7 +27,7 @@ #include "qdeclarativejsast_p.h" #include "qdeclarativejsnodepool_p.h" #include "qdeclarativejsparser_p.h" -#include +#include "qstdcontainers_p.h" #include @@ -93,8 +93,8 @@ static inline AST::SourceLocation location(Lexer *lexer) AST::UiQualifiedId *Parser::reparseAsQualifiedId(AST::ExpressionNode *expr) { - QVarLengthArray nameIds; - QVarLengthArray locations; + QStdVector nameIds; + QStdVector locations; AST::ExpressionNode *it = expr; while (AST::FieldMemberExpression *m = AST::cast(it)) { diff --git a/src/declarative/qml/qdeclarativeboundsignal.cpp b/src/declarative/qml/qdeclarativeboundsignal.cpp index ee3620b21..d8321e7da 100644 --- a/src/declarative/qml/qdeclarativeboundsignal.cpp +++ b/src/declarative/qml/qdeclarativeboundsignal.cpp @@ -116,7 +116,7 @@ void QDeclarativeBoundSignal::disconnect() { QMetaObject::disconnect(m_scope, m_signal.methodIndex(), this, evaluateIdx); QObjectPrivate * const priv = QObjectPrivate::get(m_scope); - QVarLengthArray signalSignature; + QStdVector signalSignature; QObjectPrivate::signalSignature(m_signal, &signalSignature); priv->disconnectNotify(signalSignature.constData()); } diff --git a/src/declarative/qml/qdeclarativenotifier_p.h b/src/declarative/qml/qdeclarativenotifier_p.h index 0c2d2613a..2d47dba9a 100644 --- a/src/declarative/qml/qdeclarativenotifier_p.h +++ b/src/declarative/qml/qdeclarativenotifier_p.h @@ -197,7 +197,7 @@ void QDeclarativeNotifierEndpoint::disconnect() QMetaObject::disconnectOne(s->source, s->sourceSignal, target, targetMethod); QObjectPrivate * const priv = QObjectPrivate::get(s->source); const QMetaMethod signal = s->source->metaObject()->method(s->sourceSignal); - QVarLengthArray signalSignature; + QStdVector signalSignature; QObjectPrivate::signalSignature(signal, &signalSignature); priv->disconnectNotify(signalSignature.constData()); s->source = 0; diff --git a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp index 223f87f8e..9d5c0478c 100644 --- a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp +++ b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp @@ -29,9 +29,9 @@ #include "qdeclarativeguard_p.h" #include "qdeclarativevmemetaobject_p.h" #include "qdeclarativecommon_p.h" -#include -#include -#include +#include "qtimer.h" +#include "qscriptcontextinfo.h" +#include "qstdcontainers_p.h" #include @@ -898,7 +898,7 @@ QDeclarativeObjectMethodScriptClass::callPrecise(QObject *object, const QDeclara QMetaMethod m = object->metaObject()->method(data.coreIndex); QList argTypeNames = m.parameterTypes(); - QVarLengthArray argTypes(argTypeNames.count()); + QStdVector argTypes(argTypeNames.count()); // ### Cache for (int ii = 0; ii < argTypeNames.count(); ++ii) { @@ -928,13 +928,13 @@ QDeclarativeObjectMethodScriptClass::callMethod(QObject *object, int index, { if (argCount > 0) { - QVarLengthArray args(argCount + 1); + QStdVector args(argCount + 1); args[0].initAsType(returnType, engine); for (int ii = 0; ii < argCount; ++ii) args[ii + 1].fromScriptValue(argTypes[ii], engine, ctxt->argument(ii)); - QVarLengthArray argData(args.count()); + QStdVector argData(args.count()); for (int ii = 0; ii < args.count(); ++ii) argData[ii] = args[ii].dataPtr(); @@ -1003,7 +1003,7 @@ QDeclarativeObjectMethodScriptClass::callOverloaded(MethodData *method, QScriptC continue; // We already have a better option int methodMatchScore = 0; - QVarLengthArray methodArgTypes(methodArgumentCount); + QStdVector methodArgTypes(methodArgumentCount); bool unknownArgument = false; for (int ii = 0; ii < methodArgumentCount; ++ii) { diff --git a/src/declarative/qml/qdeclarativeproperty.cpp b/src/declarative/qml/qdeclarativeproperty.cpp index f53020dd2..a8bc16944 100644 --- a/src/declarative/qml/qdeclarativeproperty.cpp +++ b/src/declarative/qml/qdeclarativeproperty.cpp @@ -1596,7 +1596,7 @@ bool QDeclarativePropertyPrivate::connect(QObject *sender, int signal_index, // would return the wrong result inside connectNotify(). const QMetaMethod signal = sender->metaObject()->method(signal_index); QObjectPrivate * const senderPriv = QObjectPrivate::get(sender); - QVarLengthArray signalSignature; + QStdVector signalSignature; QObjectPrivate::signalSignature(signal, &signalSignature); senderPriv->connectNotify(signalSignature.constData()); diff --git a/src/declarative/qml/qdeclarativevme.cpp b/src/declarative/qml/qdeclarativevme.cpp index ad54f2a46..ab81f8121 100644 --- a/src/declarative/qml/qdeclarativevme.cpp +++ b/src/declarative/qml/qdeclarativevme.cpp @@ -20,7 +20,6 @@ ****************************************************************************/ #include "qdeclarativevme_p.h" - #include "qdeclarativecompiler_p.h" #include "qdeclarativeboundsignal_p.h" #include "qdeclarativestringconverters_p.h" @@ -40,26 +39,25 @@ #include "qdeclarativecompiledbindings_p.h" #include "qdeclarativeglobal_p.h" #include "qdeclarativescriptstring.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "qstack.h" +#include "qwidget.h" +#include "qcolor.h" +#include "qpoint.h" +#include "qsize.h" +#include "qrect.h" +#include "qdebug.h" +#include "qcoreapplication.h" +#include "qdatetime.h" +#include "qstdcontainers_p.h" QT_BEGIN_NAMESPACE -// A simple stack wrapper around QVarLengthArray +// A simple stack wrapper around QStdVector template -class QDeclarativeVMEStack : private QVarLengthArray +class QDeclarativeVMEStack : private QStdVector { private: - typedef QVarLengthArray VLA; + typedef QStdVector VLA; int _index; public: diff --git a/src/gui/dialogs/qwizard.cpp b/src/gui/dialogs/qwizard.cpp index 0f5fa8d52..49ff75a98 100644 --- a/src/gui/dialogs/qwizard.cpp +++ b/src/gui/dialogs/qwizard.cpp @@ -37,8 +37,8 @@ #include "qpushbutton.h" #include "qset.h" #include "qstyle.h" -#include "qvarlengtharray.h" #include "qdialog_p.h" +#include "qstdcontainers_p.h" #include "qdebug.h" #include // for memset() @@ -1303,7 +1303,7 @@ void QWizardPrivate::updateButtonTexts() void QWizardPrivate::updateButtonLayout() { if (buttonsHaveCustomLayout) { - QVarLengthArray array(buttonsCustomLayout.count()); + QStdVector array(buttonsCustomLayout.count()); for (int i = 0; i < buttonsCustomLayout.count(); ++i) array[i] = buttonsCustomLayout.at(i); setButtonLayout(array.constData(), array.count()); @@ -1313,7 +1313,7 @@ void QWizardPrivate::updateButtonLayout() const int ArraySize = 12; QWizard::WizardButton array[ArraySize]; - memset(array, QWizard::NoButton, sizeof(array)); + ::memset(array, QWizard::NoButton, sizeof(array)); Q_ASSERT(array[0] == QWizard::NoButton); if (opts & QWizard::HaveHelpButton) { diff --git a/src/gui/graphicsview/qgridlayoutengine.cpp b/src/gui/graphicsview/qgridlayoutengine.cpp index 593d4a1a0..0d13c0e7d 100644 --- a/src/gui/graphicsview/qgridlayoutengine.cpp +++ b/src/gui/graphicsview/qgridlayoutengine.cpp @@ -27,9 +27,9 @@ #include "qgridlayoutengine_p.h" #include "qstyleoption.h" #include "qgraphicswidget_p.h" -#include "qvarlengtharray.h" #include "qdebug.h" #include "qmath.h" +#include "qstdcontainers_p.h" #include "qcorecommon_p.h" QT_BEGIN_NAMESPACE @@ -156,9 +156,9 @@ void QGridLayoutRowData::distributeMultiCells(const QGridLayoutRowInfo &rowInfo) int stretch = i.value().q_stretch; QGridLayoutBox totalBox = this->totalBox(start, end); - QVarLengthArray extras(span); - QVarLengthArray dummy(span); - QVarLengthArray newSizes(span); + QStdVector extras(span); + QStdVector dummy(span); + QStdVector newSizes(span); for (int j = 0; j < NSizes; ++j) { qreal extra = compare(box, totalBox, j); diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 7842790ba..d3f04c8d5 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -35,7 +35,7 @@ #include "qhash.h" #include "qpaintengine_raster_p.h" #include "qimage_p.h" -#include "qvarlengtharray.h" +#include "qstdcontainers_p.h" #include "qcorecommon_p.h" #include "qguicommon_p.h" #include "qx11info_x11.h" @@ -1706,7 +1706,7 @@ static void dither_to_Mono(QImageData *dst, const QImageData *src, switch (dithermode) { case Diffuse: { - QVarLengthArray lineBuffer(src->width * 2); + QStdVector lineBuffer(src->width * 2); int *line1 = lineBuffer.data(); int *line2 = lineBuffer.data() + src->width; int bmwidth = (src->width+7)/8; diff --git a/src/gui/kernel/qgridlayout.cpp b/src/gui/kernel/qgridlayout.cpp index 1517ff054..6c9780f71 100644 --- a/src/gui/kernel/qgridlayout.cpp +++ b/src/gui/kernel/qgridlayout.cpp @@ -25,7 +25,6 @@ #include "qlist.h" #include "qsizepolicy.h" #include "qvector.h" -#include "qvarlengtharray.h" #include "qlayoutengine_p.h" #include "qlayout_p.h" @@ -678,7 +677,7 @@ void QGridLayoutPrivate::setupLayoutData(int hSpacing, int vSpacing) Grid of items. We use it to determine which items are adjacent to which and compute the spacings correctly. */ - QVarLengthArray grid(rr * cc); + QVector grid(rr * cc); ::memset(grid.data(), 0, size_t(rr) * cc * sizeof(QGridBox *)); /* diff --git a/src/gui/painting/qbackingstore.cpp b/src/gui/painting/qbackingstore.cpp index d16f61437..02d4399d6 100644 --- a/src/gui/painting/qbackingstore.cpp +++ b/src/gui/painting/qbackingstore.cpp @@ -23,7 +23,6 @@ #include "qplatformdefs.h" #include "qbackingstore_p.h" #include "qdebug.h" -#include "qvarlengtharray.h" #include "qevent.h" #include "qapplication.h" #include "qpaintengine.h" @@ -33,6 +32,7 @@ #include "qwidget_p.h" #include "qwindowsurface_p.h" #include "qapplication_p.h" +#include "qstdcontainers_p.h" #include "qpaintengine_raster_p.h" QT_BEGIN_NAMESPACE @@ -659,7 +659,7 @@ void QWidgetBackingStore::sync() // painted (in case someone calls update() in paintEvent). If the widget is opaque // and does not have transparent overlapping siblings, append it to the // opaqueNonOverlappedWidgets list and paint it directly without composition. - QVarLengthArray opaqueNonOverlappedWidgets; + QStdVector opaqueNonOverlappedWidgets; for (int i = 0; i < dirtyWidgets.size(); ++i) { QWidget *w = dirtyWidgets.at(i); QWidgetPrivate *wd = w->d_func(); diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 6a710069e..50806f5fc 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -1980,7 +1980,7 @@ static void qt_merge_clip(const QClipData *c1, const QClipData *c2, QClipData *r { Q_ASSERT(c1->clipSpanHeight == c2->clipSpanHeight && c1->clipSpanHeight == result->clipSpanHeight); - QVarLengthArray buffer; + QStdVector buffer; QClipData::ClipLine *c1ClipLines = const_cast(c1)->clipLines(); QClipData::ClipLine *c2ClipLines = const_cast(c2)->clipLines(); diff --git a/src/gui/painting/qpaintengineex.cpp b/src/gui/painting/qpaintengineex.cpp index a38baa922..3e08e2583 100644 --- a/src/gui/painting/qpaintengineex.cpp +++ b/src/gui/painting/qpaintengineex.cpp @@ -23,7 +23,6 @@ #include "qpainter_p.h" #include "qstroker_p.h" #include "qpainterpath_p.h" -#include "qvarlengtharray.h" #include "qdebug.h" #include "qcorecommon_p.h" diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index cd9542129..0850f91ef 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -35,12 +35,12 @@ #include "qapplication.h" #include "qstyle.h" #include "qthread.h" -#include "qvarlengtharray.h" #include "qpaintengine_p.h" #include "qpainterpath_p.h" #include "qwidget_p.h" #include "qpaintengine_raster_p.h" #include "qstylehelper_p.h" +#include "qstdcontainers_p.h" #include "qguicommon_p.h" QT_BEGIN_NAMESPACE @@ -5901,7 +5901,7 @@ void qt_format_text(const QFont &fnt, const QRectF &_r, uint maxUnderlines = 0; int numUnderlines = 0; - QVarLengthArray underlinePositions(1); + QStdVector underlinePositions(1); QFontMetricsF fm(fnt); QString text = str; diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp index a2fef09e3..24605b7d7 100644 --- a/src/gui/painting/qpainterpath.cpp +++ b/src/gui/painting/qpainterpath.cpp @@ -29,7 +29,6 @@ #include "qpen.h" #include "qpolygon.h" #include "qtextlayout.h" -#include "qvarlengtharray.h" #include "qmath.h" #include "qbezier_p.h" #include "qfontengine_p.h" diff --git a/src/gui/painting/qpainterpath_p.h b/src/gui/painting/qpainterpath_p.h index ea753b9bc..7de3775f7 100644 --- a/src/gui/painting/qpainterpath_p.h +++ b/src/gui/painting/qpainterpath_p.h @@ -33,10 +33,9 @@ // We mean it. // -#include "QtGui/qpainterpath.h" -#include "QtCore/qlist.h" -#include "QtCore/qvarlengtharray.h" - +#include "qpainterpath.h" +#include "qlist.h" +#include "qstdcontainers_p.h" #include "qvectorpath_p.h" #include "qstroker_p.h" @@ -100,8 +99,8 @@ public: } } - QVarLengthArray elements; - QVarLengthArray points; + QStdVector elements; + QStdVector points; uint flags; }; diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp index 665c419d8..427fe2869 100644 --- a/src/gui/painting/qpdf.cpp +++ b/src/gui/painting/qpdf.cpp @@ -1572,8 +1572,8 @@ void QPdfBaseEnginePrivate::drawTextItem(const QPointF &p, const QTextItemInt &t currentPage->fonts.append(font->object_id); const qreal size = ti.fontEngine->fontDef.pixelSize; - QVarLengthArray glyphs; - QVarLengthArray positions; + QStdVector glyphs; + QStdVector positions; ti.fontEngine->getGlyphPositions(ti.glyphs, p, glyphs, positions); if (glyphs.size() == 0) return; diff --git a/src/gui/painting/qregion.cpp b/src/gui/painting/qregion.cpp index 20c27255a..f3fa176a3 100644 --- a/src/gui/painting/qregion.cpp +++ b/src/gui/painting/qregion.cpp @@ -24,12 +24,12 @@ #include "qpolygon.h" #include "qdatastream.h" #include "qvariant.h" -#include "qvarlengtharray.h" #include "qdebug.h" #include "qimage.h" #include "qbitmap.h" #include "qscopedpointer.h" #include "qt_x11_p.h" +#include "qstdcontainers_p.h" #include "qcorecommon_p.h" #include @@ -3260,7 +3260,7 @@ static void PtsToRegion(int numFullPtBlocks, int iCurPtBlock, int lastRow = 0; int extendTo = 0; bool needsExtend = false; - QVarLengthArray row; + QStdVector row; int rowSize = 0; reg->extents.setLeft(INT_MAX); diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index 61431319a..fd28abf5c 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -25,7 +25,6 @@ #include "qbitmap.h" #include "qpainter.h" #include "qpainterpath.h" -#include "qvarlengtharray.h" #include "qmath.h" #include "qendian.h" #include "qdrawhelper_p.h" @@ -89,7 +88,7 @@ QFixed QFontEngine::averageCharWidth() const void QFontEngine::getGlyphPositions(const QGlyphLayout &glyphs, const QPointF &point, - QVarLengthArray &glyphs_out, QVarLengthArray &positions) + QStdVector &glyphs_out, QStdVector &positions) { QFixed xpos = QFixed::fromReal(point.x()); QFixed ypos = QFixed::fromReal(point.y()); @@ -128,8 +127,8 @@ void QFontEngine::addOutlineToPath(qreal x, qreal y, const QGlyphLayout &glyphs, if (!glyphs.numGlyphs) return; - QVarLengthArray positions; - QVarLengthArray positioned_glyphs; + QStdVector positions; + QStdVector positioned_glyphs; getGlyphPositions(glyphs, QPointF(x, y), positioned_glyphs, positions); addGlyphsToPath(positioned_glyphs.data(), positions.data(), positioned_glyphs.size(), path); } @@ -338,8 +337,8 @@ void QFontEngineBox::addOutlineToPath(qreal x, qreal y, const QGlyphLayout &glyp if (!glyphs.numGlyphs) return; - QVarLengthArray positions; - QVarLengthArray positioned_glyphs; + QStdVector positions; + QStdVector positioned_glyphs; getGlyphPositions(glyphs, QPointF(x, y - _size), positioned_glyphs, positions); const QSize s(_size - 3, _size - 3); diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h index 92b228cb8..af1cea6b9 100644 --- a/src/gui/text/qfontengine_p.h +++ b/src/gui/text/qfontengine_p.h @@ -33,8 +33,8 @@ // We mean it. // -#include "QtCore/qatomic.h" -#include +#include "qatomic.h" +#include "qstdcontainers_p.h" #include "qtextengine_p.h" #include "qfont_p.h" @@ -112,7 +112,7 @@ public: QPainterPath *path) = 0; void getGlyphPositions(const QGlyphLayout &glyphs, const QPointF &point, - QVarLengthArray &glyphs_out, QVarLengthArray &positions); + QStdVector &glyphs_out, QStdVector &positions); virtual void addOutlineToPath(qreal, qreal, const QGlyphLayout &, QPainterPath *); diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index 246a1b33f..5bb2ebef0 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -28,7 +28,6 @@ #include "qtextlist.h" #include "qdebug.h" #include "qregexp.h" -#include "qvarlengtharray.h" #include "qtextcodec.h" #include "qthread.h" #include "qtexthtmlparser_p.h" @@ -43,7 +42,7 @@ #include "qfont_p.h" #include "qtextedit_p.h" #include "qdataurl_p.h" - +#include "qstdcontainers_p.h" #include "qtextdocument_p.h" #include "qprinter_p.h" #include "qabstracttextdocumentlayout_p.h" @@ -2586,7 +2585,7 @@ void QTextHtmlExporter::emitTable(const QTextTable *table) } Q_ASSERT(columnWidths.count() == columns); - QVarLengthArray widthEmittedForColumn(columns); + QStdVector widthEmittedForColumn(columns); for (int i = 0; i < columns; ++i) widthEmittedForColumn[i] = false; diff --git a/src/gui/text/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp index a00ac6713..d9ba2a4e0 100644 --- a/src/gui/text/qtextdocumentlayout.cpp +++ b/src/gui/text/qtextdocumentlayout.cpp @@ -33,11 +33,11 @@ #include "qrect.h" #include "qpalette.h" #include "qdebug.h" -#include "qvarlengtharray.h" #include "qstyle.h" #include "qbasictimer.h" #include "qfontmetrics.h" #include "qx11info_x11.h" +#include "qstdcontainers_p.h" #include @@ -935,7 +935,7 @@ void QTextDocumentLayoutPrivate::drawFrame(const QPointF &offset, QPainter *pain const int columns = table->columns(); QTextTableData *td = static_cast(data(table)); - QVarLengthArray selectedTableCells(context.selections.size() * 4); + QStdVector selectedTableCells(context.selections.size() * 4); for (int i = 0; i < context.selections.size(); ++i) { const QAbstractTextDocumentLayout::Selection &s = context.selections.at(i); int row_start = -1, col_start = -1, num_rows = -1, num_cols = -1; @@ -1702,7 +1702,7 @@ recalc_minmax_widths: // for variable columns distribute the remaining space if (variableCols > 0 && remainingWidth > 0) { - QVarLengthArray columnsWithProperMaxSize; + QStdVector columnsWithProperMaxSize; for (int i = 0; i < columns; ++i) if (columnWidthConstraints.at(i).type() == QTextLength::VariableLength && td->maxWidths.at(i) != QFIXED_MAX) @@ -1771,7 +1771,7 @@ recalc_minmax_widths: if (pageHeight <= 0) pageHeight = QFIXED_MAX; - QVarLengthArray heightToDistribute(columns); + QStdVector heightToDistribute(columns); td->headerHeight = 0; const int headerRowCount = qMin(table->format().headerRowCount(), rows - 1); diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index ecbbbf536..4c89a491e 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -25,7 +25,6 @@ #include "qtextengine_p.h" #include "qabstracttextdocumentlayout.h" #include "qtextlayout.h" -#include "qvarlengtharray.h" #include "qfont.h" #include "qfontengine_p.h" #include "qunicodetables_p.h" @@ -291,7 +290,7 @@ void QTextEngine::itemize() const if (!length) return; - QVarLengthArray scriptAnalysis(length); + QStdVector scriptAnalysis(length); QScriptAnalysis *analysis = scriptAnalysis.data(); const ushort *uc = reinterpret_cast(layoutData->string.unicode()); @@ -595,7 +594,7 @@ void QTextEngine::justify(const QScriptLine &line) int firstItem = findItem(line.from); int nItems = findItem(line.from + line_length - 1) - firstItem + 1; - QVarLengthArray justificationPoints; + QStdVector justificationPoints; int nPoints = 0; // qDebug("justifying from %d len %d, firstItem=%d, nItems=%d (%s)", line.from, line_length, firstItem, nItems, layoutData->string.mid(line.from, line_length).toUtf8().constData()); diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index 7aa92b5ef..4eba72c9c 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -26,7 +26,6 @@ #include "qapplication.h" #include "qmath.h" #include "qpainter.h" -#include "qvarlengtharray.h" #include "qtextformat.h" #include "qabstracttextdocumentlayout.h" #include "qtextdocument_p.h" diff --git a/src/gui/text/qtexttable.cpp b/src/gui/text/qtexttable.cpp index 7517ecf30..534104cbc 100644 --- a/src/gui/text/qtexttable.cpp +++ b/src/gui/text/qtexttable.cpp @@ -24,7 +24,7 @@ #include "qtextformat.h" #include "qdebug.h" #include "qtexttable_p.h" -#include "qvarlengtharray.h" +#include "qstdcontainers_p.h" #include @@ -1184,7 +1184,7 @@ void QTextTable::splitCell(int row, int column, int numRows, int numCols) const int origCellPosition = cell.firstPosition() - 1; - QVarLengthArray rowPositions(rowSpan); + QStdVector rowPositions(rowSpan); rowPositions[0] = cell.lastPosition(); diff --git a/src/gui/widgets/qsplitter.cpp b/src/gui/widgets/qsplitter.cpp index db25c4e7a..8f2cdff1d 100644 --- a/src/gui/widgets/qsplitter.cpp +++ b/src/gui/widgets/qsplitter.cpp @@ -32,10 +32,10 @@ #include "qstyle.h" #include "qstyleoption.h" #include "qtextstream.h" -#include "qvarlengtharray.h" #include "qvector.h" #include "qlayoutengine_p.h" #include "qsplitter_p.h" +#include "qstdcontainers_p.h" #include "qtimer.h" #include "qdebug.h" @@ -1304,8 +1304,8 @@ void QSplitter::moveSplitter(int pos, int index) qDebug() << "QSplitter::moveSplitter" << debugp << index << "adjusted" << pos << "oldP" << oldP; #endif - QVarLengthArray poss(d->list.count()); - QVarLengthArray ws(d->list.count()); + QStdVector poss(d->list.count()); + QStdVector ws(d->list.count()); bool upLeft; d->doMove(false, pos, index, +1, (d->collapsible(s) && (pos > max)), poss.data(), ws.data()); diff --git a/src/imports/particles/qdeclarativeparticles.cpp b/src/imports/particles/qdeclarativeparticles.cpp index 2fdd8bfe4..ee8e1cf5f 100644 --- a/src/imports/particles/qdeclarativeparticles.cpp +++ b/src/imports/particles/qdeclarativeparticles.cpp @@ -25,7 +25,6 @@ #include "qdeclarativepixmapcache_p.h" #include #include -#include #include "qmath.h" #include diff --git a/src/script/api/qscriptvalue.cpp b/src/script/api/qscriptvalue.cpp index ffce0f146..25ef509a8 100644 --- a/src/script/api/qscriptvalue.cpp +++ b/src/script/api/qscriptvalue.cpp @@ -21,11 +21,13 @@ #include "Platform.h" #include "qscriptvalue.h" - #include "qscriptvalue_p.h" #include "qscriptengine.h" #include "qscriptengine_p.h" #include "qscriptstring_p.h" +#include "qvariant.h" +#include "qnumeric.h" +#include "qstdcontainers_p.h" #include "JSGlobalObject.h" #include "JSImmediate.h" @@ -36,10 +38,6 @@ #include "Operations.h" #include "Arguments.h" -#include -#include -#include - /*! \since 4.3 \class QScriptValue @@ -1532,7 +1530,7 @@ QScriptValue QScriptValue::call(const QScriptValue &thisObject, if (!jscThisObject || !jscThisObject.isObject()) jscThisObject = d->engine->globalObject(); - QVarLengthArray argsVector(args.size()); + QStdVector argsVector(args.size()); for (int i = 0; i < args.size(); ++i) { const QScriptValue &arg = args.at(i); if (!arg.isValid()) { @@ -1673,7 +1671,7 @@ QScriptValue QScriptValue::construct(const QScriptValueList &args) JSC::ExecState *exec = d->engine->currentFrame; - QVarLengthArray argsVector(args.size()); + QStdVector argsVector(args.size()); for (int i = 0; i < args.size(); ++i) { QScriptValue arg = args.at(i); if (Q_UNLIKELY(QScriptValuePrivate::getEngine(arg) != d->engine && QScriptValuePrivate::getEngine(arg))) { diff --git a/src/script/bridge/qscriptqobject.cpp b/src/script/bridge/qscriptqobject.cpp index e2f384ebf..29f5e3463 100644 --- a/src/script/bridge/qscriptqobject.cpp +++ b/src/script/bridge/qscriptqobject.cpp @@ -22,10 +22,10 @@ #include "Platform.h" #include "qscriptqobject_p.h" -#include -#include -#include -#include +#include "qmetaobject.h" +#include "qstdcontainers_p.h" +#include "qdebug.h" +#include "qscriptable.h" #include "../api/qscriptengine_p.h" #include "../api/qscriptable_p.h" #include "../api/qscriptcontext_p.h" @@ -458,10 +458,10 @@ struct QScriptMetaArguments int matchDistance; int index; QScriptMetaMethod method; - QVarLengthArray args; + QStdVector args; inline QScriptMetaArguments(int dist, int idx, const QScriptMetaMethod &mtd, - const QVarLengthArray &as) + const QStdVector &as) : matchDistance(dist), index(idx), method(mtd), args(as) { } inline QScriptMetaArguments() : index(-1) { } @@ -492,7 +492,7 @@ static JSC::JSValue delegateQtMethod(JSC::ExecState *exec, QMetaMethod::MethodTy { QScriptMetaMethod chosenMethod; int chosenIndex = -1; - QVarLengthArray args; + QStdVector args; QVector candidates; QVector unresolved; QVector tooFewArgs; @@ -562,7 +562,7 @@ static JSC::JSValue delegateQtMethod(JSC::ExecState *exec, QMetaMethod::MethodTy if (!mtd.fullyResolved()) { // remember it so we can give an error message later, if necessary unresolved.append(QScriptMetaArguments(/*matchDistance=*/INT_MAX, index, - mtd, QVarLengthArray())); + mtd, QStdVector())); if (mtd.hasUnresolvedReturnType()) continue; } @@ -904,11 +904,11 @@ struct QtMethodCaller {} JSC::JSValue operator()(JSC::ExecState *exec, QMetaMethod::MethodType callType, const QMetaObject *meta, const QScriptMetaMethod &chosenMethod, - int chosenIndex, const QVarLengthArray &args) + int chosenIndex, const QStdVector &args) { JSC::JSValue result; - QVarLengthArray array(args.count()); + QStdVector array(args.count()); void **params = array.data(); for (int i = 0; i < args.count(); ++i) { const QVariant &v = args[i]; @@ -1037,7 +1037,7 @@ struct QtMethodIndexReturner { JSC::JSValue operator()(JSC::ExecState *exec, QMetaMethod::MethodType, const QMetaObject *, const QScriptMetaMethod &, - int chosenIndex, const QVarLengthArray &) + int chosenIndex, const QStdVector &) { return JSC::jsNumber(exec, chosenIndex); } @@ -2181,7 +2181,7 @@ void QObjectConnectionManager::execute(int slotIndex, void **argv) int argc = parameterTypes.count(); JSC::ExecState *exec = engine->currentFrame; - QVarLengthArray argsVector(argc); + QStdVector argsVector(argc); for (int i = 0; i < argc; ++i) { JSC::JSValue actual; void *arg = argv[i + 1]; diff --git a/src/svg/qsvghandler.cpp b/src/svg/qsvghandler.cpp index 3ed44d10c..7adf4bcd1 100644 --- a/src/svg/qsvghandler.cpp +++ b/src/svg/qsvghandler.cpp @@ -38,8 +38,8 @@ #include "qfile.h" #include "qdebug.h" #include "qnumeric.h" -#include "qvarlengtharray.h" #include "qmath.h" +#include "qstdcontainers_p.h" #include "qcorecommon_p.h" #include @@ -573,7 +573,7 @@ static QVector parseNumbersList(const QChar *&str) return points; } -static inline void parseNumbersArray(const QChar *&str, QVarLengthArray &points) +static inline void parseNumbersArray(const QChar *&str, QStdVector &points) { while (str->isSpace()) ++str; @@ -957,7 +957,7 @@ static QMatrix parseTransformationMatrix(const QStringRef &value) if (*str != QLatin1Char('(')) goto error; ++str; - QVarLengthArray points; + QStdVector points; parseNumbersArray(str, points); if (*str != QLatin1Char(')')) goto error; @@ -1387,7 +1387,7 @@ static bool parsePathDataFast(const QStringRef &dataStr, QPainterPath &path) ++str; QChar endc = *end; *const_cast(end) = 0; // parseNumbersArray requires 0-termination that QStringRef cannot guarantee - QVarLengthArray arg; + QStdVector arg; parseNumbersArray(str, arg); *const_cast(end) = endc; if (pathElem == QLatin1Char('z') || pathElem == QLatin1Char('Z')) diff --git a/src/test/qtestcase.cpp b/src/test/qtestcase.cpp index 6139feef4..cbd54b4b6 100644 --- a/src/test/qtestcase.cpp +++ b/src/test/qtestcase.cpp @@ -26,7 +26,6 @@ #include "qobject.h" #include "qstringlist.h" #include "qvector.h" -#include "qvarlengtharray.h" #include "qcoreapplication.h" #include "qfile.h" #include "qdir.h" @@ -40,6 +39,7 @@ #include "qtestresult_p.h" #include "qsignaldumper_p.h" #include "qbenchmark_p.h" +#include "qstdcontainers_p.h" #include "qcorecommon_p.h" #include @@ -1724,7 +1724,7 @@ int QTest::qExec(QObject *testObject, int argc, char **argv) int QTest::qExec(QObject *testObject, const QStringList &arguments) { const int argc = arguments.count(); - QVarLengthArray argv(argc); + QStdVector argv(argc); QVector args; args.reserve(argc); diff --git a/src/tools/qdbus/qdbuscpp2xml.cpp b/src/tools/qdbus/qdbuscpp2xml.cpp index 7f1f9b6e8..78a848378 100644 --- a/src/tools/qdbus/qdbuscpp2xml.cpp +++ b/src/tools/qdbus/qdbuscpp2xml.cpp @@ -21,7 +21,6 @@ #include #include -#include #include #include #include @@ -29,6 +28,7 @@ #include #include #include +#include "qstdcontainers_p.h" #include #include @@ -111,7 +111,7 @@ QByteArray MocParser::readLine() void MocParser::loadIntData(uint *&data) { data = 0; // initialise - QVarLengthArray array; + QStdVector array; QRegExp rx(QLatin1String("(\\d+|0x[0-9abcdef]+)"), Qt::CaseInsensitive); while (!input->atEnd()) { @@ -144,7 +144,7 @@ void MocParser::loadIntData(uint *&data) void MocParser::loadStringData(char *&stringdata) { stringdata = 0; - QVarLengthArray array; + QStdVector array; while (!input->atEnd()) { QByteArray line = readLine(); diff --git a/src/tools/uic/cpp/cppwriteincludes.cpp b/src/tools/uic/cpp/cppwriteincludes.cpp index 0025d7ddd..8c8793e49 100644 --- a/src/tools/uic/cpp/cppwriteincludes.cpp +++ b/src/tools/uic/cpp/cppwriteincludes.cpp @@ -532,7 +532,6 @@ static const struct ClassTblData { { QLatin1String("QUrl"), QLatin1String("QtCore/qurl.h") }, { QLatin1String("QVBoxLayout"), QLatin1String("QtGui/qboxlayout.h") }, { QLatin1String("QValidator"), QLatin1String("QtGui/qvalidator.h") }, - { QLatin1String("QVarLengthArray"), QLatin1String("QtCore/qvarlengtharray.h") }, { QLatin1String("QVariant"), QLatin1String("QtCore/qvariant.h") }, { QLatin1String("QVariantAnimation"), QLatin1String("QtGui/qvariantanimation.h") }, { QLatin1String("QVector"), QLatin1String("QtCore/qvector.h") }, diff --git a/tests/auto/qdbusthreading/tst_qdbusthreading.cpp b/tests/auto/qdbusthreading/tst_qdbusthreading.cpp index 86609794f..50f19d764 100644 --- a/tests/auto/qdbusthreading/tst_qdbusthreading.cpp +++ b/tests/auto/qdbusthreading/tst_qdbusthreading.cpp @@ -21,7 +21,6 @@ #include #include -#include #include #include #include @@ -176,9 +175,9 @@ Thread::Thread(bool automatic) void Thread::run() { - QVarLengthArray name; + QByteArray name; name.append(QTest::currentTestFunction(), qstrlen(QTest::currentTestFunction())); - name.append("_thread", sizeof "_thread"); + name.append("_thread", sizeof("_thread")); QMetaObject::invokeMethod(tst_QDBusThreading::self(), name.constData(), Qt::DirectConnection); } diff --git a/tests/auto/qvarlengtharray/CMakeLists.txt b/tests/auto/qvarlengtharray/CMakeLists.txt deleted file mode 100644 index 9b010ed75..000000000 --- a/tests/auto/qvarlengtharray/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -katie_test(tst_qvarlengtharray - ${CMAKE_CURRENT_SOURCE_DIR}/tst_qvarlengtharray.cpp -) diff --git a/tests/auto/qvarlengtharray/tst_qvarlengtharray.cpp b/tests/auto/qvarlengtharray/tst_qvarlengtharray.cpp deleted file mode 100644 index 4ac7340b1..000000000 --- a/tests/auto/qvarlengtharray/tst_qvarlengtharray.cpp +++ /dev/null @@ -1,591 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Copyright (C) 2016 Ivailo Monev -** -** This file is part of the test suite of the Katie Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#include -#include -#include - -//TESTED_CLASS= -//TESTED_FILES= - -class tst_QVarLengthArray : public QObject -{ - Q_OBJECT - -public: - tst_QVarLengthArray() {} - virtual ~tst_QVarLengthArray() {} - -private slots: - void append(); - void removeLast(); - void oldTests(); - void task214223(); - void QTBUG6718_resize(); - void QTBUG10978_realloc(); -}; - -int fooCtor = 0; -int fooDtor = 0; - -struct Foo -{ - int *p; - - Foo() { p = new int; ++fooCtor; } - Foo(const Foo &/*other*/) { p = new int; ++fooCtor; } - - void operator=(const Foo & /* other */) { } - - ~Foo() { delete p; ++fooDtor; } -}; - -void tst_QVarLengthArray::append() -{ - QVarLengthArray v; - v.append(QString("hello")); - QCOMPARE(v.at(0), QString("hello")); - v.append(QString("hello2")); - QCOMPARE(v.at(1), QString("hello2")); - - QVarLengthArray v2; // rocket! - v2.append(5); - QCOMPARE(v2.at(0), 5); - v2.append(10); - QCOMPARE(v2.at(1), 10); -} - -void tst_QVarLengthArray::removeLast() -{ - { - QVarLengthArray v; - v.append(0); - v.append(1); - QCOMPARE(v.size(), 2); - v.append(2); - v.append(3); - QCOMPARE(v.size(), 4); - v.removeLast(); - QCOMPARE(v.size(), 3); - v.removeLast(); - QCOMPARE(v.size(), 2); - } - - { - QVarLengthArray v; - v.append("0"); - v.append("1"); - QCOMPARE(v.size(), 2); - v.append("2"); - v.append("3"); - QCOMPARE(v.size(), 4); - v.removeLast(); - QCOMPARE(v.size(), 3); - v.removeLast(); - QCOMPARE(v.size(), 2); - } -} - -void tst_QVarLengthArray::oldTests() -{ - { - QVarLengthArray sa(128); - QVERIFY(sa.data() == &sa[0]); - sa[0] = 0xfee; - sa[10] = 0xff; - QVERIFY(sa[0] == 0xfee); - QVERIFY(sa[10] == 0xff); - sa.resize(512); - QVERIFY(sa.data() == &sa[0]); - QVERIFY(sa[0] == 0xfee); - QVERIFY(sa[10] == 0xff); - QVERIFY(sa.at(0) == 0xfee); - QVERIFY(sa.at(10) == 0xff); - QVERIFY(sa.value(0) == 0xfee); - QVERIFY(sa.value(10) == 0xff); - QVERIFY(sa.value(1000) == 0); - QVERIFY(sa.value(1000, 12) == 12); - QVERIFY(sa.size() == 512); - sa.reserve(1024); - QVERIFY(sa.capacity() == 1024); - QVERIFY(sa.size() == 512); - } - { - QVarLengthArray sa(10); - sa[0] = "Hello"; - sa[9] = "World"; - QVERIFY(*sa.data() == "Hello"); - QVERIFY(sa[9] == "World"); - sa.reserve(512); - QVERIFY(*sa.data() == "Hello"); - QVERIFY(sa[9] == "World"); - sa.resize(512); - QVERIFY(*sa.data() == "Hello"); - QVERIFY(sa[9] == "World"); - } - { - int arr[2] = {1, 2}; - QVarLengthArray sa(10); - QCOMPARE(sa.size(), 10); - sa.append(arr, 2); - QCOMPARE(sa.size(), 12); - QCOMPARE(sa[10], 1); - QCOMPARE(sa[11], 2); - } - { - QString arr[2] = { QString("hello"), QString("world") }; - QVarLengthArray sa(10); - QCOMPARE(sa.size(), 10); - sa.append(arr, 2); - QCOMPARE(sa.size(), 12); - QCOMPARE(sa[10], QString("hello")); - QCOMPARE(sa[11], QString("world")); - QCOMPARE(sa.at(10), QString("hello")); - QCOMPARE(sa.at(11), QString("world")); - QCOMPARE(sa.value(10), QString("hello")); - QCOMPARE(sa.value(11), QString("world")); - QCOMPARE(sa.value(10000), QString()); - QCOMPARE(sa.value(1212112, QString("none")), QString("none")); - QCOMPARE(sa.value(-12, QString("neg")), QString("neg")); - - sa.append(arr, 1); - QCOMPARE(sa.size(), 13); - QCOMPARE(sa[12], QString("hello")); - - sa.append(arr, 0); - QCOMPARE(sa.size(), 13); - } - { - // assignment operator and copy constructor - - QVarLengthArray sa(10); - sa[5] = 5; - - QVarLengthArray sa2(10); - sa2[5] = 6; - sa2 = sa; - QCOMPARE(sa2[5], 5); - - QVarLengthArray sa3(sa); - QCOMPARE(sa3[5], 5); - } - - QSKIP("This test causes the machine to crash when allocating too much memory.", SkipSingle); - { - QVarLengthArray a; - const int N = 0x7fffffff / sizeof(Foo); - const int Prealloc = a.capacity(); - const Foo *data0 = a.constData(); - - a.resize(N); - if (a.size() == N) { - QVERIFY(a.capacity() >= N); - QCOMPARE(fooCtor, N); - QCOMPARE(fooDtor, 0); - - for (int i = 0; i < N; i += 35000) - a[i] = Foo(); - } else { - // this is the case we're actually testing - QCOMPARE(a.size(), 0); - QCOMPARE(a.capacity(), Prealloc); - QCOMPARE(a.constData(), data0); - QCOMPARE(fooCtor, 0); - QCOMPARE(fooDtor, 0); - - a.resize(5); - QCOMPARE(a.size(), 5); - QCOMPARE(a.capacity(), Prealloc); - QCOMPARE(a.constData(), data0); - QCOMPARE(fooCtor, 5); - QCOMPARE(fooDtor, 0); - - a.resize(Prealloc + 1); - QCOMPARE(a.size(), Prealloc + 1); - QVERIFY(a.capacity() >= Prealloc + 1); - QVERIFY(a.constData() != data0); - QCOMPARE(fooCtor, Prealloc + 6); - QCOMPARE(fooDtor, 5); - - const Foo *data1 = a.constData(); - - a.resize(0x10000000); - QCOMPARE(a.size(), 0); - QVERIFY(a.capacity() >= Prealloc + 1); - QVERIFY(a.constData() == data1); - QCOMPARE(fooCtor, Prealloc + 6); - QCOMPARE(fooDtor, Prealloc + 6); - } - } -} - -void tst_QVarLengthArray::task214223() -{ - //creating a QVarLengthArray of the same size as the prealloc size - // will make the next call to append(const T&) corrupt the memory - // you should get a segfault pretty soon after that :-) - QVarLengthArray d(1); - for (int i=0; i<30; i++) - d.append(i); -} - -void tst_QVarLengthArray::QTBUG6718_resize() -{ - //MOVABLE - { - QVarLengthArray values(1); - QCOMPARE(values.size(), 1); - values[0] = 1; - values.resize(2); - QCOMPARE(values[1], QVariant()); - QCOMPARE(values[0], QVariant(1)); - values[1] = 2; - QCOMPARE(values[1], QVariant(2)); - QCOMPARE(values.size(), 2); - } - - //POD - { - QVarLengthArray values(1); - QCOMPARE(values.size(), 1); - values[0] = 1; - values.resize(2); - QCOMPARE(values[0], 1); - values[1] = 2; - QCOMPARE(values[1], 2); - QCOMPARE(values.size(), 2); - } - - //COMPLEX - { - QVarLengthArray> values(1); - QCOMPARE(values.size(), 1); - values[0].resize(10); - values.resize(2); - QCOMPARE(values[1].size(), 0); - QCOMPARE(values[0].size(), 10); - values[1].resize(20); - QCOMPARE(values[1].size(), 20); - QCOMPARE(values.size(), 2); - } -} - -struct MyBase -{ - MyBase() - : data(this) - , isCopy(false) - { - ++liveCount; - } - - MyBase(MyBase const &) - : data(this) - , isCopy(true) - { - ++copyCount; - ++liveCount; - } - - MyBase & operator=(MyBase const &) - { - if (!isCopy) { - isCopy = true; - ++copyCount; - } else { - ++errorCount; - } - - return *this; - } - - ~MyBase() - { - if (isCopy) { - if (!copyCount) - ++errorCount; - else - --copyCount; - } - - if (!liveCount) - ++errorCount; - else - --liveCount; - } - - bool hasMoved() const - { - return this != data; - } - -protected: - MyBase const * const data; - bool isCopy; - -public: - static int errorCount; - static int liveCount; - static int copyCount; -}; - -int MyBase::errorCount = 0; -int MyBase::liveCount = 0; -int MyBase::copyCount = 0; - -struct MyPrimitive - : MyBase -{ - MyPrimitive() - { - ++errorCount; - } - - ~MyPrimitive() - { - ++errorCount; - } - - MyPrimitive(MyPrimitive const &other) - : MyBase(other) - { - ++errorCount; - } -}; - -struct MyMovable - : MyBase -{ -}; - -struct MyComplex - : MyBase -{ -}; - -QT_BEGIN_NAMESPACE - -Q_DECLARE_TYPEINFO(MyPrimitive, Q_PRIMITIVE_TYPE); -Q_DECLARE_TYPEINFO(MyMovable, Q_MOVABLE_TYPE); -Q_DECLARE_TYPEINFO(MyComplex, Q_COMPLEX_TYPE); - -QT_END_NAMESPACE - -bool QTBUG10978_proceed = true; - -template -int countMoved(QVarLengthArray const &c) -{ - int result = 0; - for (int i = 0; i < c.size(); ++i) - if (c[i].hasMoved()) - ++result; - - return result; -} - -template -void QTBUG10978_test() -{ - QTBUG10978_proceed = false; - - typedef QVarLengthArray Container; - enum { - isStatic = QTypeInfo::isStatic, - isComplex = QTypeInfo::isComplex, - - isPrimitive = !isComplex && !isStatic, - isMovable = !isStatic - }; - - // Constructors - Container a; - QCOMPARE( MyBase::liveCount, 0 ); - QCOMPARE( MyBase::copyCount, 0 ); - - QVERIFY( a.capacity() >= 16 ); - QCOMPARE( a.size(), 0 ); - - Container b_real(8); - Container const &b = b_real; - QCOMPARE( MyBase::liveCount, isPrimitive ? 0 : 8 ); - QCOMPARE( MyBase::copyCount, 0 ); - - QVERIFY( b.capacity() >= 16 ); - QCOMPARE( b.size(), 8 ); - - // Assignment - a = b; - QCOMPARE( MyBase::liveCount, isPrimitive ? 0 : 16 ); - QCOMPARE( MyBase::copyCount, isComplex ? 8 : 0 ); - QVERIFY( a.capacity() >= 16 ); - QCOMPARE( a.size(), 8 ); - - QVERIFY( b.capacity() >= 16 ); - QCOMPARE( b.size(), 8 ); - - // append - a.append(b.data(), b.size()); - QCOMPARE( MyBase::liveCount, isPrimitive ? 0 : 24 ); - QCOMPARE( MyBase::copyCount, isComplex ? 16 : 0 ); - - QVERIFY( a.capacity() >= 16 ); - QCOMPARE( a.size(), 16 ); - - QVERIFY( b.capacity() >= 16 ); - QCOMPARE( b.size(), 8 ); - - // removeLast - a.removeLast(); - QCOMPARE( MyBase::liveCount, isPrimitive ? 0 : 23 ); - QCOMPARE( MyBase::copyCount, isComplex ? 15 : 0 ); - - QVERIFY( a.capacity() >= 16 ); - QCOMPARE( a.size(), 15 ); - - QVERIFY( b.capacity() >= 16 ); - QCOMPARE( b.size(), 8 ); - - // Movable types - const int capacity = a.capacity(); - if (!isPrimitive) - QCOMPARE( countMoved(a), 0 ); - - // Reserve, no re-allocation - a.reserve(capacity); - if (!isPrimitive) - QCOMPARE( countMoved(a), 0 ); - QCOMPARE( MyBase::liveCount, isPrimitive ? 0 : 23 ); - QCOMPARE( MyBase::copyCount, isComplex ? 15 : 0 ); - - QCOMPARE( a.capacity(), capacity ); - QCOMPARE( a.size(), 15 ); - - QVERIFY( b.capacity() >= 16 ); - QCOMPARE( b.size(), 8 ); - - // Reserve, force re-allocation - a.reserve(capacity * 2); - if (!isPrimitive) - QCOMPARE( countMoved(a), isMovable ? 15 : 0 ); - QCOMPARE( MyBase::liveCount, isPrimitive ? 0 : 23 ); - QCOMPARE( MyBase::copyCount, isComplex ? 15 : 0 ); - - QVERIFY( a.capacity() >= capacity * 2 ); - QCOMPARE( a.size(), 15 ); - - QVERIFY( b.capacity() >= 16 ); - QCOMPARE( b.size(), 8 ); - - // resize, grow - a.resize(40); - if (!isPrimitive) - QCOMPARE( countMoved(a), isMovable ? 15 : 0 ); - QCOMPARE( MyBase::liveCount, isPrimitive ? 0 : 48 ); - QCOMPARE( MyBase::copyCount, isComplex ? 15 : 0 ); - - QVERIFY( a.capacity() >= a.size() ); - QCOMPARE( a.size(), 40 ); - - QVERIFY( b.capacity() >= 16 ); - QCOMPARE( b.size(), 8 ); - - // Copy constructor, allocate - { - Container c(a); - if (!isPrimitive) - QCOMPARE( countMoved(c), 0 ); - QCOMPARE( MyBase::liveCount, isPrimitive ? 0 : 88 ); - QCOMPARE( MyBase::copyCount, isComplex ? 55 : 0 ); - - QVERIFY( a.capacity() >= a.size() ); - QCOMPARE( a.size(), 40 ); - - QVERIFY( b.capacity() >= 16 ); - QCOMPARE( b.size(), 8 ); - - QVERIFY( c.capacity() >= 40 ); - QCOMPARE( c.size(), 40 ); - } - - // resize, shrink - a.resize(10); - if (!isPrimitive) - QCOMPARE( countMoved(a), isMovable ? 10 : 0 ); - QCOMPARE( MyBase::liveCount, isPrimitive ? 0 : 18 ); - QCOMPARE( MyBase::copyCount, isComplex ? 10 : 0 ); - - QVERIFY( a.capacity() >= a.size() ); - QCOMPARE( a.size(), 10 ); - - QVERIFY( b.capacity() >= 16 ); - QCOMPARE( b.size(), 8 ); - - // Copy constructor, don't allocate - { - Container c(a); - if (!isPrimitive) - QCOMPARE( countMoved(c), 0 ); - QCOMPARE( MyBase::liveCount, isPrimitive ? 0 : 28 ); - QCOMPARE( MyBase::copyCount, isComplex ? 20 : 0 ); - - QVERIFY( a.capacity() >= a.size() ); - QCOMPARE( a.size(), 10 ); - - QVERIFY( b.capacity() >= 16 ); - QCOMPARE( b.size(), 8 ); - - QVERIFY( c.capacity() >= 16 ); - QCOMPARE( c.size(), 10 ); - } - - a.clear(); - QCOMPARE( a.size(), 0 ); - - b_real.clear(); - QCOMPARE( b.size(), 0 ); - - QCOMPARE(MyBase::errorCount, 0); - QCOMPARE(MyBase::liveCount, 0); - - // All done - QTBUG10978_proceed = true; -} - -void tst_QVarLengthArray::QTBUG10978_realloc() -{ - QTBUG10978_test(); - QVERIFY(QTBUG10978_proceed); - - QTBUG10978_test(); - QVERIFY(QTBUG10978_proceed); - - QTBUG10978_test(); - QVERIFY(QTBUG10978_proceed); - - QTBUG10978_test(); - QVERIFY(QTBUG10978_proceed); -} - -QTEST_APPLESS_MAIN(tst_QVarLengthArray) - -#include "moc_tst_qvarlengtharray.cpp" diff --git a/tests/benchmarks/core/io/qdir/tree/4.6.0-list.txt b/tests/benchmarks/core/io/qdir/tree/4.6.0-list.txt index 6c5a1f318..890152b09 100644 --- a/tests/benchmarks/core/io/qdir/tree/4.6.0-list.txt +++ b/tests/benchmarks/core/io/qdir/tree/4.6.0-list.txt @@ -8209,8 +8209,6 @@ qtools_p.h qunicodetables.cpp qunicodetables_p.h - qvarlengtharray.h - qvarlengtharray.qdoc qvector.cpp qvector.h qvsnprintf.cpp diff --git a/tests/benchmarks/gui/graphicsview/qgraphicsview/chiptester/chip.cpp b/tests/benchmarks/gui/graphicsview/qgraphicsview/chiptester/chip.cpp index 5ef258304..c99c5deab 100644 --- a/tests/benchmarks/gui/graphicsview/qgraphicsview/chiptester/chip.cpp +++ b/tests/benchmarks/gui/graphicsview/qgraphicsview/chiptester/chip.cpp @@ -21,7 +21,7 @@ #include "chip.h" -#include "QtCore/qvarlengtharray.h" +#include #include Chip::Chip(const QColor &color, int x, int y) @@ -102,7 +102,7 @@ void Chip::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWid } // Draw lines - QVarLengthArray lines; + QVector lines; if (option->levelOfDetail >= 0.5) { for (int i = 0; i <= 10; i += (option->levelOfDetail > 0.5 ? 1 : 2)) { lines.append(QLineF(18 + 7 * i, 13, 18 + 7 * i, 5)); -- 2.11.0