diff options
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/io/qiodevice.cpp | 4 | ||||
-rw-r--r-- | src/corelib/io/qtextstream.cpp | 6 | ||||
-rw-r--r-- | src/corelib/itemmodels/qsortfilterproxymodel.cpp | 10 | ||||
-rw-r--r-- | src/corelib/itemmodels/qsortfilterproxymodel.h | 2 | ||||
-rw-r--r-- | src/corelib/kernel/qmimedata.cpp | 17 | ||||
-rw-r--r-- | src/corelib/statemachine/qstatemachine.cpp | 30 | ||||
-rw-r--r-- | src/corelib/tools/qregularexpression.cpp | 3 |
7 files changed, 53 insertions, 19 deletions
diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp index 47484ad596..e73a200fb4 100644 --- a/src/corelib/io/qiodevice.cpp +++ b/src/corelib/io/qiodevice.cpp @@ -989,6 +989,10 @@ QByteArray QIODevice::readAll() // Size is unknown, read incrementally. qint64 readResult; do { + if (quint64(readBytes) + QIODEVICE_BUFFERSIZE > QByteArray::MaxSize) { + // If resize would fail, don't read more, return what we have. + break; + } result.resize(readBytes + QIODEVICE_BUFFERSIZE); readResult = read(result.data() + readBytes, QIODEVICE_BUFFERSIZE); if (readResult > 0 || readBytes == 0) diff --git a/src/corelib/io/qtextstream.cpp b/src/corelib/io/qtextstream.cpp index 6149a04a74..5fe4cfef9d 100644 --- a/src/corelib/io/qtextstream.cpp +++ b/src/corelib/io/qtextstream.cpp @@ -447,6 +447,9 @@ bool QTextStreamPrivate::fillReadBuffer(qint64 maxBytes) bytesRead = device->read(buf, sizeof(buf)); } + if (bytesRead <= 0) + return false; + #ifndef QT_NO_TEXTCODEC // codec auto detection, explicitly defaults to locale encoding if the // codec has been set to 0. @@ -470,9 +473,6 @@ bool QTextStreamPrivate::fillReadBuffer(qint64 maxBytes) qt_prettyDebug(buf, qMin(32,int(bytesRead)) , int(bytesRead)).constData(), int(sizeof(buf)), int(bytesRead)); #endif - if (bytesRead <= 0) - return false; - int oldReadBufferSize = readBuffer.size(); #ifndef QT_NO_TEXTCODEC // convert to unicode diff --git a/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/src/corelib/itemmodels/qsortfilterproxymodel.cpp index 3a604c15f4..922d0f1622 100644 --- a/src/corelib/itemmodels/qsortfilterproxymodel.cpp +++ b/src/corelib/itemmodels/qsortfilterproxymodel.cpp @@ -2577,8 +2577,8 @@ void QSortFilterProxyModel::invalidateFilter() /*! Returns \c true if the value of the item referred to by the given - index \a left is less than the value of the item referred to by - the given index \a right, otherwise returns \c false. + index \a source_left is less than the value of the item referred to by + the given index \a source_right, otherwise returns \c false. This function is used as the < operator when sorting, and handles the following QVariant types: @@ -2612,11 +2612,11 @@ void QSortFilterProxyModel::invalidateFilter() \sa sortRole, sortCaseSensitivity, dynamicSortFilter */ -bool QSortFilterProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const +bool QSortFilterProxyModel::lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const { Q_D(const QSortFilterProxyModel); - QVariant l = (left.model() ? left.model()->data(left, d->sort_role) : QVariant()); - QVariant r = (right.model() ? right.model()->data(right, d->sort_role) : QVariant()); + QVariant l = (source_left.model() ? source_left.model()->data(source_left, d->sort_role) : QVariant()); + QVariant r = (source_right.model() ? source_right.model()->data(source_right, d->sort_role) : QVariant()); switch (l.userType()) { case QVariant::Invalid: return (r.type() != QVariant::Invalid); diff --git a/src/corelib/itemmodels/qsortfilterproxymodel.h b/src/corelib/itemmodels/qsortfilterproxymodel.h index 9ba4e48d09..a08d7c6416 100644 --- a/src/corelib/itemmodels/qsortfilterproxymodel.h +++ b/src/corelib/itemmodels/qsortfilterproxymodel.h @@ -111,7 +111,7 @@ public Q_SLOTS: protected: virtual bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const; virtual bool filterAcceptsColumn(int source_column, const QModelIndex &source_parent) const; - virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const; + virtual bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const; void filterChanged(); void invalidateFilter(); diff --git a/src/corelib/kernel/qmimedata.cpp b/src/corelib/kernel/qmimedata.cpp index 0753faf469..3e9cdac966 100644 --- a/src/corelib/kernel/qmimedata.cpp +++ b/src/corelib/kernel/qmimedata.cpp @@ -566,7 +566,22 @@ QByteArray QMimeData::data(const QString &mimeType) const void QMimeData::setData(const QString &mimeType, const QByteArray &data) { Q_D(QMimeData); - d->setData(mimeType, QVariant(data)); + + if (mimeType == QLatin1String("text/uri-list")) { + QByteArray ba = data; + if (ba.endsWith('\0')) + ba.chop(1); + QList<QByteArray> urls = ba.split('\n'); + QList<QVariant> list; + for (int i = 0; i < urls.size(); ++i) { + QByteArray ba = urls.at(i).trimmed(); + if (!ba.isEmpty()) + list.append(QUrl::fromEncoded(ba)); + } + d->setData(mimeType, list); + } else { + d->setData(mimeType, QVariant(data)); + } } /*! diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp index 04c82b5cd3..3d2da77390 100644 --- a/src/corelib/statemachine/qstatemachine.cpp +++ b/src/corelib/statemachine/qstatemachine.cpp @@ -483,6 +483,8 @@ function removeConflictingTransitions(enabledTransitions): filteredTransitions.add(t1) return filteredTransitions + +Note: the implementation below does not build the transitionsToRemove, but removes them in-place. */ void QStateMachinePrivate::removeConflictingTransitions(QList<QAbstractTransition*> &enabledTransitions) { @@ -492,24 +494,36 @@ void QStateMachinePrivate::removeConflictingTransitions(QList<QAbstractTransitio foreach (QAbstractTransition *t1, enabledTransitions) { bool t1Preempted = false; - QVarLengthArray<QAbstractTransition *> transitionsToRemove; QSet<QAbstractState*> exitSetT1 = computeExitSet_Unordered(QList<QAbstractTransition*>() << t1); - foreach (QAbstractTransition *t2, filteredTransitions) { + QList<QAbstractTransition*>::iterator t2It = filteredTransitions.begin(); + while (t2It != filteredTransitions.end()) { + QAbstractTransition *t2 = *t2It; + if (t1 == t2) { + // Special case: someone added the same transition object to a state twice. In this + // case, t2 (which is already in the list) "preempts" t1. + t1Preempted = true; + break; + } + QSet<QAbstractState*> exitSetT2 = computeExitSet_Unordered(QList<QAbstractTransition*>() << t2); - if (!exitSetT1.intersect(exitSetT2).isEmpty()) { + if (exitSetT1.intersect(exitSetT2).isEmpty()) { + // No conflict, no cry. Next patient please. + ++t2It; + } else { + // Houston, we have a conflict. Check which transition can be removed. if (isDescendant(t1->sourceState(), t2->sourceState())) { - transitionsToRemove.append(t2); + // t1 preempts t2, so we can remove t2 + t2It = filteredTransitions.erase(t2It); } else { + // t2 preempts t1, so there's no use in looking further and we don't need to add + // t1 to the list. t1Preempted = true; break; } } } - if (!t1Preempted) { - foreach (QAbstractTransition *t3, transitionsToRemove) - filteredTransitions.removeAll(t3); + if (!t1Preempted) filteredTransitions.append(t1); - } } enabledTransitions = filteredTransitions; diff --git a/src/corelib/tools/qregularexpression.cpp b/src/corelib/tools/qregularexpression.cpp index cbc5a0486e..9950b90720 100644 --- a/src/corelib/tools/qregularexpression.cpp +++ b/src/corelib/tools/qregularexpression.cpp @@ -2657,7 +2657,8 @@ static const char *pcreCompileErrorCodes[] = QT_TRANSLATE_NOOP("QRegularExpression", "parentheses are too deeply nested"), QT_TRANSLATE_NOOP("QRegularExpression", "invalid range in character class"), QT_TRANSLATE_NOOP("QRegularExpression", "group name must start with a non-digit"), - QT_TRANSLATE_NOOP("QRegularExpression", "parentheses are too deeply nested (stack check)") + QT_TRANSLATE_NOOP("QRegularExpression", "parentheses are too deeply nested (stack check)"), + QT_TRANSLATE_NOOP("QRegularExpression", "digits missing in \\x{} or \\o{}") }; #endif // #if 0 |