summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2016-04-07 10:47:20 +0200
committerLiang Qi <liang.qi@theqtcompany.com>2016-04-07 10:47:20 +0200
commitee0951d69b38f766e67262487be95b88501aa4a5 (patch)
tree116c334060500be340d4d61c99026316b0df3ce9 /src/corelib
parent0bb645b1ccc5a9d57b21cf0b2c4306b8e48c611c (diff)
parentd37239aa419ee4adff4b0a8d5c1403cadff72319 (diff)
Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts: src/network/access/qftp.cpp src/widgets/itemviews/qheaderview.cpp src/widgets/itemviews/qlistview.cpp tests/auto/network/access/qftp/tst_qftp.cpp Change-Id: I9f928f25d45d8944dd60bb583f649fc1615bc5d9
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/global/qglobal.h2
-rw-r--r--src/corelib/io/qdir.cpp8
-rw-r--r--src/corelib/itemmodels/qabstractitemmodel.h2
-rw-r--r--src/corelib/kernel/qobjectdefs.h73
-rw-r--r--src/corelib/tools/qdatetimeparser.cpp11
-rw-r--r--src/corelib/tools/qhash.cpp1
-rw-r--r--src/corelib/tools/qstring.h12
-rw-r--r--src/corelib/tools/qtimezoneprivate.cpp57
8 files changed, 105 insertions, 61 deletions
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index 86ac5d0312..235bae89af 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -1010,8 +1010,6 @@ Q_CORE_EXPORT QString qtTrId(const char *id, int n = -1);
#endif // QT_NO_TRANSLATION
-#define QDOC_PROPERTY(text)
-
/*
When RTTI is not available, define this macro to force any uses of
dynamic_cast to cause a compile failure.
diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp
index 9b9b00f76d..9efe2fb90e 100644
--- a/src/corelib/io/qdir.cpp
+++ b/src/corelib/io/qdir.cpp
@@ -762,17 +762,13 @@ QString QDir::relativeFilePath(const QString &fileName) const
#endif
QString result;
-#if defined(Q_OS_WIN)
- QStringList dirElts = dir.split(QLatin1Char('/'), QString::SkipEmptyParts);
- QStringList fileElts = file.split(QLatin1Char('/'), QString::SkipEmptyParts);
-#else
QVector<QStringRef> dirElts = dir.splitRef(QLatin1Char('/'), QString::SkipEmptyParts);
QVector<QStringRef> fileElts = file.splitRef(QLatin1Char('/'), QString::SkipEmptyParts);
-#endif
+
int i = 0;
while (i < dirElts.size() && i < fileElts.size() &&
#if defined(Q_OS_WIN)
- dirElts.at(i).toLower() == fileElts.at(i).toLower())
+ dirElts.at(i).compare(fileElts.at(i), Qt::CaseInsensitive) == 0)
#else
dirElts.at(i) == fileElts.at(i))
#endif
diff --git a/src/corelib/itemmodels/qabstractitemmodel.h b/src/corelib/itemmodels/qabstractitemmodel.h
index ce35cf4730..0820626452 100644
--- a/src/corelib/itemmodels/qabstractitemmodel.h
+++ b/src/corelib/itemmodels/qabstractitemmodel.h
@@ -429,7 +429,7 @@ inline Qt::ItemFlags QModelIndex::flags() const
{ return m ? m->flags(*this) : Qt::ItemFlags(); }
inline uint qHash(const QModelIndex &index) Q_DECL_NOTHROW
-{ return uint((index.row() << 4) + index.column() + index.internalId()); }
+{ return uint((uint(index.row()) << 4) + index.column() + index.internalId()); }
QT_END_NAMESPACE
diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h
index 3d47bae4a0..f8bebdf617 100644
--- a/src/corelib/kernel/qobjectdefs.h
+++ b/src/corelib/kernel/qobjectdefs.h
@@ -62,6 +62,25 @@ class QString;
#define Q_MOC_OUTPUT_REVISION 67
#endif
+// The following macros can be defined by tools that understand Qt
+// to have the information from the macro.
+#ifndef QT_ANNOTATE_CLASS
+# ifndef Q_COMPILER_VARIADIC_MACROS
+# define QT_ANNOTATE_CLASS(type, x)
+# else
+# define QT_ANNOTATE_CLASS(type, ...)
+# endif
+#endif
+#ifndef QT_ANNOTATE_CLASS2
+# define QT_ANNOTATE_CLASS2(type, a1, a2)
+#endif
+#ifndef QT_ANNOTATE_FUNCTION
+# define QT_ANNOTATE_FUNCTION(x)
+#endif
+#ifndef QT_ANNOTATE_ACCESS_SPECIFIER
+# define QT_ANNOTATE_ACCESS_SPECIFIER(x)
+#endif
+
// The following macros are our "extensions" to C++
// They are used, strictly speaking, only by the moc.
@@ -71,38 +90,44 @@ class QString;
# define QT_NO_EMIT
# else
# ifndef QT_NO_SIGNALS_SLOTS_KEYWORDS
-# define slots
-# define signals public
+# define slots Q_SLOTS
+# define signals Q_SIGNALS
# endif
# endif
-# define Q_SLOTS
-# define Q_SIGNALS public
-# define Q_PRIVATE_SLOT(d, signature)
+# define Q_SLOTS QT_ANNOTATE_ACCESS_SPECIFIER(qt_slot)
+# define Q_SIGNALS public QT_ANNOTATE_ACCESS_SPECIFIER(qt_signal)
+# define Q_PRIVATE_SLOT(d, signature) QT_ANNOTATE_CLASS2(qt_private_slot, d, signature)
# define Q_EMIT
#ifndef QT_NO_EMIT
# define emit
#endif
-#define Q_CLASSINFO(name, value)
-#define Q_PLUGIN_METADATA(x)
-#define Q_INTERFACES(x)
+#ifndef Q_CLASSINFO
+# define Q_CLASSINFO(name, value)
+#endif
+#define Q_PLUGIN_METADATA(x) QT_ANNOTATE_CLASS(qt_plugin_metadata, x)
+#define Q_INTERFACES(x) QT_ANNOTATE_CLASS(qt_interfaces, x)
#ifdef Q_COMPILER_VARIADIC_MACROS
-#define Q_PROPERTY(...)
+# define Q_PROPERTY(...) QT_ANNOTATE_CLASS(qt_property, __VA_ARGS__)
#else
-#define Q_PROPERTY(text)
+# define Q_PROPERTY(text) QT_ANNOTATE_CLASS(qt_property, text)
+#endif
+#define Q_PRIVATE_PROPERTY(d, text) QT_ANNOTATE_CLASS2(qt_private_property, d, text)
+#ifndef Q_REVISION
+# define Q_REVISION(v)
#endif
-#define Q_PRIVATE_PROPERTY(d, text)
-#define Q_REVISION(v)
-#define Q_OVERRIDE(text)
-#define Q_ENUMS(x)
-#define Q_FLAGS(x)
-#define Q_ENUM(ENUM) \
+#define Q_OVERRIDE(text) QT_ANNOTATE_CLASS(qt_override, text)
+#define QDOC_PROPERTY(text) QT_ANNOTATE_CLASS(qt_qdoc_property, text)
+#define Q_ENUMS(x) QT_ANNOTATE_CLASS(qt_enums, x)
+#define Q_FLAGS(x) QT_ANNOTATE_CLASS(qt_enums, x)
+#define Q_ENUM_IMPL(ENUM) \
friend Q_DECL_CONSTEXPR const QMetaObject *qt_getEnumMetaObject(ENUM) Q_DECL_NOEXCEPT { return &staticMetaObject; } \
friend Q_DECL_CONSTEXPR const char *qt_getEnumName(ENUM) Q_DECL_NOEXCEPT { return #ENUM; }
-#define Q_FLAG(ENUM) Q_ENUM(ENUM)
-#define Q_SCRIPTABLE
-#define Q_INVOKABLE
-#define Q_SIGNAL
-#define Q_SLOT
+#define Q_ENUM(x) Q_ENUMS(x) Q_ENUM_IMPL(x)
+#define Q_FLAG(x) Q_FLAGS(x) Q_ENUM_IMPL(x)
+#define Q_SCRIPTABLE QT_ANNOTATE_FUNCTION(qt_scriptable)
+#define Q_INVOKABLE QT_ANNOTATE_FUNCTION(qt_invokable)
+#define Q_SIGNAL QT_ANNOTATE_FUNCTION(qt_signal)
+#define Q_SLOT QT_ANNOTATE_FUNCTION(qt_slot)
#endif // QT_NO_META_MACROS
#ifndef QT_NO_TRANSLATION
@@ -180,10 +205,11 @@ private: \
Q_OBJECT_NO_ATTRIBUTES_WARNING \
Q_DECL_HIDDEN_STATIC_METACALL static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **); \
QT_WARNING_POP \
- struct QPrivateSignal {};
+ struct QPrivateSignal {}; \
+ QT_ANNOTATE_CLASS(qt_qobject, "")
/* qmake ignore Q_OBJECT */
-#define Q_OBJECT_FAKE Q_OBJECT
+#define Q_OBJECT_FAKE Q_OBJECT QT_ANNOTATE_CLASS(qt_fake, "")
#ifndef QT_NO_META_MACROS
/* qmake ignore Q_GADGET */
@@ -197,6 +223,7 @@ private: \
Q_OBJECT_NO_ATTRIBUTES_WARNING \
Q_DECL_HIDDEN_STATIC_METACALL static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **); \
QT_WARNING_POP \
+ QT_ANNOTATE_CLASS(qt_qgadget, "") \
/*end*/
#endif // QT_NO_META_MACROS
diff --git a/src/corelib/tools/qdatetimeparser.cpp b/src/corelib/tools/qdatetimeparser.cpp
index bbcd64d34f..73ecd4c47e 100644
--- a/src/corelib/tools/qdatetimeparser.cpp
+++ b/src/corelib/tools/qdatetimeparser.cpp
@@ -606,19 +606,20 @@ int QDateTimeParser::sectionMaxSize(Section s, int count) const
// fall through
#endif
case MonthSection:
- if (count <= 2)
- return 2;
-
#ifdef QT_NO_TEXTDATE
return 2;
#else
+ if (count <= 2)
+ return 2;
+
{
int ret = 0;
const QLocale l = locale();
+ const QLocale::FormatType format = count == 4 ? QLocale::LongFormat : QLocale::ShortFormat;
for (int i=1; i<=mcount; ++i) {
const QString str = (s == MonthSection
- ? l.monthName(i, count == 4 ? QLocale::LongFormat : QLocale::ShortFormat)
- : l.dayName(i, count == 4 ? QLocale::LongFormat : QLocale::ShortFormat));
+ ? l.monthName(i, format)
+ : l.dayName(i, format));
ret = qMax(str.size(), ret);
}
return ret;
diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp
index 8ab98bd509..2f0886edce 100644
--- a/src/corelib/tools/qhash.cpp
+++ b/src/corelib/tools/qhash.cpp
@@ -1,4 +1,3 @@
-
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h
index ddaab1f544..6676efab41 100644
--- a/src/corelib/tools/qstring.h
+++ b/src/corelib/tools/qstring.h
@@ -1546,9 +1546,9 @@ inline QT_ASCII_CAST_WARN bool QStringRef::operator!=(const char *s) const
inline QT_ASCII_CAST_WARN bool QStringRef::operator<(const char *s) const
{ return QString::compare_helper(constData(), size(), s, -1) < 0; }
inline QT_ASCII_CAST_WARN bool QStringRef::operator<=(const char *s) const
-{ return QString::compare_helper(constData(), size(), s, -1) > 0; }
-inline QT_ASCII_CAST_WARN bool QStringRef::operator>(const char *s) const
{ return QString::compare_helper(constData(), size(), s, -1) <= 0; }
+inline QT_ASCII_CAST_WARN bool QStringRef::operator>(const char *s) const
+{ return QString::compare_helper(constData(), size(), s, -1) > 0; }
inline QT_ASCII_CAST_WARN bool QStringRef::operator>=(const char *s) const
{ return QString::compare_helper(constData(), size(), s, -1) >= 0; }
@@ -1557,13 +1557,13 @@ inline QT_ASCII_CAST_WARN bool operator==(const char *s1, const QStringRef &s2)
inline QT_ASCII_CAST_WARN bool operator!=(const char *s1, const QStringRef &s2)
{ return QString::compare_helper(s2.constData(), s2.size(), s1, -1) != 0; }
inline QT_ASCII_CAST_WARN bool operator<(const char *s1, const QStringRef &s2)
-{ return QString::compare_helper(s2.constData(), s2.size(), s1, -1) < 0; }
-inline QT_ASCII_CAST_WARN bool operator<=(const char *s1, const QStringRef &s2)
{ return QString::compare_helper(s2.constData(), s2.size(), s1, -1) > 0; }
+inline QT_ASCII_CAST_WARN bool operator<=(const char *s1, const QStringRef &s2)
+{ return QString::compare_helper(s2.constData(), s2.size(), s1, -1) >= 0; }
inline QT_ASCII_CAST_WARN bool operator>(const char *s1, const QStringRef &s2)
-{ return QString::compare_helper(s2.constData(), s2.size(), s1, -1) <= 0; }
+{ return QString::compare_helper(s2.constData(), s2.size(), s1, -1) < 0; }
inline QT_ASCII_CAST_WARN bool operator>=(const char *s1, const QStringRef &s2)
-{ return QString::compare_helper(s2.constData(), s2.size(), s1, -1) >= 0; }
+{ return QString::compare_helper(s2.constData(), s2.size(), s1, -1) <= 0; }
#endif // !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII)
inline int QString::compare(const QStringRef &s, Qt::CaseSensitivity cs) const Q_DECL_NOTHROW
diff --git a/src/corelib/tools/qtimezoneprivate.cpp b/src/corelib/tools/qtimezoneprivate.cpp
index dc20bca27f..763d12b702 100644
--- a/src/corelib/tools/qtimezoneprivate.cpp
+++ b/src/corelib/tools/qtimezoneprivate.cpp
@@ -447,22 +447,45 @@ QTimeZone::OffsetData QTimeZonePrivate::toOffsetData(const QTimeZonePrivate::Dat
return offsetData;
}
-// If the format of the ID is valid
+// Is the format of the ID valid ?
bool QTimeZonePrivate::isValidId(const QByteArray &ianaId)
{
- // Rules for defining TZ/IANA names as per ftp://ftp.iana.org/tz/code/Theory
- // 1. Use only valid POSIX file name components
- // 2. Within a file name component, use only ASCII letters, `.', `-' and `_'.
- // 3. Do not use digits
- // 4. A file name component must not exceed 14 characters or start with `-'
- // Aliases such as "Etc/GMT+7" and "SystemV/EST5EDT" are valid so we need to accept digits, ':', and '+'.
-
- // The following would be preferable if QRegExp would work on QByteArrays directly:
- // const QRegExp rx(QStringLiteral("[a-z0-9:+._][a-z0-9:+._-]{,13}(?:/[a-z0-9:+._][a-z0-9:+._-]{,13})*"),
- // Qt::CaseInsensitive);
- // return rx.exactMatch(ianaId);
-
- // hand-rolled version:
+ /*
+ Main rules for defining TZ/IANA names as per ftp://ftp.iana.org/tz/code/Theory
+ 1. Use only valid POSIX file name components
+ 2. Within a file name component, use only ASCII letters, `.', `-' and `_'.
+ 3. Do not use digits (except in a [+-]\d+ suffix, when used).
+ 4. A file name component must not exceed 14 characters or start with `-'
+ However, the rules are really guidelines - a later one says
+ - Do not change established names if they only marginally violate the
+ above rules.
+ We may, therefore, need to be a bit slack in our check here, if we hit
+ legitimate exceptions in real time-zone databases.
+
+ In particular, aliases such as "Etc/GMT+7" and "SystemV/EST5EDT" are valid
+ so we need to accept digits, ':', and '+'; aliases typically have the form
+ of POSIX TZ strings, which allow a suffix to a proper IANA name. A POSIX
+ suffix starts with an offset (as in GMT+7) and may continue with another
+ name (as in EST5EDT, giving the DST name of the zone); a further offset is
+ allowed (for DST). The ("hard to describe and [...] error-prone in
+ practice") POSIX form even allows a suffix giving the dates (and
+ optionally times) of the annual DST transitions. Hopefully, no TZ aliases
+ go that far, but we at least need to accept an offset and (single
+ fragment) DST-name.
+
+ But for the legacy complications, the following would be preferable if
+ QRegExp would work on QByteArrays directly:
+ const QRegExp rx(QStringLiteral("[a-z+._][a-z+._-]{,13}"
+ "(?:/[a-z+._][a-z+._-]{,13})*"
+ // Optional suffix:
+ "(?:[+-]?\d{1,2}(?::\d{1,2}){,2}" // offset
+ // one name fragment (DST):
+ "(?:[a-z+._][a-z+._-]{,13})?)"),
+ Qt::CaseInsensitive);
+ return rx.exactMatch(ianaId);
+ */
+
+ // Somewhat slack hand-rolled version:
const int MinSectionLength = 1;
const int MaxSectionLength = 14;
int sectionLength = 0;
@@ -478,11 +501,11 @@ bool QTimeZonePrivate::isValidId(const QByteArray &ianaId)
} else if (!(ch >= 'a' && ch <= 'z')
&& !(ch >= 'A' && ch <= 'Z')
&& !(ch == '_')
+ && !(ch == '.')
+ // Should ideally check these only happen as an offset:
&& !(ch >= '0' && ch <= '9')
- && !(ch == '-')
&& !(ch == '+')
- && !(ch == ':')
- && !(ch == '.')) {
+ && !(ch == ':')) {
return false; // violates (2)
}
}