diff options
author | Liang Qi <liang.qi@qt.io> | 2017-05-07 13:07:34 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2017-05-07 13:08:18 +0200 |
commit | d1ea4813458b383e66ce4df69d1833b8b6a279c4 (patch) | |
tree | 3bdc16da993e5de56b669e6774fb0748075ddd90 /src/corelib/io | |
parent | 1c87d4e1a1d0e1972f6dc85e55ea9be8a42797ba (diff) | |
parent | 0b1ec78c2d4871afcc89d5b046926b88f0819a7c (diff) |
Merge remote-tracking branch 'origin/5.9' into dev
Conflicts:
src/network/access/qnetworkreply.cpp
tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp
Change-Id: Iadf766269454087e69fb216fc3857d85b0ddfaad
Diffstat (limited to 'src/corelib/io')
-rw-r--r-- | src/corelib/io/qfile.cpp | 4 | ||||
-rw-r--r-- | src/corelib/io/qfiledevice.cpp | 4 | ||||
-rw-r--r-- | src/corelib/io/qfilesystemwatcher.cpp | 1 | ||||
-rw-r--r-- | src/corelib/io/qfilesystemwatcher_inotify.cpp | 2 | ||||
-rw-r--r-- | src/corelib/io/qfilesystemwatcher_polling.cpp | 3 | ||||
-rw-r--r-- | src/corelib/io/qiodevice.cpp | 4 | ||||
-rw-r--r-- | src/corelib/io/qloggingregistry.cpp | 50 | ||||
-rw-r--r-- | src/corelib/io/qloggingregistry_p.h | 16 | ||||
-rw-r--r-- | src/corelib/io/qnoncontiguousbytedevice.cpp | 1 | ||||
-rw-r--r-- | src/corelib/io/qsavefile.cpp | 4 | ||||
-rw-r--r-- | src/corelib/io/qsettings.cpp | 4 | ||||
-rw-r--r-- | src/corelib/io/qstandardpaths.cpp | 4 | ||||
-rw-r--r-- | src/corelib/io/qtemporarydir.cpp | 10 | ||||
-rw-r--r-- | src/corelib/io/qtemporaryfile.cpp | 4 | ||||
-rw-r--r-- | src/corelib/io/qtextstream.cpp | 3 | ||||
-rw-r--r-- | src/corelib/io/qurlidna.cpp | 49 | ||||
-rw-r--r-- | src/corelib/io/qwindowspipereader.cpp | 4 |
17 files changed, 115 insertions, 52 deletions
diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp index c19cb92715..ddd343b515 100644 --- a/src/corelib/io/qfile.cpp +++ b/src/corelib/io/qfile.cpp @@ -1113,3 +1113,7 @@ qint64 QFile::size() const } QT_END_NAMESPACE + +#ifndef QT_NO_QOBJECT +#include "moc_qfile.cpp" +#endif diff --git a/src/corelib/io/qfiledevice.cpp b/src/corelib/io/qfiledevice.cpp index 9e2e3fe741..8533602d63 100644 --- a/src/corelib/io/qfiledevice.cpp +++ b/src/corelib/io/qfiledevice.cpp @@ -815,3 +815,7 @@ bool QFileDevice::setFileTime(const QDateTime &newDate, QFileDevice::FileTime fi } QT_END_NAMESPACE + +#ifndef QT_NO_QOBJECT +#include "moc_qfiledevice.cpp" +#endif diff --git a/src/corelib/io/qfilesystemwatcher.cpp b/src/corelib/io/qfilesystemwatcher.cpp index 612b3fa57c..ed597c415b 100644 --- a/src/corelib/io/qfilesystemwatcher.cpp +++ b/src/corelib/io/qfilesystemwatcher.cpp @@ -497,6 +497,7 @@ QStringList QFileSystemWatcher::files() const QT_END_NAMESPACE #include "moc_qfilesystemwatcher.cpp" +#include "moc_qfilesystemwatcher_p.cpp" #endif // QT_NO_FILESYSTEMWATCHER diff --git a/src/corelib/io/qfilesystemwatcher_inotify.cpp b/src/corelib/io/qfilesystemwatcher_inotify.cpp index 5564bc7dca..3cfc6a254f 100644 --- a/src/corelib/io/qfilesystemwatcher_inotify.cpp +++ b/src/corelib/io/qfilesystemwatcher_inotify.cpp @@ -417,4 +417,6 @@ QString QInotifyFileSystemWatcherEngine::getPathFromID(int id) const QT_END_NAMESPACE +#include "moc_qfilesystemwatcher_inotify_p.cpp" + #endif // QT_NO_FILESYSTEMWATCHER diff --git a/src/corelib/io/qfilesystemwatcher_polling.cpp b/src/corelib/io/qfilesystemwatcher_polling.cpp index cbcb68e7d2..5bef8127f7 100644 --- a/src/corelib/io/qfilesystemwatcher_polling.cpp +++ b/src/corelib/io/qfilesystemwatcher_polling.cpp @@ -151,4 +151,7 @@ void QPollingFileSystemWatcherEngine::timeout() } QT_END_NAMESPACE + +#include "moc_qfilesystemwatcher_polling_p.cpp" + #endif // !QT_NO_FILESYSTEMWATCHER diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp index 41a4d7a1ba..80122eac5e 100644 --- a/src/corelib/io/qiodevice.cpp +++ b/src/corelib/io/qiodevice.cpp @@ -2059,3 +2059,7 @@ QDebug operator<<(QDebug debug, QIODevice::OpenMode modes) #endif QT_END_NAMESPACE + +#ifndef QT_NO_QOBJECT +#include "moc_qiodevice.cpp" +#endif diff --git a/src/corelib/io/qloggingregistry.cpp b/src/corelib/io/qloggingregistry.cpp index 47fb1fb6b8..0e7eaeea76 100644 --- a/src/corelib/io/qloggingregistry.cpp +++ b/src/corelib/io/qloggingregistry.cpp @@ -317,13 +317,12 @@ void QLoggingRegistry::init() const QMutexLocker locker(®istryMutex); - envRules = std::move(er); - qtConfigRules = std::move(qr); - configRules = std::move(cr); + ruleSets[EnvironmentRules] = std::move(er); + ruleSets[QtConfigRules] = std::move(qr); + ruleSets[ConfigRules] = std::move(cr); - if (!envRules.isEmpty() || !qtConfigRules.isEmpty() || !configRules.isEmpty()) { + if (!ruleSets[EnvironmentRules].isEmpty() || !ruleSets[QtConfigRules].isEmpty() || !ruleSets[ConfigRules].isEmpty()) updateRules(); - } } /*! @@ -367,7 +366,7 @@ void QLoggingRegistry::setApiRules(const QString &content) const QMutexLocker locker(®istryMutex); - apiRules = parser.rules(); + ruleSets[ApiRules] = parser.rules(); updateRules(); } @@ -380,13 +379,6 @@ void QLoggingRegistry::setApiRules(const QString &content) */ void QLoggingRegistry::updateRules() { - rules.clear(); - rules.reserve(qtConfigRules.size() + configRules.size() + apiRules.size() + envRules.size()), - rules += qtConfigRules; - rules += configRules; - rules += apiRules; - rules += envRules; - for (auto it = categories.keyBegin(), end = categories.keyEnd(); it != end; ++it) (*categoryFilter)(*it); } @@ -406,8 +398,7 @@ QLoggingRegistry::installFilter(QLoggingCategory::CategoryFilter filter) QLoggingCategory::CategoryFilter old = categoryFilter; categoryFilter = filter; - for (auto it = categories.keyBegin(), end = categories.keyEnd(); it != end; ++it) - (*categoryFilter)(*it); + updateRules(); return old; } @@ -446,19 +437,22 @@ void QLoggingRegistry::defaultCategoryFilter(QLoggingCategory *cat) } QString categoryName = QLatin1String(cat->categoryName()); - for (const QLoggingRule &item : reg->rules) { - int filterpass = item.pass(categoryName, QtDebugMsg); - if (filterpass != 0) - debug = (filterpass > 0); - filterpass = item.pass(categoryName, QtInfoMsg); - if (filterpass != 0) - info = (filterpass > 0); - filterpass = item.pass(categoryName, QtWarningMsg); - if (filterpass != 0) - warning = (filterpass > 0); - filterpass = item.pass(categoryName, QtCriticalMsg); - if (filterpass != 0) - critical = (filterpass > 0); + + for (const auto &ruleSet : reg->ruleSets) { + for (const auto &rule : ruleSet) { + int filterpass = rule.pass(categoryName, QtDebugMsg); + if (filterpass != 0) + debug = (filterpass > 0); + filterpass = rule.pass(categoryName, QtInfoMsg); + if (filterpass != 0) + info = (filterpass > 0); + filterpass = rule.pass(categoryName, QtWarningMsg); + if (filterpass != 0) + warning = (filterpass > 0); + filterpass = rule.pass(categoryName, QtCriticalMsg); + if (filterpass != 0) + critical = (filterpass > 0); + } } cat->setEnabled(QtDebugMsg, debug); diff --git a/src/corelib/io/qloggingregistry_p.h b/src/corelib/io/qloggingregistry_p.h index 69fc6ea4ec..a68b993cca 100644 --- a/src/corelib/io/qloggingregistry_p.h +++ b/src/corelib/io/qloggingregistry_p.h @@ -130,14 +130,20 @@ private: static void defaultCategoryFilter(QLoggingCategory *category); + enum RuleSet { + // sorted by order in which defaultCategoryFilter considers them: + QtConfigRules, + ConfigRules, + ApiRules, + EnvironmentRules, + + NumRuleSets + }; + QMutex registryMutex; // protected by mutex: - QVector<QLoggingRule> qtConfigRules; - QVector<QLoggingRule> configRules; - QVector<QLoggingRule> envRules; - QVector<QLoggingRule> apiRules; - QVector<QLoggingRule> rules; + QVector<QLoggingRule> ruleSets[NumRuleSets]; QHash<QLoggingCategory*,QtMsgType> categories; QLoggingCategory::CategoryFilter categoryFilter; diff --git a/src/corelib/io/qnoncontiguousbytedevice.cpp b/src/corelib/io/qnoncontiguousbytedevice.cpp index 61299b8aa8..beca6ccbf7 100644 --- a/src/corelib/io/qnoncontiguousbytedevice.cpp +++ b/src/corelib/io/qnoncontiguousbytedevice.cpp @@ -578,3 +578,4 @@ QIODevice* QNonContiguousByteDeviceFactory::wrap(QNonContiguousByteDevice* byteD QT_END_NAMESPACE +#include "moc_qnoncontiguousbytedevice_p.cpp" diff --git a/src/corelib/io/qsavefile.cpp b/src/corelib/io/qsavefile.cpp index d8166014db..0283c5f31f 100644 --- a/src/corelib/io/qsavefile.cpp +++ b/src/corelib/io/qsavefile.cpp @@ -412,4 +412,8 @@ bool QSaveFile::directWriteFallback() const QT_END_NAMESPACE +#ifndef QT_NO_QOBJECT +#include "moc_qsavefile.cpp" +#endif + #endif // QT_NO_TEMPORARYFILE diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp index 24fa00c4d9..850e729987 100644 --- a/src/corelib/io/qsettings.cpp +++ b/src/corelib/io/qsettings.cpp @@ -3515,4 +3515,8 @@ QSettings::Format QSettings::registerFormat(const QString &extension, ReadFunc r QT_END_NAMESPACE +#ifndef QT_BOOTSTRAPPED +#include "moc_qsettings.cpp" +#endif + #endif // QT_NO_SETTINGS diff --git a/src/corelib/io/qstandardpaths.cpp b/src/corelib/io/qstandardpaths.cpp index 4cf3a3e9bd..f2368c3b23 100644 --- a/src/corelib/io/qstandardpaths.cpp +++ b/src/corelib/io/qstandardpaths.cpp @@ -645,4 +645,8 @@ bool QStandardPaths::isTestModeEnabled() QT_END_NAMESPACE +#ifndef QT_NO_QOBJECT +#include "moc_qstandardpaths.cpp" +#endif + #endif // QT_NO_STANDARDPATHS diff --git a/src/corelib/io/qtemporarydir.cpp b/src/corelib/io/qtemporarydir.cpp index b2bf9fce97..ffaee9c683 100644 --- a/src/corelib/io/qtemporarydir.cpp +++ b/src/corelib/io/qtemporarydir.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2017 The Qt Company Ltd. ** Copyright (C) 2016 Intel Corporation. ** Contact: https://www.qt.io/licensing/ ** @@ -198,10 +198,10 @@ void QTemporaryDirPrivate::create(const QString &templateName) \ingroup io - QTemporaryDir is used to create unique temporary dirs safely. - The dir itself is created by the constructor. The name of the + QTemporaryDir is used to create unique temporary directories safely. + The directory itself is created by the constructor. The name of the temporary directory is guaranteed to be unique (i.e., you are - guaranteed to not overwrite an existing dir), and the directory will + guaranteed to not overwrite an existing directory), and the directory will subsequently be removed upon destruction of the QTemporaryDir object. The directory name is either auto-generated, or created based on a template, which is passed to QTemporaryDir's constructor. @@ -214,7 +214,7 @@ void QTemporaryDirPrivate::create(const QString &templateName) created, using isValid(). Do not use \l {QDir::exists()}{exists()}, since a default-constructed QDir represents the current directory, which exists. - The path to the temporary dir can be found by calling path(). + The path to the temporary directory can be found by calling path(). A temporary directory will have some static part of the name and some part that is calculated to be unique. The default path will be diff --git a/src/corelib/io/qtemporaryfile.cpp b/src/corelib/io/qtemporaryfile.cpp index 7aae128796..8a99873fee 100644 --- a/src/corelib/io/qtemporaryfile.cpp +++ b/src/corelib/io/qtemporaryfile.cpp @@ -796,4 +796,6 @@ QT_END_NAMESPACE #endif // QT_NO_TEMPORARYFILE - +#ifndef QT_NO_QOBJECT +#include "moc_qtemporaryfile.cpp" +#endif diff --git a/src/corelib/io/qtextstream.cpp b/src/corelib/io/qtextstream.cpp index 76664a4ade..ee3cb4efcb 100644 --- a/src/corelib/io/qtextstream.cpp +++ b/src/corelib/io/qtextstream.cpp @@ -3187,3 +3187,6 @@ QLocale QTextStream::locale() const QT_END_NAMESPACE +#ifndef QT_NO_QOBJECT +#include "moc_qtextstream_p.cpp" +#endif diff --git a/src/corelib/io/qurlidna.cpp b/src/corelib/io/qurlidna.cpp index 16bb924b17..226bc8ba28 100644 --- a/src/corelib/io/qurlidna.cpp +++ b/src/corelib/io/qurlidna.cpp @@ -2120,31 +2120,52 @@ Q_AUTOTEST_EXPORT void qt_nameprep(QString *source, int from) } } -Q_AUTOTEST_EXPORT bool qt_check_std3rules(const QChar *uc, int len) +static const QChar *qt_find_nonstd3(const QChar *uc, int len, Qt::CaseSensitivity cs) { if (len > 63) - return false; + return uc; for (int i = 0; i < len; ++i) { ushort c = uc[i].unicode(); if (c == '-' && (i == 0 || i == len - 1)) - return false; + return uc + i; // verifying the absence of non-LDH is the same as verifying that // only LDH is present + if (cs == Qt::CaseInsensitive && (c >= 'A' && c <= 'Z')) + continue; if (c == '-' || (c >= '0' && c <= '9') - || (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') //underscore is not supposed to be allowed, but other browser accept it (QTBUG-7434) || c == '_') continue; - return false; + return uc + i; } - return true; + return nullptr; +} + +Q_AUTOTEST_EXPORT bool qt_check_std3rules(const QChar *uc, int len) +{ + return qt_find_nonstd3(uc, len, Qt::CaseInsensitive) == nullptr; } +static bool qt_check_nameprepped_std3(const QChar *in, int len) +{ + // fast path: check for lowercase ASCII + const QChar *firstNonAscii = qt_find_nonstd3(in, len, Qt::CaseSensitive); + if (firstNonAscii == nullptr) { + // everything was lowercase ASCII, digits or hyphen + return true; + } + + const QChar *e = in + len; + QString origin = QString::fromRawData(firstNonAscii, e - firstNonAscii); + QString copy = origin; + qt_nameprep(©, 0); + return origin == copy; +} static inline uint encodeDigit(uint digit) { @@ -2422,8 +2443,8 @@ static bool qt_is_idn_enabled(const QString &domain) return false; int len = domain.size() - idx - 1; - QString tldString(domain.constData() + idx + 1, len); - qt_nameprep(&tldString, 0); + QString tldString = qt_ACE_do(QString::fromRawData(domain.constData() + idx + 1, len), ToAceOnly, ForbidLeadingDot); + len = tldString.size(); const QChar *tld = tldString.constData(); @@ -2546,13 +2567,19 @@ QString qt_ACE_do(const QString &domain, AceOperation op, AceLeadingDot dot) qt_punycodeEncoder(result.constData() + prevLen, result.size() - prevLen, &aceForm); // We use resize()+memcpy() here because we're overwriting the data we've copied + bool appended = false; if (isIdnEnabled) { QString tmp = qt_punycodeDecoder(aceForm); if (tmp.isEmpty()) return QString(); // shouldn't happen, since we've just punycode-encoded it - result.resize(prevLen + tmp.size()); - memcpy(result.data() + prevLen, tmp.constData(), tmp.size() * sizeof(QChar)); - } else { + if (qt_check_nameprepped_std3(tmp.constData(), tmp.size())) { + result.resize(prevLen + tmp.size()); + memcpy(result.data() + prevLen, tmp.constData(), tmp.size() * sizeof(QChar)); + appended = true; + } + } + + if (!appended) { result.resize(prevLen + aceForm.size()); memcpy(result.data() + prevLen, aceForm.constData(), aceForm.size() * sizeof(QChar)); } diff --git a/src/corelib/io/qwindowspipereader.cpp b/src/corelib/io/qwindowspipereader.cpp index 8bd8af3f34..b68e9e6d4b 100644 --- a/src/corelib/io/qwindowspipereader.cpp +++ b/src/corelib/io/qwindowspipereader.cpp @@ -206,13 +206,13 @@ void QWindowsPipeReader::notified(DWORD errorCode, DWORD numberOfBytesRead) void QWindowsPipeReader::startAsyncRead() { const DWORD minReadBufferSize = 4096; - DWORD bytesToRead = qMax(checkPipeState(), minReadBufferSize); + qint64 bytesToRead = qMax(checkPipeState(), minReadBufferSize); if (pipeBroken) return; if (readBufferMaxSize && bytesToRead > (readBufferMaxSize - readBuffer.size())) { bytesToRead = readBufferMaxSize - readBuffer.size(); - if (bytesToRead == 0) { + if (bytesToRead <= 0) { // Buffer is full. User must read data from the buffer // before we can read more from the pipe. return; |