From b3e2c69cc2de4fdf3fd19fbe11517459aa61aa17 Mon Sep 17 00:00:00 2001 From: Michele Caini Date: Thu, 11 Oct 2012 23:19:50 +0200 Subject: Review of documentation. Documentation has been updated, changes apply to Qt5 as well as Qt4. Change-Id: I692869971bafffabbb9c323dc031f6d984c1adb9 Reviewed-by: Stephen Kelly Reviewed-by: Frederik Gladhorn --- src/corelib/doc/snippets/pointer/pointer.cpp | 3 ++- src/corelib/kernel/qpointer.cpp | 10 +++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'src/corelib') 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/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 qPointerFromVariant(const QVariant &variant) + + \internal + + Returns a guarded pointer that points to the same object that + \a variant holds. +*/ -- cgit v1.2.3 From e0ad6e5f7dd644c35baeb5ee714b5abfae2696da Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Tue, 16 Oct 2012 13:05:42 +0200 Subject: Add documentation for ucs4 overloads. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ibacd8f260950db195a17cffe8396e8460f227eb9 Reviewed-by: Jan Arve Sæther --- src/corelib/tools/qchar.cpp | 54 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 43 insertions(+), 11 deletions(-) (limited to 'src/corelib') 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,30 +969,62 @@ 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 -- cgit v1.2.3 From 8fdef974b7014212947fc409543847d97ec7d5b9 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Tue, 18 Sep 2012 09:57:51 +0200 Subject: Logging: Mark deprecated API with QT_DEPRECATED Still use it in qtestlib though because using qInstallMessageHandler here would break all tests (still) using qInstallMsgHandler - Qt always uses the new message handler if there's one, ignoring any message handler installed through deprecated API. Change-Id: I6fefefb315a2421425d2b7787e367fd348a33d83 Reviewed-by: Thiago Macieira --- src/corelib/global/qlogging.cpp | 6 ++++++ src/corelib/global/qlogging.h | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'src/corelib') 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); -- cgit v1.2.3 From 08748f147b44983d9155baa420b84423aec43e1d Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Tue, 16 Oct 2012 12:58:32 +0200 Subject: Add parameter documentation. Change-Id: I8ce85bbb286c3cb844ef600daa5e99432ee55b74 Reviewed-by: Jerome Pasion --- src/corelib/kernel/qtranslator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') 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 -- cgit v1.2.3 From a0280e5cac5b4f268c20e89a1c2d0364c323a7cf Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 15 Oct 2012 13:48:07 -0700 Subject: Add qlibraryinfo.h to global.pri's HEADERS list The file was already present but wasn't mentioned. Change-Id: Icac4fd5276b071ed2173e72aed51abb4c0b5b50a Reviewed-by: Oswald Buddenhagen --- src/corelib/global/global.pri | 1 + 1 file changed, 1 insertion(+) (limited to 'src/corelib') 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 \ -- cgit v1.2.3 From 6039179373f7552c2a711b06a7d69b9ca9d2b175 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Str=C3=B8mme?= Date: Tue, 16 Oct 2012 11:34:00 +0200 Subject: Fix for memory leak in ResultStore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In ResultStoreBase::addResults() it possible that the ResultItem we create is invalid (filter-mode enabled). Since an invalid ResultItem won't have any result data, we need to make sure that we don't allocate any data for it. Task-number: QTBUG-27224 Change-Id: Ic99b191db0e9dd4e29b64911f87d90a8148bb7a5 Reviewed-by: Morten Johan Sørvig --- src/corelib/thread/qresultstore.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/corelib') 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 *results, int totalCount) { - return ResultStoreBase::addResults(index, new QVector(*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(*results), results->count(), totalCount); } int addCanceledResult(int index) -- cgit v1.2.3 From e75be9f30e88f0bef361144887fb36a30079cb7d Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Fri, 6 Jul 2012 11:37:26 +0100 Subject: Add new error strings to QRegularExpression They are introduced in PCRE 8.31. Change-Id: Id0447b381d5e23996d4e87ae0368b07a8bc1c318 Reviewed-by: Thiago Macieira Reviewed-by: Oswald Buddenhagen --- src/corelib/tools/qregularexpression.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/corelib') 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 -- cgit v1.2.3 From 0783b1670d5862b51747b0246a222878ff3b9c44 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Tue, 16 Oct 2012 12:57:31 +0200 Subject: Doc fix in return value of QDate::setYMD MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ie107e451a7b2a084fb6131939f212acd412a9df6 Reviewed-by: Mitch Curtis Reviewed-by: Jerome Pasion Reviewed-by: Jan Arve Sæther --- src/corelib/tools/qdatetime.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/corelib') 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. */ -- cgit v1.2.3 From ae3ad0ad211e6b9d745193fc049ad6ee07d731f0 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 17 Oct 2012 09:20:10 +0200 Subject: Handle the case where persistent indexes have gone invalid. Don't add invalid ranges to the result. They will be removed whenever d->ranges is processed for public consumption anyway. For example, QItemSelectionModel::selection() calls merge() with another selection. The merge() method removes invalid ranges already. But the invalid ranges don't need to be there in the first place, so this patch removes them. A longer-term goal is to maintain d->ranges as an always-sorted list. This method can be called with a vector containing invalid QPersistentModelIndexes when those persistent indexes are made invalid in between layoutAboutToBeChanged and layoutChanged. It's a normal thing to happen and a case that should be handled deliberately. Change-Id: I741ed9208d8a75644975c9e8d61f0d6d78e20576 Reviewed-by: Marc Mutz --- src/corelib/itemmodels/qitemselectionmodel.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/corelib') 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 &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(); -- cgit v1.2.3 From b8fe5e1bbc7f341d03d2704a6110d6e3240589bb Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 28 Sep 2012 14:02:29 +0200 Subject: Make sure functions returning iterators have an iterator as parameter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The IA-64 C++ ABI does not encode the return type for non-template functions (QVector is the template, not the function), which means that these two functions have the same signature: Node *QVector::begin() typename class QTypedArrayData::iterator QVector::begin() [both are _ZN7QVectorI4NodeE5beginEv] When linking compilation units compiled with different QT_STRICT_ITERATORS settings, only one of the two out-of-line copies will survive. Depending on the ABI, we may have a problem: the ABI can say that a function returning a structure takes an implicit first parameter, which a function returning a regular pointer doesn't. Task-number: QTBUG-27277 Change-Id: I57a59e5a7c46f55faabfe85c073dca89d2a7bbf3 Reviewed-by: Jan Kundrát Reviewed-by: Thiago Macieira --- src/corelib/tools/qarraydata.h | 12 ++++++------ src/corelib/tools/qvector.h | 11 +++++++++++ 2 files changed, 17 insertions(+), 6 deletions(-) (limited to 'src/corelib') 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(QArrayData::data()); } const T *data() const { return static_cast(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/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); -- cgit v1.2.3 From efe607e8aa6ecb156ffaea1a9c0ea1b09595133a Mon Sep 17 00:00:00 2001 From: Michele Caini Date: Fri, 5 Oct 2012 18:36:03 +0200 Subject: Review of documentation. Documentation has been updated to reflect changes in Qt5. Change-Id: I378858cf61f4bf62375c30c3903818d754dadcf0 Reviewed-by: Frederik Gladhorn --- .../doc/snippets/code/src_corelib_plugin_quuid.cpp | 2 +- src/corelib/plugin/quuid.cpp | 30 +++++++++++++++++++--- 2 files changed, 28 insertions(+), 4 deletions(-) (limited to 'src/corelib') 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/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 -- cgit v1.2.3 From c4b2d77f40a42a67480bb49aa63b0953c80c024a Mon Sep 17 00:00:00 2001 From: Bernd Weimer Date: Wed, 17 Oct 2012 11:19:34 +0200 Subject: Fix for slowness of touch move events In the event dispatcher native events will be processed in a tight loop to drain the queue. IO events and timers will be postponed. Change-Id: Ic2c06ed182027289eb5e7042fbae99efbd01ea27 Reviewed-by: Fabian Bumberger Reviewed-by: Sean Harmer Reviewed-by: Thomas McGuire --- src/corelib/kernel/qeventdispatcher_blackberry.cpp | 104 +++++++++------------ 1 file changed, 46 insertions(+), 58 deletions(-) (limited to 'src/corelib') 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(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(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(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(event), 0); break; } - - hasProcessedEventsOnce = true; } // the number of bits set in the file sets -- cgit v1.2.3 From 320c4e31e124f99601399d00935362b587c77510 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 25 Sep 2012 16:30:48 +0200 Subject: Make QContiguousCache with zero capacity not crash These containers don't make sense and will just result in no action being taken (all items added will simply be discarded), but it shouldn't crash due to a division by zero. Update the documentation to explain the fact. Task-number: QTBUG-27339 Change-Id: Ib9acf5c0a9a826e6853e7beaf5e56511fde98dc6 Reviewed-by: Giuseppe D'Angelo Reviewed-by: Ian Walters Reviewed-by: Thiago Macieira --- src/corelib/tools/qcontiguouscache.cpp | 11 +++++++++-- src/corelib/tools/qcontiguouscache.h | 6 ++++++ 2 files changed, 15 insertions(+), 2 deletions(-) (limited to 'src/corelib') 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::freeData(Data *x) template void QContiguousCache::append(const T &value) { + if (!d->alloc) + return; // zero capacity detach(); if (QTypeInfo::isComplex) { if (d->count == d->alloc) @@ -362,6 +364,8 @@ void QContiguousCache::append(const T &value) template void QContiguousCache::prepend(const T &value) { + if (!d->alloc) + return; // zero capacity detach(); if (d->start) d->start--; @@ -385,6 +389,8 @@ template void QContiguousCache::insert(int pos, const T &value) { Q_ASSERT_X(pos >= 0 && pos < INT_MAX, "QContiguousCache::insert", "index out of range"); + if (!d->alloc) + return; // zero capacity detach(); if (containsIndex(pos)) { if (QTypeInfo::isComplex) { -- cgit v1.2.3