From 8a33077853e851e2795476cd502444c2d8535f9a Mon Sep 17 00:00:00 2001 From: David Faure Date: Thu, 28 Jul 2016 12:25:59 +0200 Subject: QUrl: fix resolved() for data URLs They look relative because the path doesn't start with a '/' but they have a scheme so they shouldn't be combined as if it was one absolute and one relative URL. [ChangeLog][QtCore][QUrl] QUrl::resolved() no longer treats a URL with a scheme as a relative URL if it matches this URL's scheme. This special casing was incompatible with RFC 3986 and broke resolving data: URLs, for instance. Change-Id: I3758d3a2141cea7c6d13514243eb8dee5d510dd0 Reviewed-by: Thiago Macieira --- src/corelib/io/qurl.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index 2672de24f2..1fe529d48d 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -3167,8 +3167,7 @@ QUrl QUrl::resolved(const QUrl &relative) const if (!relative.d) return *this; QUrl t; - // be non strict and allow scheme in relative url - if (!relative.d->scheme.isEmpty() && relative.d->scheme != d->scheme) { + if (!relative.d->scheme.isEmpty()) { t = relative; t.detach(); } else { -- cgit v1.2.3 From f0685992a3412b059a0952ac591f40856ffffb6f Mon Sep 17 00:00:00 2001 From: Konstantin Shegunov Date: Sun, 24 Jul 2016 22:14:49 +0300 Subject: Docs changed to reflect that valueName is required with value parsing When the option expects a value the valueName parameter of the constructor isn't optional; it must be set. This requirement is made explicit in the documentation. Task-number: QTBUG-54855 Change-Id: I190884aff2fa8e96bc5c5e82cdfed85be761d6e3 Reviewed-by: Thiago Macieira Reviewed-by: David Faure --- src/corelib/tools/qcommandlineoption.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qcommandlineoption.cpp b/src/corelib/tools/qcommandlineoption.cpp index 8c0ba8cb2b..93d20577c3 100644 --- a/src/corelib/tools/qcommandlineoption.cpp +++ b/src/corelib/tools/qcommandlineoption.cpp @@ -144,7 +144,7 @@ QCommandLineOption::QCommandLineOption(const QStringList &names) The description is set to \a description. It is customary to add a "." at the end of the description. - In addition, the \a valueName can be set if the option expects a value. + In addition, the \a valueName needs to be set if the option expects a value. The default value for the option is set to \a defaultValue. In Qt versions before 5.4, this constructor was \c explicit. In Qt 5.4 @@ -180,7 +180,7 @@ QCommandLineOption::QCommandLineOption(const QString &name, const QString &descr The description is set to \a description. It is customary to add a "." at the end of the description. - In addition, the \a valueName can be set if the option expects a value. + In addition, the \a valueName needs to be set if the option expects a value. The default value for the option is set to \a defaultValue. In Qt versions before 5.4, this constructor was \c explicit. In Qt 5.4 -- cgit v1.2.3 From 49c892328223dfa2502b462d8e5e8e181f4f6cd5 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 25 Jul 2016 13:24:59 +0200 Subject: QSortFilterProxyModel: Don't forward the hint from source's layoutChanged signal We can't forward a VerticalSortHint or HorizontalSortHint hint, because we might be filtering extra items. The documentation of QAbstractItemModel::LayoutChangeHint states: Note that VerticalSortHint and HorizontalSortHint carry the meaning that items are being moved within the same parent, not moved to a different parent in the model, and not filtered out or in. And some of the views rely on this assumption (QQmlDelegateModel for example) What happens in the test is the following: - 'model' emit the dataChanged signal when its data is changed. - 'proxi1' QSortFilterProxyModelPrivate::_q_sourceDataChanged does not forward the dataChanged signal imediatly, it will instead first re-sort the model and call layoutAboutToBeChanged / layouChanged with the VerticalSortHint - 'proxy2' would forward the layoutAboutToBeChanged with the hint, but in QSortFilterProxyModelPrivate::_q_sourceLayoutChanged, it will redo the mapping which will cause the changed data to be filtered. So proxy2 can't forward the VerticalSortHint as it removed rows in the process. Change-Id: I20b6983e9d18bf7509fe6144c74f37d24e4a18c2 Reviewed-by: Tobias Koenig Reviewed-by: David Faure --- src/corelib/itemmodels/qsortfilterproxymodel.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/src/corelib/itemmodels/qsortfilterproxymodel.cpp index 0771fd0e30..f264ad015d 100644 --- a/src/corelib/itemmodels/qsortfilterproxymodel.cpp +++ b/src/corelib/itemmodels/qsortfilterproxymodel.cpp @@ -1322,6 +1322,7 @@ void QSortFilterProxyModelPrivate::_q_sourceReset() void QSortFilterProxyModelPrivate::_q_sourceLayoutAboutToBeChanged(const QList &sourceParents, QAbstractItemModel::LayoutChangeHint hint) { Q_Q(QSortFilterProxyModel); + Q_UNUSED(hint); // We can't forward Hint because we might filter additional rows or columns saved_persistent_indexes.clear(); QList parents; @@ -1340,7 +1341,7 @@ void QSortFilterProxyModelPrivate::_q_sourceLayoutAboutToBeChanged(const QListlayoutAboutToBeChanged(parents, hint); + emit q->layoutAboutToBeChanged(parents); if (persistent.indexes.isEmpty()) return; @@ -1350,6 +1351,7 @@ void QSortFilterProxyModelPrivate::_q_sourceLayoutAboutToBeChanged(const QList &sourceParents, QAbstractItemModel::LayoutChangeHint hint) { Q_Q(QSortFilterProxyModel); + Q_UNUSED(hint); // We can't forward Hint because we might filter additional rows or columns // Optimize: We only actually have to clear the mapping related to the contents of // sourceParents, not everything. @@ -1379,7 +1381,7 @@ void QSortFilterProxyModelPrivate::_q_sourceLayoutChanged(const QListlayoutChanged(parents, hint); + emit q->layoutChanged(parents); } void QSortFilterProxyModelPrivate::_q_sourceRowsAboutToBeInserted( -- cgit v1.2.3 From 879fd5bb5ce94d9d98b966448029c030832eb582 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 14 Jun 2016 12:34:53 +0200 Subject: QTzTimeZonePrivate: skip redundant check, tidy up Various transition functions checked on m_tranTimes.size() > 0 inside a block which was conditioned on this already; simplify the code by knowing this is true already. Tidied up an initializer at the same time. Change-Id: I3e933a69e1b71b94bfd4451e4d761844da669d33 Reviewed-by: Thiago Macieira --- src/corelib/tools/qtimezoneprivate_tz.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qtimezoneprivate_tz.cpp b/src/corelib/tools/qtimezoneprivate_tz.cpp index 29544a5c37..c13c9a5223 100644 --- a/src/corelib/tools/qtimezoneprivate_tz.cpp +++ b/src/corelib/tools/qtimezoneprivate_tz.cpp @@ -896,13 +896,12 @@ QTimeZonePrivate::Data QTzTimeZonePrivate::data(qint64 forMSecsSinceEpoch) const if (m_tranTimes.size() > 0 && m_tranTimes.last().atMSecsSinceEpoch < forMSecsSinceEpoch && !m_posixRule.isEmpty() && forMSecsSinceEpoch >= 0) { const int year = QDateTime::fromMSecsSinceEpoch(forMSecsSinceEpoch, Qt::UTC).date().year(); - const int lastMSecs = (m_tranTimes.size() > 0) ? m_tranTimes.last().atMSecsSinceEpoch : 0; - QVector posixTrans = calculatePosixTransitions(m_posixRule, year - 1, - year + 1, lastMSecs); + QVector posixTrans = + calculatePosixTransitions(m_posixRule, year - 1, year + 1, + m_tranTimes.last().atMSecsSinceEpoch); for (int i = posixTrans.size() - 1; i >= 0; --i) { if (posixTrans.at(i).atMSecsSinceEpoch <= forMSecsSinceEpoch) { - QTimeZonePrivate::Data data; - data = posixTrans.at(i); + QTimeZonePrivate::Data data = posixTrans.at(i); data.atMSecsSinceEpoch = forMSecsSinceEpoch; return data; } @@ -940,9 +939,9 @@ QTimeZonePrivate::Data QTzTimeZonePrivate::nextTransition(qint64 afterMSecsSince if (m_tranTimes.size() > 0 && m_tranTimes.last().atMSecsSinceEpoch < afterMSecsSinceEpoch && !m_posixRule.isEmpty() && afterMSecsSinceEpoch >= 0) { const int year = QDateTime::fromMSecsSinceEpoch(afterMSecsSinceEpoch, Qt::UTC).date().year(); - const int lastMSecs = (m_tranTimes.size() > 0) ? m_tranTimes.last().atMSecsSinceEpoch : 0; - QVector posixTrans = calculatePosixTransitions(m_posixRule, year - 1, - year + 1, lastMSecs); + QVector posixTrans = + calculatePosixTransitions(m_posixRule, year - 1, year + 1, + m_tranTimes.last().atMSecsSinceEpoch); for (int i = 0; i < posixTrans.size(); ++i) { if (posixTrans.at(i).atMSecsSinceEpoch > afterMSecsSinceEpoch) return posixTrans.at(i); @@ -966,9 +965,9 @@ QTimeZonePrivate::Data QTzTimeZonePrivate::previousTransition(qint64 beforeMSecs if (m_tranTimes.size() > 0 && m_tranTimes.last().atMSecsSinceEpoch < beforeMSecsSinceEpoch && !m_posixRule.isEmpty() && beforeMSecsSinceEpoch > 0) { const int year = QDateTime::fromMSecsSinceEpoch(beforeMSecsSinceEpoch, Qt::UTC).date().year(); - const int lastMSecs = (m_tranTimes.size() > 0) ? m_tranTimes.last().atMSecsSinceEpoch : 0; - QVector posixTrans = calculatePosixTransitions(m_posixRule, year - 1, - year + 1, lastMSecs); + QVector posixTrans = + calculatePosixTransitions(m_posixRule, year - 1, year + 1, + m_tranTimes.last().atMSecsSinceEpoch); for (int i = posixTrans.size() - 1; i >= 0; --i) { if (posixTrans.at(i).atMSecsSinceEpoch < beforeMSecsSinceEpoch) return posixTrans.at(i); -- cgit v1.2.3 From 2a24c3c268d443fb260d731d9f65b57726a40354 Mon Sep 17 00:00:00 2001 From: Clemens Sielaff Date: Sun, 24 Jul 2016 11:21:34 +1200 Subject: Fixed Bug in QVariant comparison when containing QStringLists MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As it were, QStringLists were not handled explicitly when comparing QVariants. If both QStringLists contained only a single entry, they were treated as QStrings - if both QStringLists were empty, there were equal (correctly so) - but if one of the QStringLists had more than one entry, the compare function fell through to returning always 1. As discussed here: https://stackoverflow.com/a/38492467/3444217 Added rich comparison tests for all non-numerical, non-recursive QVariants that support them (except QModelIndex and QPersistentModelIndex) Task-number: QTBUG-54893 Change-Id: Icc5480d9ba056ee5efe83da566c5829caa1509d7 Reviewed-by: Jędrzej Nowacki --- src/corelib/kernel/qvariant.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index 7596699843..4f256cccda 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -3560,6 +3560,8 @@ int QVariant::compare(const QVariant &v) const return v1.toTime() < v2.toTime() ? -1 : 1; case QVariant::DateTime: return v1.toDateTime() < v2.toDateTime() ? -1 : 1; + case QVariant::StringList: + return v1.toStringList() < v2.toStringList() ? -1 : 1; } int r = v1.toString().compare(v2.toString(), Qt::CaseInsensitive); if (r == 0) { -- cgit v1.2.3 From ed38f516bf1a9185ed331c2e5a38648e64a3982a Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 2 Aug 2016 20:29:55 +0300 Subject: QStringListModel: begin/endResetModel() are no signals ... so don't use emit on them. Just confuses readers. Change-Id: I24365fc533b5b35f8942d6014dbc68387aa23e22 Reviewed-by: Friedemann Kleint --- src/corelib/itemmodels/qstringlistmodel.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/itemmodels/qstringlistmodel.cpp b/src/corelib/itemmodels/qstringlistmodel.cpp index b0919c5d78..c6a1fac9c8 100644 --- a/src/corelib/itemmodels/qstringlistmodel.cpp +++ b/src/corelib/itemmodels/qstringlistmodel.cpp @@ -301,9 +301,9 @@ QStringList QStringListModel::stringList() const */ void QStringListModel::setStringList(const QStringList &strings) { - emit beginResetModel(); + beginResetModel(); lst = strings; - emit endResetModel(); + endResetModel(); } /*! -- cgit v1.2.3 From 9c8a8e90a6514c23bcbeb14073a9d6bdd926d68b Mon Sep 17 00:00:00 2001 From: Anton Kudryavtsev Date: Mon, 11 Jul 2016 17:23:21 +0300 Subject: QString: fix append(const QStringRef &str) Use QStringRef::isNull instead of QStringRef::string() for validation. Non-NULL str.string() may yet leave us with a useless str.unicode(), which is the actual problem here; whereas !str.isNull() does really confirm that str.unicode() is sensible. Such test prevents situation like: const QString a; QString b; b.append(a); // b.isNull() == true b.append(QStringRef(&a)); // b.isNull() == false Auto test updated: create QStringRef from QString directly, without any condition. Change-Id: I082cd58ef656d8a53e3c1223aca01feea82fffb9 Reviewed-by: Thiago Macieira Reviewed-by: Marc Mutz --- src/corelib/tools/qstring.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index b5119444b7..9aeec77632 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -9375,7 +9375,7 @@ QString &QString::append(const QStringRef &str) { if (str.string() == this) { str.appendTo(this); - } else if (str.string()) { + } else if (!str.isNull()) { int oldSize = size(); resize(oldSize + str.size()); memcpy(data() + oldSize, str.unicode(), str.size() * sizeof(QChar)); -- cgit v1.2.3 From 91a2c8630b2204831566ab8e523c747f9d8ec927 Mon Sep 17 00:00:00 2001 From: David Faure Date: Tue, 2 Aug 2016 14:07:37 +0200 Subject: QUrl::resolved: keep treating file:name.txt as relative for now 8a33077 made QUrl::resolved() follow its documentation ("If relative is not a relative URL, this function will return relative directly.", where relative means scheme is empty). However there is much code out there (e.g. qtdeclarative) which relies on QUrl::fromLocalFile("fileName.txt") to be treated as relative, so for now, we still allow this (in Qt 5.6.x). For Qt 5.8, this commit will be reverted. [ChangeLog][QtCore][QUrl] [EDITORIAL: replaces 8a33077] QUrl::resolved() no longer treats a URL with a scheme as a relative URL if it matches this URL's scheme. For now it still treats "file:name.txt" as relative for compatibility, but be warned that in Qt 5.8 it will no longer consider those to be relative. Both isRelative() and RFC 3986 say that such URLs are not relative, so starting from Qt 5.8, resolved() will return them as is. Change-Id: Iff01e5b470319f6c46526086d765187e2259bdf5 Reviewed-by: Thiago Macieira Reviewed-by: Oswald Buddenhagen --- src/corelib/io/qurl.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index 1fe529d48d..a5643d123d 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -3167,7 +3167,8 @@ QUrl QUrl::resolved(const QUrl &relative) const if (!relative.d) return *this; QUrl t; - if (!relative.d->scheme.isEmpty()) { + // Compatibility hack (mostly for qtdeclarative) : treat "file:relative.txt" as relative even though QUrl::isRelative() says false + if (!relative.d->scheme.isEmpty() && (!relative.isLocalFile() || QDir::isAbsolutePath(relative.d->path))) { t = relative; t.detach(); } else { -- cgit v1.2.3