From 5b17fb14282822de36efd924abff8e3555e2491f Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Thu, 17 Mar 2016 10:01:25 +0100 Subject: Doc: Make the replacement functions for obsoleted functions explicit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I3a4bd3b4fcfd253b63fe342da6e398a4aeaf6825 Reviewed-by: Topi Reiniƶ --- src/corelib/tools/qstring.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/corelib/tools') diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index cdf37cca07..10d3441d2c 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -5820,7 +5820,9 @@ QString QString::toUpper_helper(QString &str) } /*! - \obsolete Use asprintf(), arg() or QTextStream instead. + \obsolete + + Use asprintf(), arg() or QTextStream instead. */ QString &QString::sprintf(const char *cformat, ...) { @@ -5876,7 +5878,9 @@ QString QString::asprintf(const char *cformat, ...) } /*! - \obsolete Use vasprintf(), arg() or QTextStream instead. + \obsolete + + Use vasprintf(), arg() or QTextStream instead. */ QString &QString::vsprintf(const char *cformat, va_list ap) { @@ -10487,7 +10491,7 @@ float QStringRef::toFloat(bool *ok) const \obsolete \fn QString Qt::escape(const QString &plain) - \sa QString::toHtmlEscaped() + Use QString::toHtmlEscaped() instead. */ /*! -- cgit v1.2.3 From ee22fe13cda74c5ef5ee7b6db1b75d2837e43672 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Mon, 18 Jan 2016 13:00:32 +0100 Subject: QDateTimeParser::parse(): improve readability A switch (was inconsistent about whether enum members need casts and) made it less obvious, rather than more, what was going on; so changed it to a nested if. Change-Id: I9af322d9dd17aa08cac5003eff2c8eaa73b50d45 Reviewed-by: Marc Mutz --- src/corelib/tools/qdatetimeparser.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'src/corelib/tools') diff --git a/src/corelib/tools/qdatetimeparser.cpp b/src/corelib/tools/qdatetimeparser.cpp index 8e3eaf7074..cc09992b88 100644 --- a/src/corelib/tools/qdatetimeparser.cpp +++ b/src/corelib/tools/qdatetimeparser.cpp @@ -977,22 +977,17 @@ QDateTimeParser::StateNode QDateTimeParser::parse(QString &input, int &cursorPos if (state != Invalid) { if (parserType != QVariant::Time) { - if (year % 100 != year2digits) { - switch (isSet & (YearSection2Digits|YearSection)) { - case YearSection2Digits: + if (year % 100 != year2digits && (isSet & YearSection2Digits)) { + if (!(isSet & YearSection)) { year = (year / 100) * 100; year += year2digits; - break; - case ((uint)YearSection2Digits|(uint)YearSection): { + } else { conflicts = true; const SectionNode &sn = sectionNode(currentSectionIndex); if (sn.type == YearSection2Digits) { year = (year / 100) * 100; year += year2digits; } - break; } - default: - break; } } -- cgit v1.2.3 From c671e66802b75b511ad85347c70f6193134d81ca Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Mon, 18 Jan 2016 17:14:17 +0100 Subject: QDateTimeParser: mediate QLocale's meddling via a setter. The former has (for now) nothing private, so QLocale got away with setting its .defaultLocale explicitly; provide a setter method by which it can do that, to allow scope for later encapsulation. Change-Id: I77fc5fc8f868fc7cf8d51eb1c5d18926c61cbf78 Reviewed-by: Marc Mutz --- src/corelib/tools/qdatetimeparser_p.h | 1 + src/corelib/tools/qlocale.cpp | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'src/corelib/tools') diff --git a/src/corelib/tools/qdatetimeparser_p.h b/src/corelib/tools/qdatetimeparser_p.h index 257cb6e2cc..d6c4d615db 100644 --- a/src/corelib/tools/qdatetimeparser_p.h +++ b/src/corelib/tools/qdatetimeparser_p.h @@ -218,6 +218,7 @@ public: FieldInfo fieldInfo(int index) const; + void setDefaultLocale(const QLocale &loc) { defaultLocale = loc; } virtual QDateTime getMinimum() const; virtual QDateTime getMaximum() const; virtual int cursorPosition() const { return -1; } diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index 890a8fb95d..72a6668bd3 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -1834,7 +1834,7 @@ QTime QLocale::toTime(const QString &string, const QString &format) const QTime time; #ifndef QT_BOOTSTRAPPED QDateTimeParser dt(QVariant::Time, QDateTimeParser::FromString); - dt.defaultLocale = *this; + dt.setDefaultLocale(*this); if (dt.parseFormat(format)) dt.fromString(string, 0, &time); #else @@ -1865,7 +1865,7 @@ QDate QLocale::toDate(const QString &string, const QString &format) const QDate date; #ifndef QT_BOOTSTRAPPED QDateTimeParser dt(QVariant::Date, QDateTimeParser::FromString); - dt.defaultLocale = *this; + dt.setDefaultLocale(*this); if (dt.parseFormat(format)) dt.fromString(string, &date, 0); #else @@ -1898,7 +1898,7 @@ QDateTime QLocale::toDateTime(const QString &string, const QString &format) cons QDate date; QDateTimeParser dt(QVariant::DateTime, QDateTimeParser::FromString); - dt.defaultLocale = *this; + dt.setDefaultLocale(*this); if (dt.parseFormat(format) && dt.fromString(string, &date, &time)) return QDateTime(date, time); #else -- cgit v1.2.3 From fd5720af2cb1e641c433c73fd977c8ba9d278305 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Wed, 20 Jan 2016 09:42:34 +0100 Subject: QDateTimeParser: new Section mask values simplify code. Various |s of existing section flags were used repeatedly; naming these masks makes the relevant code easier to read. In QDateTimeEdit, add a comment to make clear that its Section enum is based on QDTP's. Change-Id: Ifd8364cd396a6d0d5ed7ae7dc4d31690f77edd30 Reviewed-by: Marc Mutz --- src/corelib/tools/qdatetimeparser.cpp | 18 +++++++++++------- src/corelib/tools/qdatetimeparser_p.h | 12 +++++++++--- 2 files changed, 20 insertions(+), 10 deletions(-) (limited to 'src/corelib/tools') diff --git a/src/corelib/tools/qdatetimeparser.cpp b/src/corelib/tools/qdatetimeparser.cpp index cc09992b88..180f76bcc1 100644 --- a/src/corelib/tools/qdatetimeparser.cpp +++ b/src/corelib/tools/qdatetimeparser.cpp @@ -159,7 +159,7 @@ bool QDateTimeParser::setDigit(QDateTime &v, int index, int newVal) const break; } - if (!(node.type & (DaySection|DayOfWeekSectionShort|DayOfWeekSectionLong))) { + if (!(node.type & DaySectionMask)) { if (day < cachedDay) day = cachedDay; const int max = QDate(year, month, 1).daysInMonth(); @@ -625,6 +625,10 @@ int QDateTimeParser::sectionMaxSize(Section s, int count) const case Internal: case TimeSectionMask: case DateSectionMask: + case HourSectionMask: + case YearSectionMask: + case DayOfWeekSectionMask: + case DaySectionMask: qWarning("QDateTimeParser::sectionMaxSize: Invalid section %s", SectionNode::name(s).toLatin1().constData()); @@ -993,12 +997,11 @@ QDateTimeParser::StateNode QDateTimeParser::parse(QString &input, int &cursorPos const QDate date(year, month, day); const int diff = dayofweek - date.dayOfWeek(); - if (diff != 0 && state == Acceptable - && isSet & (DayOfWeekSectionShort | DayOfWeekSectionLong)) { + if (diff != 0 && state == Acceptable && isSet & DayOfWeekSectionMask) { if (isSet & DaySection) conflicts = true; const SectionNode &sn = sectionNode(currentSectionIndex); - if (sn.type & (DayOfWeekSectionShort|DayOfWeekSectionLong) || currentSectionIndex == -1) { + if (sn.type & DayOfWeekSectionMask || currentSectionIndex == -1) { // dayofweek should be preferred day += diff; if (day <= 0) { @@ -1010,8 +1013,9 @@ QDateTimeParser::StateNode QDateTimeParser::parse(QString &input, int &cursorPos << diff << QDate(year, month, day).dayOfWeek(); } } + bool needfixday = false; - if (sectionType(currentSectionIndex) & (DaySection|DayOfWeekSectionShort|DayOfWeekSectionLong)) { + if (sectionType(currentSectionIndex) & DaySectionMask) { cachedDay = day; } else if (cachedDay > day) { day = cachedDay; @@ -1039,7 +1043,7 @@ QDateTimeParser::StateNode QDateTimeParser::parse(QString &input, int &cursorPos const SectionNode sn = sectionNode(i); if (sn.type & DaySection) { input.replace(sectionPos(sn), sectionSize(i), loc.toString(day)); - } else if (sn.type & (DayOfWeekSectionShort | DayOfWeekSectionLong)) { + } else if (sn.type & DayOfWeekSectionMask) { const int dayOfWeek = QDate(year, month, day).dayOfWeek(); const QLocale::FormatType dayFormat = (sn.type == DayOfWeekSectionShort @@ -1296,7 +1300,7 @@ int QDateTimeParser::findDay(const QString &str1, int startDay, int sectionIndex int bestCount = 0; if (!str1.isEmpty()) { const SectionNode &sn = sectionNode(sectionIndex); - if (!(sn.type & (DaySection|DayOfWeekSectionShort|DayOfWeekSectionLong))) { + if (!(sn.type & DaySectionMask)) { qWarning("QDateTimeParser::findDay Internal error"); return -1; } diff --git a/src/corelib/tools/qdatetimeparser_p.h b/src/corelib/tools/qdatetimeparser_p.h index d6c4d615db..90c6a8acba 100644 --- a/src/corelib/tools/qdatetimeparser_p.h +++ b/src/corelib/tools/qdatetimeparser_p.h @@ -114,14 +114,20 @@ public: MinuteSection = 0x00008, Hour12Section = 0x00010, Hour24Section = 0x00020, - TimeSectionMask = (AmPmSection|MSecSection|SecondSection|MinuteSection|Hour12Section|Hour24Section), + HourSectionMask = (Hour12Section | Hour24Section), + TimeSectionMask = (MSecSection | SecondSection | MinuteSection | + HourSectionMask | AmPmSection), + DaySection = 0x00100, MonthSection = 0x00200, YearSection = 0x00400, YearSection2Digits = 0x00800, + YearSectionMask = YearSection | YearSection2Digits, DayOfWeekSectionShort = 0x01000, DayOfWeekSectionLong = 0x02000, - DateSectionMask = (DaySection|MonthSection|YearSection|YearSection2Digits|DayOfWeekSectionShort|DayOfWeekSectionLong), + DayOfWeekSectionMask = DayOfWeekSectionShort | DayOfWeekSectionLong, + DaySectionMask = DaySection | DayOfWeekSectionMask, + DateSectionMask = DaySectionMask | MonthSection | YearSectionMask, Internal = 0x10000, FirstSection = 0x20000 | Internal, @@ -132,7 +138,7 @@ public: FirstSectionIndex = -2, LastSectionIndex = -3, CalendarPopupIndex = -4 - }; // duplicated from qdatetimeedit.h + }; // extending qdatetimeedit.h's equivalent Q_DECLARE_FLAGS(Sections, Section) struct Q_CORE_EXPORT SectionNode { -- cgit v1.2.3 From 093eec6fedd46d4065056376c5d9b56deb249fae Mon Sep 17 00:00:00 2001 From: Andreas Holzammer Date: Thu, 24 Mar 2016 16:22:33 +0100 Subject: wince: Fix intrinsics for X86 platforms when SSE2 is enabled SSE2 can use intrinsics, which are supported by WEC2013, but for WEC7 they need to be defined. Change-Id: I261f3db4db7abcb0b59598cef9cbad404635c3ec Reviewed-by: Friedemann Kleint Reviewed-by: Gunnar Roth Reviewed-by: Kevin Funk Reviewed-by: Lars Knoll --- src/corelib/tools/qsimd_p.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/corelib/tools') diff --git a/src/corelib/tools/qsimd_p.h b/src/corelib/tools/qsimd_p.h index 8171184ad2..ca53908cf5 100644 --- a/src/corelib/tools/qsimd_p.h +++ b/src/corelib/tools/qsimd_p.h @@ -432,7 +432,13 @@ static inline quint64 qCpuFeatures() #ifdef Q_PROCESSOR_X86 // Bit scan functions for x86 -# if defined(Q_CC_MSVC) && !defined(Q_OS_WINCE) +# if defined(Q_CC_MSVC) +# if defined _WIN32_WCE && _WIN32_WCE < 0x800 +extern "C" unsigned char _BitScanForward(unsigned long* Index, unsigned long Mask); +extern "C" unsigned char _BitScanReverse(unsigned long* Index, unsigned long Mask); +# pragma intrinsic(_BitScanForward) +# pragma intrinsic(_BitScanReverse) +# endif // MSVC calls it _BitScanReverse and returns the carry flag, which we don't need static __forceinline unsigned long _bit_scan_reverse(uint val) { -- cgit v1.2.3 From 045e417eff0a0efabd15d22361af7e6dff5f44f4 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sun, 3 Apr 2016 13:02:47 +0200 Subject: [doc] QElapsedTimer: mention more clearly which functions cause undefined behavior Change-Id: Ic7ab0d81689e2cc78f39f5f32beaea74ca10ce38 Reviewed-by: Giuseppe D'Angelo Reviewed-by: Friedemann Kleint Reviewed-by: Olivier Goffart (Woboq GmbH) Reviewed-by: Thiago Macieira --- src/corelib/tools/qelapsedtimer_generic.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'src/corelib/tools') diff --git a/src/corelib/tools/qelapsedtimer_generic.cpp b/src/corelib/tools/qelapsedtimer_generic.cpp index 210d372e15..8679aec810 100644 --- a/src/corelib/tools/qelapsedtimer_generic.cpp +++ b/src/corelib/tools/qelapsedtimer_generic.cpp @@ -79,7 +79,8 @@ void QElapsedTimer::start() Q_DECL_NOTHROW and then starting the timer again with start(), but it does so in one single operation, avoiding the need to obtain the clock value twice. - Restarting the timer makes it valid again. + Calling this function on a QElapsedTimer that is invalid + results in undefined behavior. The following example illustrates how to use this function to calibrate a parameter to a slow operation (for example, an iteration count) so that @@ -87,7 +88,7 @@ void QElapsedTimer::start() Q_DECL_NOTHROW \snippet qelapsedtimer/main.cpp 3 - \sa start(), invalidate(), elapsed() + \sa start(), invalidate(), elapsed(), isValid() */ qint64 QElapsedTimer::restart() Q_DECL_NOTHROW { @@ -100,8 +101,10 @@ qint64 QElapsedTimer::restart() Q_DECL_NOTHROW /*! \since 4.8 Returns the number of nanoseconds since this QElapsedTimer was last - started. Calling this function in a QElapsedTimer that was invalidated - will result in undefined results. + started. + + Calling this function on a QElapsedTimer that is invalid + results in undefined behavior. On platforms that do not provide nanosecond resolution, the value returned will be the best estimate available. @@ -115,10 +118,12 @@ qint64 QElapsedTimer::nsecsElapsed() const Q_DECL_NOTHROW /*! Returns the number of milliseconds since this QElapsedTimer was last - started. Calling this function in a QElapsedTimer that was invalidated - will result in undefined results. + started. - \sa start(), restart(), hasExpired(), invalidate() + Calling this function on a QElapsedTimer that is invalid + results in undefined behavior. + + \sa start(), restart(), hasExpired(), isValid(), invalidate() */ qint64 QElapsedTimer::elapsed() const Q_DECL_NOTHROW { @@ -166,7 +171,8 @@ qint64 QElapsedTimer::msecsTo(const QElapsedTimer &other) const Q_DECL_NOTHROW \a other was started before this object, the returned value will be negative. If it was started later, the returned value will be positive. - The return value is undefined if this object or \a other were invalidated. + Calling this function on or with a QElapsedTimer that is invalid + results in undefined behavior. \sa msecsTo(), elapsed() */ -- cgit v1.2.3 From 10758c5af244c6e7eb53b280d35198311cd548ce Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 6 Apr 2016 13:26:12 +0200 Subject: Mark some QByteArray relational operators nothrow Specifically, those that compare UTF-8 octet-streams: - QByteArray <-> QByteArray - QByteArray <-> const char* For more, Qt first needs to gain a nothrow UTF-8 <-> UTF-16 comparator. Change-Id: Ibccbdcdc3ebed5b1ac0e65c971f6f7d1bd15b6da Reviewed-by: Thiago Macieira --- src/corelib/tools/qbytearray.h | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'src/corelib/tools') diff --git a/src/corelib/tools/qbytearray.h b/src/corelib/tools/qbytearray.h index a53d4eabd3..d334bb43c5 100644 --- a/src/corelib/tools/qbytearray.h +++ b/src/corelib/tools/qbytearray.h @@ -604,41 +604,41 @@ inline bool QByteArray::contains(const QByteArray &a) const { return indexOf(a) != -1; } inline bool QByteArray::contains(char c) const { return indexOf(c) != -1; } -inline bool operator==(const QByteArray &a1, const QByteArray &a2) +inline bool operator==(const QByteArray &a1, const QByteArray &a2) Q_DECL_NOTHROW { return (a1.size() == a2.size()) && (memcmp(a1.constData(), a2.constData(), a1.size())==0); } -inline bool operator==(const QByteArray &a1, const char *a2) +inline bool operator==(const QByteArray &a1, const char *a2) Q_DECL_NOTHROW { return a2 ? qstrcmp(a1,a2) == 0 : a1.isEmpty(); } -inline bool operator==(const char *a1, const QByteArray &a2) +inline bool operator==(const char *a1, const QByteArray &a2) Q_DECL_NOTHROW { return a1 ? qstrcmp(a1,a2) == 0 : a2.isEmpty(); } -inline bool operator!=(const QByteArray &a1, const QByteArray &a2) +inline bool operator!=(const QByteArray &a1, const QByteArray &a2) Q_DECL_NOTHROW { return !(a1==a2); } -inline bool operator!=(const QByteArray &a1, const char *a2) +inline bool operator!=(const QByteArray &a1, const char *a2) Q_DECL_NOTHROW { return a2 ? qstrcmp(a1,a2) != 0 : !a1.isEmpty(); } -inline bool operator!=(const char *a1, const QByteArray &a2) +inline bool operator!=(const char *a1, const QByteArray &a2) Q_DECL_NOTHROW { return a1 ? qstrcmp(a1,a2) != 0 : !a2.isEmpty(); } -inline bool operator<(const QByteArray &a1, const QByteArray &a2) +inline bool operator<(const QByteArray &a1, const QByteArray &a2) Q_DECL_NOTHROW { return qstrcmp(a1, a2) < 0; } - inline bool operator<(const QByteArray &a1, const char *a2) + inline bool operator<(const QByteArray &a1, const char *a2) Q_DECL_NOTHROW { return qstrcmp(a1, a2) < 0; } -inline bool operator<(const char *a1, const QByteArray &a2) +inline bool operator<(const char *a1, const QByteArray &a2) Q_DECL_NOTHROW { return qstrcmp(a1, a2) < 0; } -inline bool operator<=(const QByteArray &a1, const QByteArray &a2) +inline bool operator<=(const QByteArray &a1, const QByteArray &a2) Q_DECL_NOTHROW { return qstrcmp(a1, a2) <= 0; } -inline bool operator<=(const QByteArray &a1, const char *a2) +inline bool operator<=(const QByteArray &a1, const char *a2) Q_DECL_NOTHROW { return qstrcmp(a1, a2) <= 0; } -inline bool operator<=(const char *a1, const QByteArray &a2) +inline bool operator<=(const char *a1, const QByteArray &a2) Q_DECL_NOTHROW { return qstrcmp(a1, a2) <= 0; } -inline bool operator>(const QByteArray &a1, const QByteArray &a2) +inline bool operator>(const QByteArray &a1, const QByteArray &a2) Q_DECL_NOTHROW { return qstrcmp(a1, a2) > 0; } -inline bool operator>(const QByteArray &a1, const char *a2) +inline bool operator>(const QByteArray &a1, const char *a2) Q_DECL_NOTHROW { return qstrcmp(a1, a2) > 0; } -inline bool operator>(const char *a1, const QByteArray &a2) +inline bool operator>(const char *a1, const QByteArray &a2) Q_DECL_NOTHROW { return qstrcmp(a1, a2) > 0; } -inline bool operator>=(const QByteArray &a1, const QByteArray &a2) +inline bool operator>=(const QByteArray &a1, const QByteArray &a2) Q_DECL_NOTHROW { return qstrcmp(a1, a2) >= 0; } -inline bool operator>=(const QByteArray &a1, const char *a2) +inline bool operator>=(const QByteArray &a1, const char *a2) Q_DECL_NOTHROW { return qstrcmp(a1, a2) >= 0; } -inline bool operator>=(const char *a1, const QByteArray &a2) +inline bool operator>=(const char *a1, const QByteArray &a2) Q_DECL_NOTHROW { return qstrcmp(a1, a2) >= 0; } #if !defined(QT_USE_QSTRINGBUILDER) inline const QByteArray operator+(const QByteArray &a1, const QByteArray &a2) -- cgit v1.2.3 From f083830b8de106ed51d39242008215e9ea2179b2 Mon Sep 17 00:00:00 2001 From: Anton Kudryavtsev Date: Wed, 13 Apr 2016 14:45:11 +0300 Subject: CoreLib: use const (and const APIs) more For CoW types const methods will be called. Mark store_persistent_indexes() as const, because this method does not modify the object. Change-Id: Ic867913b4fb5aaebfbaaffe1d3be45cf7b646403 Reviewed-by: Thiago Macieira --- src/corelib/tools/qcommandlineparser.cpp | 7 ++++--- src/corelib/tools/qeasingcurve.cpp | 2 +- src/corelib/tools/qlocale_unix.cpp | 2 +- src/corelib/tools/qringbuffer.cpp | 12 ++++++------ src/corelib/tools/qtimezoneprivate_mac.mm | 2 +- 5 files changed, 13 insertions(+), 12 deletions(-) (limited to 'src/corelib/tools') diff --git a/src/corelib/tools/qcommandlineparser.cpp b/src/corelib/tools/qcommandlineparser.cpp index 6587d900d2..a7ab8b9e70 100644 --- a/src/corelib/tools/qcommandlineparser.cpp +++ b/src/corelib/tools/qcommandlineparser.cpp @@ -887,7 +887,8 @@ QStringList QCommandLineParser::values(const QString &optionName) const bool QCommandLineParser::isSet(const QCommandLineOption &option) const { // option.names() might be empty if the constructor failed - return !option.names().isEmpty() && isSet(option.names().first()); + const auto names = option.names(); + return !names.isEmpty() && isSet(names.first()); } /*! @@ -905,7 +906,7 @@ bool QCommandLineParser::isSet(const QCommandLineOption &option) const */ QString QCommandLineParser::value(const QCommandLineOption &option) const { - return value(option.names().first()); + return value(option.names().constFirst()); } /*! @@ -923,7 +924,7 @@ QString QCommandLineParser::value(const QCommandLineOption &option) const */ QStringList QCommandLineParser::values(const QCommandLineOption &option) const { - return values(option.names().first()); + return values(option.names().constFirst()); } /*! diff --git a/src/corelib/tools/qeasingcurve.cpp b/src/corelib/tools/qeasingcurve.cpp index 2851dc81d6..4b5f5e7830 100644 --- a/src/corelib/tools/qeasingcurve.cpp +++ b/src/corelib/tools/qeasingcurve.cpp @@ -444,7 +444,7 @@ struct BezierEase : public QEasingCurveFunction void init() { - if (_bezierCurves.last() == QPointF(1.0, 1.0)) { + if (_bezierCurves.constLast() == QPointF(1.0, 1.0)) { _init = true; _curveCount = _bezierCurves.count() / 3; diff --git a/src/corelib/tools/qlocale_unix.cpp b/src/corelib/tools/qlocale_unix.cpp index 9b0d338e46..095001e0a3 100644 --- a/src/corelib/tools/qlocale_unix.cpp +++ b/src/corelib/tools/qlocale_unix.cpp @@ -122,7 +122,7 @@ QLocale QSystemLocale::fallbackUiLocale() const // the first part of LANGUAGE if LANGUAGE is set and has a first part: QByteArray language = qgetenv("LANGUAGE"); if (!language.isEmpty()) { - language = language.split(':').first(); + language = language.split(':').constFirst(); if (!language.isEmpty()) return QLocale(QString::fromLatin1(language)); } diff --git a/src/corelib/tools/qringbuffer.cpp b/src/corelib/tools/qringbuffer.cpp index db2004dfd9..4a2dfdec2b 100644 --- a/src/corelib/tools/qringbuffer.cpp +++ b/src/corelib/tools/qringbuffer.cpp @@ -74,14 +74,14 @@ void QRingBuffer::free(qint64 bytes) Q_ASSERT(bytes <= bufferSize); while (bytes > 0) { - const qint64 blockSize = buffers.first().size() - head; + const qint64 blockSize = buffers.constFirst().size() - head; if (tailBuffer == 0 || blockSize > bytes) { // keep a single block around if it does not exceed // the basic block size, to avoid repeated allocations // between uses of the buffer if (bufferSize <= bytes) { - if (buffers.first().size() <= basicBlockSize) { + if (buffers.constFirst().size() <= basicBlockSize) { bufferSize = 0; head = tail = 0; } else { @@ -114,8 +114,8 @@ char *QRingBuffer::reserve(qint64 bytes) } else { const qint64 newSize = bytes + tail; // if need buffer reallocation - if (newSize > buffers.last().size()) { - if (newSize > buffers.last().capacity() && (tail >= basicBlockSize + if (newSize > buffers.constLast().size()) { + if (newSize > buffers.constLast().capacity() && (tail >= basicBlockSize || newSize >= MaxByteArraySize)) { // shrink this buffer to its current size buffers.last().resize(tail); @@ -180,7 +180,7 @@ void QRingBuffer::chop(qint64 bytes) // the basic block size, to avoid repeated allocations // between uses of the buffer if (bufferSize <= bytes) { - if (buffers.first().size() <= basicBlockSize) { + if (buffers.constFirst().size() <= basicBlockSize) { bufferSize = 0; head = tail = 0; } else { @@ -198,7 +198,7 @@ void QRingBuffer::chop(qint64 bytes) bytes -= tail; buffers.removeLast(); --tailBuffer; - tail = buffers.last().size(); + tail = buffers.constLast().size(); } } diff --git a/src/corelib/tools/qtimezoneprivate_mac.mm b/src/corelib/tools/qtimezoneprivate_mac.mm index 14b0523ca7..3a665c2b00 100644 --- a/src/corelib/tools/qtimezoneprivate_mac.mm +++ b/src/corelib/tools/qtimezoneprivate_mac.mm @@ -243,7 +243,7 @@ QTimeZonePrivate::Data QMacTimeZonePrivate::previousTransition(qint64 beforeMSec } } if (secsList.size() >= 1) - return data(qint64(secsList.last()) * 1000); + return data(qint64(secsList.constLast()) * 1000); else return invalidData(); } -- cgit v1.2.3