diff options
author | Tor Arne Vestbø <tor.arne.vestbo@digia.com> | 2012-10-19 09:53:42 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@digia.com> | 2012-10-19 09:54:12 +0200 |
commit | 55a36aed7935984846db2342e37160057cb3bec8 (patch) | |
tree | b84f611333fe9ec6ecda62c9ea47f954f59bc394 /src/corelib | |
parent | a9a87deb685600aebd9ed1cec82ad668afca88d9 (diff) | |
parent | 734324c37cb9d8417aa86f76fc81dadc21be2156 (diff) |
Merge remote-tracking branch 'gerrit/master' into newdocs
Change-Id: If7f46d56cf0b0b79f7fc8955a01964121b900d07
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/doc/snippets/code/src_corelib_plugin_quuid.cpp | 2 | ||||
-rw-r--r-- | src/corelib/doc/snippets/pointer/pointer.cpp | 3 | ||||
-rw-r--r-- | src/corelib/global/global.pri | 1 | ||||
-rw-r--r-- | src/corelib/global/qlogging.cpp | 6 | ||||
-rw-r--r-- | src/corelib/global/qlogging.h | 5 | ||||
-rw-r--r-- | src/corelib/itemmodels/qitemselectionmodel.cpp | 6 | ||||
-rw-r--r-- | src/corelib/kernel/qeventdispatcher_blackberry.cpp | 104 | ||||
-rw-r--r-- | src/corelib/kernel/qpointer.cpp | 10 | ||||
-rw-r--r-- | src/corelib/kernel/qtranslator.cpp | 2 | ||||
-rw-r--r-- | src/corelib/plugin/quuid.cpp | 30 | ||||
-rw-r--r-- | src/corelib/thread/qresultstore.h | 5 | ||||
-rw-r--r-- | src/corelib/tools/qarraydata.h | 12 | ||||
-rw-r--r-- | src/corelib/tools/qchar.cpp | 54 | ||||
-rw-r--r-- | src/corelib/tools/qcontiguouscache.cpp | 11 | ||||
-rw-r--r-- | src/corelib/tools/qcontiguouscache.h | 6 | ||||
-rw-r--r-- | src/corelib/tools/qdatetime.cpp | 1 | ||||
-rw-r--r-- | src/corelib/tools/qregularexpression.cpp | 4 | ||||
-rw-r--r-- | src/corelib/tools/qvector.h | 11 |
18 files changed, 185 insertions, 88 deletions
diff --git a/src/corelib/doc/snippets/code/src_corelib_plugin_quuid.cpp b/src/corelib/doc/snippets/code/src_corelib_plugin_quuid.cpp index 662ce35054..34c81189c1 100644 --- a/src/corelib/doc/snippets/code/src_corelib_plugin_quuid.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_plugin_quuid.cpp @@ -40,5 +40,5 @@ //! [0] // {67C8770B-44F1-410A-AB9A-F9B5446F13EE} -QUuid IID_MyInterface(0x67c8770b, 0x44f1, 0x410a, 0xab, 0x9a, 0xf9, 0xb5, 0x44, 0x6f, 0x13, 0xee) +QUuid IID_MyInterface(0x67c8770b, 0x44f1, 0x410a, 0xab, 0x9a, 0xf9, 0xb5, 0x44, 0x6f, 0x13, 0xee); //! [0] diff --git a/src/corelib/doc/snippets/pointer/pointer.cpp b/src/corelib/doc/snippets/pointer/pointer.cpp index 31b4959651..503f2dfccd 100644 --- a/src/corelib/doc/snippets/pointer/pointer.cpp +++ b/src/corelib/doc/snippets/pointer/pointer.cpp @@ -53,7 +53,8 @@ int main(int argc, char *argv[]) //! [1] if (label) -//! [1] //! [2] +//! [1] +//! [2] label->show(); //! [2] return 0; diff --git a/src/corelib/global/global.pri b/src/corelib/global/global.pri index 05a2461f1b..01756c8419 100644 --- a/src/corelib/global/global.pri +++ b/src/corelib/global/global.pri @@ -9,6 +9,7 @@ HEADERS += \ global/qendian.h \ global/qnumeric_p.h \ global/qnumeric.h \ + global/qlibraryinfo.h \ global/qlogging.h \ global/qtypeinfo.h \ global/qsysinfo.h \ diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index 13bbdbead0..e4ff7eece4 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -780,6 +780,12 @@ Q_CORE_EXPORT QString qMessageFormatString(QtMsgType type, const QMessageLogCont return message; } +#if !QT_DEPRECATED_SINCE(5, 0) +// make sure they're defined to be exported +typedef void (*QtMsgHandler)(QtMsgType, const char *); +Q_CORE_EXPORT QtMsgHandler qInstallMsgHandler(QtMsgHandler); +#endif + static QtMsgHandler msgHandler = 0; // pointer to debug handler (without context) static QtMessageHandler messageHandler = 0; // pointer to debug handler (with context) diff --git a/src/corelib/global/qlogging.h b/src/corelib/global/qlogging.h index 0c92e71ad6..4a4eb26321 100644 --- a/src/corelib/global/qlogging.h +++ b/src/corelib/global/qlogging.h @@ -161,9 +161,10 @@ Q_CORE_EXPORT void qt_message_output(QtMsgType, const QMessageLogContext &contex Q_CORE_EXPORT void qErrnoWarning(int code, const char *msg, ...); Q_CORE_EXPORT void qErrnoWarning(const char *msg, ...); -// deprecated. Use qInstallMessageHandler instead! +#if QT_DEPRECATED_SINCE(5, 0)// deprecated. Use qInstallMessageHandler instead! typedef void (*QtMsgHandler)(QtMsgType, const char *); -Q_CORE_EXPORT QtMsgHandler qInstallMsgHandler(QtMsgHandler); +Q_CORE_EXPORT QT_DEPRECATED QtMsgHandler qInstallMsgHandler(QtMsgHandler); +#endif typedef void (*QtMessageHandler)(QtMsgType, const QMessageLogContext &, const QString &); Q_CORE_EXPORT QtMessageHandler qInstallMessageHandler(QtMessageHandler); diff --git a/src/corelib/itemmodels/qitemselectionmodel.cpp b/src/corelib/itemmodels/qitemselectionmodel.cpp index 74bc0e6a9d..4b9391d285 100644 --- a/src/corelib/itemmodels/qitemselectionmodel.cpp +++ b/src/corelib/itemmodels/qitemselectionmodel.cpp @@ -853,12 +853,18 @@ static QItemSelection mergeIndexes(const QVector<QPersistentModelIndex> &indexes int i = 0; while (i < indexes.count()) { const QPersistentModelIndex &tl = indexes.at(i); + if (!tl.isValid()) { + ++i; + continue; + } QPersistentModelIndex br = tl; QModelIndex brParent = br.parent(); int brRow = br.row(); int brColumn = br.column(); while (++i < indexes.count()) { const QPersistentModelIndex &next = indexes.at(i); + if (!next.isValid()) + continue; const QModelIndex nextParent = next.parent(); const int nextRow = next.row(); const int nextColumn = next.column(); diff --git a/src/corelib/kernel/qeventdispatcher_blackberry.cpp b/src/corelib/kernel/qeventdispatcher_blackberry.cpp index 33ca1023dd..b2ec574c89 100644 --- a/src/corelib/kernel/qeventdispatcher_blackberry.cpp +++ b/src/corelib/kernel/qeventdispatcher_blackberry.cpp @@ -243,28 +243,6 @@ void QEventDispatcherBlackberry::unregisterSocketNotifier(QSocketNotifier *notif } } -static inline bool updateTimeout(int *timeout, const struct timeval &start) -{ - // A timeout of -1 means we should block indefinitely. If we get here, we got woken up by a - // non-IO BPS event, and that event has been processed already. This means we can go back and - // block in bps_get_event(). - // Note that processing the BPS event might have triggered a wakeup, in that case we get a - // IO event in the next bps_get_event() right away. - if (*timeout == -1) - return true; - - if (Q_UNLIKELY(!QElapsedTimer::isMonotonic())) { - // we cannot recalculate the timeout without a monotonic clock as the time may have changed - return false; - } - - // clock source is monotonic, so we can recalculate how much timeout is left - timeval t2 = qt_gettime(); - int elapsed = (t2.tv_sec * 1000 + t2.tv_usec / 1000) - (start.tv_sec * 1000 + start.tv_usec / 1000); - *timeout -= elapsed; - return *timeout >= 0; -} - int QEventDispatcherBlackberry::select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, timeval *timeout) { @@ -291,60 +269,70 @@ int QEventDispatcherBlackberry::select(int nfds, fd_set *readfds, fd_set *writef FD_ZERO(exceptfds); // Convert timeout to milliseconds - int timeout_bps = -1; + int timeoutTotal = -1; if (timeout) - timeout_bps = (timeout->tv_sec * 1000) + (timeout->tv_usec / 1000); + timeoutTotal = (timeout->tv_sec * 1000) + (timeout->tv_usec / 1000); + + int timeoutLeft = timeoutTotal; - bool hasProcessedEventsOnce = false; bps_event_t *event = 0; + unsigned int eventCount = 0; // This loop exists such that we can drain the bps event queue of all native events // more efficiently than if we were to return control to Qt after each event. This // is important for handling touch events which can come in rapidly. forever { - Q_ASSERT(!hasProcessedEventsOnce || event); - - // Only emit the awake() and aboutToBlock() signals in the second iteration. For the first - // iteration, the UNIX event dispatcher will have taken care of that already. - if (hasProcessedEventsOnce) - emit awake(); - - // Filtering the native event should happen between the awake() and aboutToBlock() signal - // emissions. The calls awake() - filterNativeEvent() - aboutToBlock() - bps_get_event() - // need not to be interrupted by a break or return statement. - // - // Because of this, the native event is actually processed one loop iteration - // after it was retrieved with bps_get_event(). - if (event) - filterNativeEvent(QByteArrayLiteral("bps_event_t"), static_cast<void*>(event), 0); - - if (hasProcessedEventsOnce) - emit aboutToBlock(); + // Only emit the awake() and aboutToBlock() signals in the second iteration. For the + // first iteration, the UNIX event dispatcher will have taken care of that already. + // Also native events are actually processed one loop iteration after they were + // retrieved with bps_get_event(). + + // Filtering the native event should happen between the awake() and aboutToBlock() + // signal emissions. The calls awake() - filterNativeEvent() - aboutToBlock() - + // bps_get_event() need not to be interrupted by a break or return statement. + if (eventCount > 0) { + if (event) { + emit awake(); + filterNativeEvent(QByteArrayLiteral("bps_event_t"), static_cast<void*>(event), 0); + emit aboutToBlock(); + } + + // Update the timeout + // Clock source is monotonic, so we can recalculate how much timeout is left + if (timeoutTotal != -1) { + timeval t2 = qt_gettime(); + timeoutLeft = timeoutTotal - ((t2.tv_sec * 1000 + t2.tv_usec / 1000) + - (startTime.tv_sec * 1000 + startTime.tv_usec / 1000)); + if (timeoutLeft < 0) + timeoutLeft = 0; + } + } // Wait for event or file to be ready event = 0; - const int result = bps_get_event(&event, timeout_bps); + const int result = bps_get_event(&event, timeoutLeft); if (result != BPS_SUCCESS) qWarning("QEventDispatcherBlackberry::select: bps_get_event() failed"); - // In the case of !event, we break out of the loop to let Qt process the timers - // that are now ready (since timeout has expired). - // In the case of bpsIOReadyDomain, we break out to let Qt process the FDs that - // are ready. If we do not do this activation of QSocketNotifiers etc would be - // delayed. - if (!event || bps_event_get_domain(event) == bpsIOReadyDomain) - break; + if (!event) // In case of !event, we break out of the loop to let Qt process the timers + break; // (since timeout has expired) and socket notifiers that are now ready. - // Update the timeout. If this fails we have exceeded our alloted time or the system - // clock has changed time and we cannot calculate a new timeout so we bail out. - if (!updateTimeout(&timeout_bps, startTime)) { + if (bps_event_get_domain(event) == bpsIOReadyDomain) { + timeoutTotal = 0; // in order to immediately drain the event queue of native events + event = 0; // (especially touch move events) we don't break out here + } + + ++eventCount; - // No more loop iteration, so we need to filter the event here. - filterNativeEvent(QByteArrayLiteral("bps_event_t"), static_cast<void*>(event), 0); + // Make sure we are not trapped in this loop due to continuous native events + // also we cannot recalculate the timeout without a monotonic clock as the time may have changed + const unsigned int maximumEventCount = 12; + if (Q_UNLIKELY((eventCount > maximumEventCount && timeoutLeft == 0) + || !QElapsedTimer::isMonotonic())) { + if (event) + filterNativeEvent(QByteArrayLiteral("bps_event_t"), static_cast<void*>(event), 0); break; } - - hasProcessedEventsOnce = true; } // the number of bits set in the file sets diff --git a/src/corelib/kernel/qpointer.cpp b/src/corelib/kernel/qpointer.cpp index 48710bb70c..b774b36592 100644 --- a/src/corelib/kernel/qpointer.cpp +++ b/src/corelib/kernel/qpointer.cpp @@ -123,7 +123,7 @@ /*! \fn QPointer::QPointer(T* p) - Constructs a guarded pointer that points to same object that \a p + Constructs a guarded pointer that points to the same object that \a p points to. */ @@ -273,3 +273,11 @@ \a p2 are not pointing to the same object, otherwise returns false. */ +/*! + \fn QPointer<T> qPointerFromVariant(const QVariant &variant) + + \internal + + Returns a guarded pointer that points to the same object that + \a variant holds. +*/ diff --git a/src/corelib/kernel/qtranslator.cpp b/src/corelib/kernel/qtranslator.cpp index 6d9133529a..c4486d3ae6 100644 --- a/src/corelib/kernel/qtranslator.cpp +++ b/src/corelib/kernel/qtranslator.cpp @@ -695,7 +695,7 @@ static QString find_translation(const QLocale & locale, \li File name with ui language part stripped further, etc. \endlist - For example, an application running in the locale with the following + For example, an application running in the \a locale with the following \l{QLocale::uiLanguages()}{ui languages} - "es", "fr-CA", "de" might call load(QLocale::system(), "foo", ".", "/opt/foolib", ".qm"). load() would replace '-' (dash) with '_' (underscore) in the ui language and then try to diff --git a/src/corelib/plugin/quuid.cpp b/src/corelib/plugin/quuid.cpp index 445f707a73..c1ebc57cf6 100644 --- a/src/corelib/plugin/quuid.cpp +++ b/src/corelib/plugin/quuid.cpp @@ -181,7 +181,7 @@ static QUuid createFromName(const QUuid &ns, const QByteArray &baseData, QCrypto are in use. Each UUID contains a bit field that specifies which type (variant) of UUID it is. Call variant() to discover which type of UUID an instance of QUuid contains. It extracts the three - most signifcant bits of byte 8 of the 16 bytes. In QUuid, byte 8 + most significant bits of byte 8 of the 16 bytes. In QUuid, byte 8 is \c{QUuid::data4[0]}. If you create instances of QUuid using the constructor that accepts all the numeric values as parameters, use the following table to set the three most significant bits of @@ -428,7 +428,17 @@ QUuid::QUuid(const QByteArray &text) \since 5.0 \fn QUuid QUuid::createUuidV3(const QUuid &ns, const QByteArray &baseData); - This functions returns a new UUID with variant QUuid::DCE and version QUuid::Md5. + This function returns a new UUID with variant QUuid::DCE and version QUuid::Md5. + \a ns is the namespace and \a baseData is the basic data as described by RFC 4122. + + \sa variant(), version(), createUuidV5() +*/ + +/*! + \since 5.0 + \fn QUuid QUuid::createUuidV3(const QUuid &ns, const QString &baseData); + + This function returns a new UUID with variant QUuid::DCE and version QUuid::Md5. \a ns is the namespace and \a baseData is the basic data as described by RFC 4122. \sa variant(), version(), createUuidV5() @@ -438,7 +448,17 @@ QUuid::QUuid(const QByteArray &text) \since 5.0 \fn QUuid QUuid::createUuidV5(const QUuid &ns, const QByteArray &baseData); - This functions returns a new UUID with variant QUuid::DCE and version QUuid::Sha1. + This function returns a new UUID with variant QUuid::DCE and version QUuid::Sha1. + \a ns is the namespace and \a baseData is the basic data as described by RFC 4122. + + \sa variant(), version(), createUuidV3() +*/ + +/*! + \since 5.0 + \fn QUuid QUuid::createUuidV5(const QUuid &ns, const QString &baseData); + + This function returns a new UUID with variant QUuid::DCE and version QUuid::Sha1. \a ns is the namespace and \a baseData is the basic data as described by RFC 4122. \sa variant(), version(), createUuidV3() @@ -990,6 +1010,10 @@ QUuid QUuid::createUuid() */ #ifndef QT_NO_DEBUG_STREAM +/*! + \relates QUuid + Writes the UUID \a id to the output stream for debugging information \a dbg. +*/ QDebug operator<<(QDebug dbg, const QUuid &id) { #ifndef QT_NO_QUUID_STRING diff --git a/src/corelib/thread/qresultstore.h b/src/corelib/thread/qresultstore.h index 3314cd7aaf..d084e24c0c 100644 --- a/src/corelib/thread/qresultstore.h +++ b/src/corelib/thread/qresultstore.h @@ -176,7 +176,10 @@ public: int addResults(int index, const QVector<T> *results, int totalCount) { - return ResultStoreBase::addResults(index, new QVector<T>(*results), results->count(), totalCount); + if (m_filterMode == true && results->count() != totalCount && 0 == results->count()) + return ResultStoreBase::addResults(index, 0, 0, totalCount); + else + return ResultStoreBase::addResults(index, new QVector<T>(*results), results->count(), totalCount); } int addCanceledResult(int index) diff --git a/src/corelib/tools/qarraydata.h b/src/corelib/tools/qarraydata.h index a67255ad68..7fecbbbeeb 100644 --- a/src/corelib/tools/qarraydata.h +++ b/src/corelib/tools/qarraydata.h @@ -209,12 +209,12 @@ struct QTypedArrayData T *data() { return static_cast<T *>(QArrayData::data()); } const T *data() const { return static_cast<const T *>(QArrayData::data()); } - iterator begin() { return data(); } - iterator end() { return data() + size; } - const_iterator begin() const { return data(); } - const_iterator end() const { return data() + size; } - const_iterator constBegin() const { return data(); } - const_iterator constEnd() const { return data() + size; } + iterator begin(iterator = iterator()) { return data(); } + iterator end(iterator = iterator()) { return data() + size; } + const_iterator begin(const_iterator = const_iterator()) const { return data(); } + const_iterator end(const_iterator = const_iterator()) const { return data() + size; } + const_iterator constBegin(const_iterator = const_iterator()) const { return data(); } + const_iterator constEnd(const_iterator = const_iterator()) const { return data() + size; } class AlignmentDummy { QArrayData header; T data; }; diff --git a/src/corelib/tools/qchar.cpp b/src/corelib/tools/qchar.cpp index 0a027fc229..c66962d931 100644 --- a/src/corelib/tools/qchar.cpp +++ b/src/corelib/tools/qchar.cpp @@ -121,7 +121,7 @@ QT_BEGIN_NAMESPACE isDigit() (decimal digits). All of these are wrappers around category() which return the Unicode-defined category of each character. Some of these also calculate the derived properties - (i.e. isSpace() returns true if the character is of category + (for example isSpace() returns true if the character is of category Separator_* or an exceptional code point from Other_Control category). QChar also provides direction(), which indicates the "natural" @@ -766,14 +766,14 @@ bool QT_FASTCALL QChar::isLetterOrNumber_helper(uint ucs4) \fn bool QChar::isHighSurrogate() const Returns true if the QChar is the high part of a UTF16 surrogate - (i.e. if its code point is in range [0xd800..0xdbff]); false otherwise. + (for example if its code point is in range [0xd800..0xdbff]); false otherwise. */ /*! \fn bool QChar::isLowSurrogate() const Returns true if the QChar is the low part of a UTF16 surrogate - (i.e. if its code point is in range [0xdc00..0xdfff]); false otherwise. + (for example if its code point is in range [0xdc00..0xdfff]); false otherwise. */ /*! @@ -782,7 +782,7 @@ bool QT_FASTCALL QChar::isLetterOrNumber_helper(uint ucs4) Returns true if the QChar contains a code point that is in either the high or the low part of the UTF-16 surrogate range - (i.e. if its code point is in range [0xd800..0xdfff]); false otherwise. + (for example if its code point is in range [0xd800..0xdfff]); false otherwise. */ /*! @@ -806,7 +806,7 @@ bool QT_FASTCALL QChar::isLetterOrNumber_helper(uint ucs4) Returns true if the UCS-4-encoded character specified by \a ucs4 is the high part of a UTF16 surrogate - (i.e. if its code point is in range [0xd800..0xdbff]); false otherwise. + (for example if its code point is in range [0xd800..0xdbff]); false otherwise. */ /*! @@ -815,7 +815,7 @@ bool QT_FASTCALL QChar::isLetterOrNumber_helper(uint ucs4) Returns true if the UCS-4-encoded character specified by \a ucs4 is the low part of a UTF16 surrogate - (i.e. if its code point is in range [0xdc00..0xdfff]); false otherwise. + (for example if its code point is in range [0xdc00..0xdfff]); false otherwise. */ /*! @@ -825,7 +825,7 @@ bool QT_FASTCALL QChar::isLetterOrNumber_helper(uint ucs4) Returns true if the UCS-4-encoded character specified by \a ucs4 contains a code point that is in either the high or the low part of the - UTF-16 surrogate range (i.e. if its code point is in range [0xd800..0xdfff]); + UTF-16 surrogate range (for example if its code point is in range [0xd800..0xdfff]); false otherwise. */ @@ -834,7 +834,7 @@ bool QT_FASTCALL QChar::isLetterOrNumber_helper(uint ucs4) Returns true if the UCS-4-encoded character specified by \a ucs4 can be split into the high and low parts of a UTF16 surrogate - (i.e. if its code point is greater than or equals to 0x10000); + (for example if its code point is greater than or equals to 0x10000); false otherwise. */ @@ -969,31 +969,63 @@ bool QChar::hasMirrored(uint ucs4) /*! \fn bool QChar::isLower() const - Returns true if the character is a lowercase letter, i.e. + Returns true if the character is a lowercase letter, for example category() is Letter_Lowercase. \sa isUpper(), toLower(), toUpper() */ /*! + \fn static bool QChar::isLower(uint ucs4) + \overload + \since 5.0 + + Returns true if the UCS-4-encoded character specified by \a ucs4 + is a lowercase letter, for example category() is Letter_Lowercase. + + \sa isUpper(), toLower(), toUpper() +*/ + +/*! \fn bool QChar::isUpper() const - Returns true if the character is an uppercase letter, i.e. + Returns true if the character is an uppercase letter, for example category() is Letter_Uppercase. \sa isLower(), toUpper(), toLower() */ /*! + \fn static bool QChar::isUpper(uint ucs4) + \overload + \since 5.0 + + Returns true if the UCS-4-encoded character specified by \a ucs4 + is an uppercase letter, for example category() is Letter_Uppercase. + + \sa isLower(), toUpper(), toLower() +*/ + +/*! \fn bool QChar::isTitleCase() const - Returns true if the character is a titlecase letter, i.e. + Returns true if the character is a titlecase letter, for example category() is Letter_Titlecase. \sa isLower(), toUpper(), toLower(), toTitleCase() */ /*! + \fn static bool QChar::isTitleCase(uint ucs4) + \overload + \since 5.0 + + Returns true if the UCS-4-encoded character specified by \a ucs4 + is a titlecase letter, for example category() is Letter_Titlecase. + + \sa isLower(), toUpper(), toLower(), toTitleCase() +*/ +/*! \fn QChar QChar::mirroredChar() const Returns the mirrored character if this character is a mirrored diff --git a/src/corelib/tools/qcontiguouscache.cpp b/src/corelib/tools/qcontiguouscache.cpp index 3e325bec59..40edb0fa58 100644 --- a/src/corelib/tools/qcontiguouscache.cpp +++ b/src/corelib/tools/qcontiguouscache.cpp @@ -80,8 +80,15 @@ void QContiguousCacheData::freeData(QContiguousCacheData *data) of matching how user interface views most commonly request data, as a set of rows localized around the current scrolled position. This restriction allows the cache to consume less memory and processor - cycles than QCache. The QContiguousCache class also can provide - an upper bound on memory usage via setCapacity(). + cycles than QCache. + + QContiguousCache operates on a fixed capacity, set with setCapacity() or + passed as a parameter to the constructor. This capacity is the upper bound + on memory usage by the cache itself, not including the memory allocated by + the elements themselves. Note that a cache with a capacity of zero (the + default) means no items will be stored: the insert(), append() and + prepend() operations will effectively be no-ops. Therefore, it's important + to set the capacity to a reasonable value before adding items to the cache. The simplest way of using a contiguous cache is to use the append() and prepend(). diff --git a/src/corelib/tools/qcontiguouscache.h b/src/corelib/tools/qcontiguouscache.h index 8713a3407a..e1cc65f10a 100644 --- a/src/corelib/tools/qcontiguouscache.h +++ b/src/corelib/tools/qcontiguouscache.h @@ -341,6 +341,8 @@ void QContiguousCache<T>::freeData(Data *x) template <typename T> void QContiguousCache<T>::append(const T &value) { + if (!d->alloc) + return; // zero capacity detach(); if (QTypeInfo<T>::isComplex) { if (d->count == d->alloc) @@ -362,6 +364,8 @@ void QContiguousCache<T>::append(const T &value) template<typename T> void QContiguousCache<T>::prepend(const T &value) { + if (!d->alloc) + return; // zero capacity detach(); if (d->start) d->start--; @@ -385,6 +389,8 @@ template<typename T> void QContiguousCache<T>::insert(int pos, const T &value) { Q_ASSERT_X(pos >= 0 && pos < INT_MAX, "QContiguousCache<T>::insert", "index out of range"); + if (!d->alloc) + return; // zero capacity detach(); if (containsIndex(pos)) { if (QTypeInfo<T>::isComplex) { diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index cbdd183f33..a9d3095224 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -847,6 +847,7 @@ QString QDate::toString(const QString& format) const If \a y is in the range 0 to 99, it is interpreted as 1900 to 1999. + Returns \c false if the date is invalid. Use setDate() instead. */ diff --git a/src/corelib/tools/qregularexpression.cpp b/src/corelib/tools/qregularexpression.cpp index 5436d1f94a..5c6b3ff044 100644 --- a/src/corelib/tools/qregularexpression.cpp +++ b/src/corelib/tools/qregularexpression.cpp @@ -2345,7 +2345,9 @@ static const char *pcreCompileErrorCodes[] = QT_TRANSLATE_NOOP("QRegularExpression", "\\N is not supported in a class"), QT_TRANSLATE_NOOP("QRegularExpression", "too many forward references"), QT_TRANSLATE_NOOP("QRegularExpression", "disallowed Unicode code point (>= 0xd800 && <= 0xdfff)"), - QT_TRANSLATE_NOOP("QRegularExpression", "invalid UTF-16 string") + QT_TRANSLATE_NOOP("QRegularExpression", "invalid UTF-16 string"), + QT_TRANSLATE_NOOP("QRegularExpression", "name is too long in (*MARK), (*PRUNE), (*SKIP), or (*THEN)"), + QT_TRANSLATE_NOOP("QRegularExpression", "character value in \\u.... sequence is too large") }; #endif // #if 0 diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index c0ae048322..925ad17110 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -151,6 +151,7 @@ public: // STL-style typedef typename Data::iterator iterator; typedef typename Data::const_iterator const_iterator; +#if !defined(QT_STRICT_ITERATORS) || defined(Q_QDOC) inline iterator begin() { detach(); return d->begin(); } inline const_iterator begin() const { return d->constBegin(); } inline const_iterator cbegin() const { return d->constBegin(); } @@ -159,6 +160,16 @@ public: inline const_iterator end() const { return d->constEnd(); } inline const_iterator cend() const { return d->constEnd(); } inline const_iterator constEnd() const { return d->constEnd(); } +#else + inline iterator begin(iterator = iterator()) { detach(); return d->begin(); } + inline const_iterator begin(const_iterator = const_iterator()) const { return d->constBegin(); } + inline const_iterator cbegin(const_iterator = const_iterator()) const { return d->constBegin(); } + inline const_iterator constBegin(const_iterator = const_iterator()) const { return d->constBegin(); } + inline iterator end(iterator = iterator()) { detach(); return d->end(); } + inline const_iterator end(const_iterator = const_iterator()) const { return d->constEnd(); } + inline const_iterator cend(const_iterator = const_iterator()) const { return d->constEnd(); } + inline const_iterator constEnd(const_iterator = const_iterator()) const { return d->constEnd(); } +#endif 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); |