diff options
author | Liang Qi <liang.qi@theqtcompany.com> | 2015-10-14 15:45:35 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@theqtcompany.com> | 2015-10-14 15:45:35 +0200 |
commit | 4456984da780b14572e1ec0f079a4d349ab299bd (patch) | |
tree | f586a281a81c57c91c49e83a5d3ec6c7eece0578 /src/corelib/io | |
parent | e824abd987d77efaa085fe1f9fb514d270798d55 (diff) | |
parent | 281121697340084f7d385eab530f41916789b94d (diff) |
Merge remote-tracking branch 'origin/5.6' into dev
Conflicts:
tests/auto/corelib/io/qfile/tst_qfile.cpp
tests/auto/corelib/io/qprocess/tst_qprocess.cpp
tests/auto/corelib/tools/qversionnumber/qversionnumber.pro
Change-Id: Ia93ce500349d96a2fbf0b4a37b73f088cc505c6e
Diffstat (limited to 'src/corelib/io')
-rw-r--r-- | src/corelib/io/qdebug.cpp | 56 | ||||
-rw-r--r-- | src/corelib/io/qdebug.h | 16 | ||||
-rw-r--r-- | src/corelib/io/qdir.cpp | 2 | ||||
-rw-r--r-- | src/corelib/io/qfilesystemengine.cpp | 2 | ||||
-rw-r--r-- | src/corelib/io/qfilesystementry.cpp | 3 | ||||
-rw-r--r-- | src/corelib/io/qfilesystemwatcher.cpp | 6 | ||||
-rw-r--r-- | src/corelib/io/qfilesystemwatcher_win.cpp | 2 | ||||
-rw-r--r-- | src/corelib/io/qfsfileengine_p.h | 1 | ||||
-rw-r--r-- | src/corelib/io/qiodevice.cpp | 6 | ||||
-rw-r--r-- | src/corelib/io/qlockfile_unix.cpp | 37 | ||||
-rw-r--r-- | src/corelib/io/qprocess.cpp | 12 | ||||
-rw-r--r-- | src/corelib/io/qresource.cpp | 6 | ||||
-rw-r--r-- | src/corelib/io/qsettings.cpp | 9 | ||||
-rw-r--r-- | src/corelib/io/qsettings_mac.cpp | 6 | ||||
-rw-r--r-- | src/corelib/io/qstandardpaths_win.cpp | 2 | ||||
-rw-r--r-- | src/corelib/io/qtemporarydir.cpp | 4 | ||||
-rw-r--r-- | src/corelib/io/qtextstream.cpp | 2 | ||||
-rw-r--r-- | src/corelib/io/qtldurl.cpp | 15 | ||||
-rw-r--r-- | src/corelib/io/qurl.cpp | 2 | ||||
-rw-r--r-- | src/corelib/io/qwindowspipereader.cpp | 2 | ||||
-rw-r--r-- | src/corelib/io/qwindowspipewriter.cpp | 54 |
21 files changed, 178 insertions, 67 deletions
diff --git a/src/corelib/io/qdebug.cpp b/src/corelib/io/qdebug.cpp index 13eccce9da..81af96b96b 100644 --- a/src/corelib/io/qdebug.cpp +++ b/src/corelib/io/qdebug.cpp @@ -696,6 +696,62 @@ QDebug &QDebug::resetFormat() */ /*! + \fn QDebug operator<<(QDebug stream, const QList<T> &list) + \relates QDebug + + Writes the contents of \a list to \a stream. \c T needs to + support streaming into QDebug. +*/ + +/*! + \fn QDebug operator<<(QDebug stream, const QVector<T> &vector) + \relates QDebug + + Writes the contents of \a vector to \a stream. \c T needs to + support streaming into QDebug. +*/ + +/*! + \fn QDebug operator<<(QDebug stream, const QSet<T> &set) + \relates QDebug + + Writes the contents of \a set to \a stream. \c T needs to + support streaming into QDebug. +*/ + +/*! + \fn QDebug operator<<(QDebug stream, const QMap<Key, T> &map) + \relates QDebug + + Writes the contents of \a map to \a stream. Both \c Key and + \c T need to support streaming into QDebug. +*/ + +/*! + \fn QDebug operator<<(QDebug stream, const QHash<Key, T> &hash) + \relates QDebug + + Writes the contents of \a hash to \a stream. Both \c Key and + \c T need to support streaming into QDebug. +*/ + +/*! + \fn QDebug operator<<(QDebug stream, const QPair<T1, T2> &pair) + \relates QDebug + + Writes the contents of \a pair to \a stream. Both \c T1 and + \c T2 need to support streaming into QDebug. +*/ + +/*! + \fn QDebug operator<<(QDebug stream, const QFlags<T> &flag) + \relates QDebug + \since 4.7 + + Writes \a flag to \a stream. +*/ + +/*! \class QDebugStateSaver \inmodule QtCore \brief Convenience class for custom QDebug operators diff --git a/src/corelib/io/qdebug.h b/src/corelib/io/qdebug.h index 2f626dfc1f..b1a0396f35 100644 --- a/src/corelib/io/qdebug.h +++ b/src/corelib/io/qdebug.h @@ -216,12 +216,12 @@ inline QDebug operator<<(QDebug debug, const QVector<T> &vec) return operator<<(debug, vec.toList()); } -template <class aKey, class aT> -inline QDebug operator<<(QDebug debug, const QMap<aKey, aT> &map) +template <class Key, class T> +inline QDebug operator<<(QDebug debug, const QMap<Key, T> &map) { const bool oldSetting = debug.autoInsertSpaces(); debug.nospace() << "QMap("; - for (typename QMap<aKey, aT>::const_iterator it = map.constBegin(); + for (typename QMap<Key, T>::const_iterator it = map.constBegin(); it != map.constEnd(); ++it) { debug << '(' << it.key() << ", " << it.value() << ')'; } @@ -230,12 +230,12 @@ inline QDebug operator<<(QDebug debug, const QMap<aKey, aT> &map) return debug.maybeSpace(); } -template <class aKey, class aT> -inline QDebug operator<<(QDebug debug, const QHash<aKey, aT> &hash) +template <class Key, class T> +inline QDebug operator<<(QDebug debug, const QHash<Key, T> &hash) { const bool oldSetting = debug.autoInsertSpaces(); debug.nospace() << "QHash("; - for (typename QHash<aKey, aT>::const_iterator it = hash.constBegin(); + for (typename QHash<Key, T>::const_iterator it = hash.constBegin(); it != hash.constEnd(); ++it) debug << '(' << it.key() << ", " << it.value() << ')'; debug << ')'; @@ -276,7 +276,7 @@ inline QDebug operator<<(QDebug debug, const QContiguousCache<T> &cache) return debug.maybeSpace(); } -#ifndef QT_NO_QOBJECT +#if !defined(QT_NO_QOBJECT) && !defined(Q_QDOC) Q_CORE_EXPORT QDebug qt_QMetaEnum_debugOperator(QDebug&, int value, const QMetaObject *meta, const char *name); Q_CORE_EXPORT QDebug qt_QMetaEnum_flagDebugOperator(QDebug &dbg, quint64 value, const QMetaObject *meta, const char *name); @@ -305,7 +305,7 @@ inline typename QtPrivate::QEnableIf< !QtPrivate::IsQEnumHelper<T>::Value && !QtPrivate::IsQEnumHelper<QFlags<T> >::Value, QDebug>::Type qt_QMetaEnum_flagDebugOperator_helper(QDebug debug, const QFlags<T> &flags) -#else // !QT_NO_QOBJECT +#else // !QT_NO_QOBJECT && !Q_QDOC template <class T> inline QDebug qt_QMetaEnum_flagDebugOperator_helper(QDebug debug, const QFlags<T> &flags) #endif diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index e1d9858a66..4d2b36632f 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -138,7 +138,7 @@ inline QChar QDirPrivate::getFilterSepChar(const QString &nameFilter) // static inline QStringList QDirPrivate::splitFilters(const QString &nameFilter, QChar sep) { - if (sep == 0) + if (sep.isNull()) sep = getFilterSepChar(nameFilter); QStringList ret = nameFilter.split(sep); for (int i = 0; i < ret.count(); ++i) diff --git a/src/corelib/io/qfilesystemengine.cpp b/src/corelib/io/qfilesystemengine.cpp index e4dec2b7fb..a49d69d447 100644 --- a/src/corelib/io/qfilesystemengine.cpp +++ b/src/corelib/io/qfilesystemengine.cpp @@ -152,7 +152,7 @@ static bool _q_resolveEntryAndCreateLegacyEngine_recursive(QFileSystemEntry &ent const QStringList &paths = QDir::searchPaths(filePath.left(prefixSeparator)); for (int i = 0; i < paths.count(); i++) { - entry = QFileSystemEntry(QDir::cleanPath(paths.at(i) % QLatin1Char('/') % filePath.mid(prefixSeparator + 1))); + entry = QFileSystemEntry(QDir::cleanPath(paths.at(i) % QLatin1Char('/') % filePath.midRef(prefixSeparator + 1))); // Recurse! if (_q_resolveEntryAndCreateLegacyEngine_recursive(entry, data, engine, true)) return true; diff --git a/src/corelib/io/qfilesystementry.cpp b/src/corelib/io/qfilesystementry.cpp index 79f16a0839..709970e3ac 100644 --- a/src/corelib/io/qfilesystementry.cpp +++ b/src/corelib/io/qfilesystementry.cpp @@ -53,8 +53,7 @@ static bool isUncRoot(const QString &server) if (idx == -1 || idx + 1 == localPath.length()) return true; - localPath = localPath.right(localPath.length() - idx - 1).trimmed(); - return localPath.isEmpty(); + return localPath.rightRef(localPath.length() - idx - 1).trimmed().isEmpty(); } static inline QString fixIfRelativeUncPath(const QString &path) diff --git a/src/corelib/io/qfilesystemwatcher.cpp b/src/corelib/io/qfilesystemwatcher.cpp index 7fc3049f46..23a2fbecdb 100644 --- a/src/corelib/io/qfilesystemwatcher.cpp +++ b/src/corelib/io/qfilesystemwatcher.cpp @@ -296,7 +296,9 @@ QStringList QFileSystemWatcher::addPaths(const QStringList &paths) QFileSystemWatcherEngine *engine = 0; - if(!objectName().startsWith(QLatin1String("_qt_autotest_force_engine_"))) { + const QString on = objectName(); + + if (!on.startsWith(QLatin1String("_qt_autotest_force_engine_"))) { // Normal runtime case - search intelligently for best engine if(d->native) { engine = d->native; @@ -307,7 +309,7 @@ QStringList QFileSystemWatcher::addPaths(const QStringList &paths) } else { // Autotest override case - use the explicitly selected engine only - QString forceName = objectName().mid(26); + const QStringRef forceName = on.midRef(26); if(forceName == QLatin1String("poller")) { qDebug() << "QFileSystemWatcher: skipping native engine, using only polling engine"; d_func()->initPollerEngine(); diff --git a/src/corelib/io/qfilesystemwatcher_win.cpp b/src/corelib/io/qfilesystemwatcher_win.cpp index 4907a20a5f..410753868e 100644 --- a/src/corelib/io/qfilesystemwatcher_win.cpp +++ b/src/corelib/io/qfilesystemwatcher_win.cpp @@ -186,7 +186,7 @@ QStringList QWindowsFileSystemWatcherEngine::addPaths(const QStringList &paths, } if (!found) { QWindowsFileSystemWatcherEngineThread *thread = new QWindowsFileSystemWatcherEngineThread(); - DEBUG() << " ###Creating new thread" << thread << "(" << (threads.count()+1) << "threads)"; + DEBUG() << " ###Creating new thread" << thread << '(' << (threads.count()+1) << "threads)"; thread->handles.append(handle.handle); thread->handleForDir.insert(QFileSystemWatcherPathKey(absolutePath), handle); diff --git a/src/corelib/io/qfsfileengine_p.h b/src/corelib/io/qfsfileengine_p.h index 8ba05fa8b9..0a7f551672 100644 --- a/src/corelib/io/qfsfileengine_p.h +++ b/src/corelib/io/qfsfileengine_p.h @@ -199,7 +199,6 @@ public: bool closeFileHandle; mutable uint is_sequential : 2; - mutable uint could_stat : 1; mutable uint tried_stat : 1; #if !defined(Q_OS_WINCE) mutable uint need_lstat : 1; diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp index 84a6a1d9cb..c80c78bd3b 100644 --- a/src/corelib/io/qiodevice.cpp +++ b/src/corelib/io/qiodevice.cpp @@ -83,6 +83,7 @@ void debugBinaryString(const char *data, qint64 maxlen) static void checkWarnMessage(const QIODevice *device, const char *function, const char *what) { +#ifndef QT_NO_WARNING_OUTPUT QDebug d = qWarning(); d.noquote(); d.nospace(); @@ -98,6 +99,11 @@ static void checkWarnMessage(const QIODevice *device, const char *function, cons Q_UNUSED(device) #endif // !QT_NO_QOBJECT d << ": " << what; +#else + Q_UNUSED(device); + Q_UNUSED(function); + Q_UNUSED(what); +#endif // QT_NO_WARNING_OUTPUT } #define CHECK_MAXLEN(function, returnType) \ diff --git a/src/corelib/io/qlockfile_unix.cpp b/src/corelib/io/qlockfile_unix.cpp index 27f8a97fd4..365f3e07ab 100644 --- a/src/corelib/io/qlockfile_unix.cpp +++ b/src/corelib/io/qlockfile_unix.cpp @@ -56,7 +56,13 @@ # include <cstdio> #elif defined(Q_OS_BSD4) && !defined(Q_OS_IOS) # include <sys/user.h> +# if defined(__GLIBC__) && defined(__FreeBSD_kernel__) +# include <sys/cdefs.h> +# include <sys/param.h> +# include <sys/sysctl.h> +# else # include <libutil.h> +# endif #endif QT_BEGIN_NAMESPACE @@ -165,8 +171,10 @@ QLockFile::LockError QLockFilePrivate::tryLock_sys() } } // Ensure nobody else can delete the file while we have it - if (!setNativeLocks(fd)) - qWarning() << "setNativeLocks failed:" << strerror(errno); + if (!setNativeLocks(fd)) { + const int errnoSaved = errno; + qWarning() << "setNativeLocks failed:" << qt_error_string(errnoSaved); + } if (qt_write_loop(fd, fileData.constData(), fileData.size()) < fileData.size()) { close(fd); @@ -178,6 +186,13 @@ QLockFile::LockError QLockFilePrivate::tryLock_sys() // We hold the lock, continue. fileHandle = fd; + // Sync to disk if possible. Ignore errors (e.g. not supported). +#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0 + fdatasync(fileHandle); +#else + fsync(fileHandle); +#endif + return QLockFile::NoError; } @@ -234,9 +249,27 @@ QString QLockFilePrivate::processNameByPid(qint64 pid) buf[len] = 0; return QFileInfo(QFile::decodeName(buf)).fileName(); #elif defined(Q_OS_BSD4) && !defined(Q_OS_IOS) +# if defined(__GLIBC__) && defined(__FreeBSD_kernel__) + int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, pid }; + size_t len = 0; + if (sysctl(mib, 4, NULL, &len, NULL, 0) < 0) + return QString(); + kinfo_proc *proc = static_cast<kinfo_proc *>(malloc(len)); +# else kinfo_proc *proc = kinfo_getproc(pid); +# endif if (!proc) return QString(); +# if defined(__GLIBC__) && defined(__FreeBSD_kernel__) + if (sysctl(mib, 4, proc, &len, NULL, 0) < 0) { + free(proc); + return QString(); + } + if (proc->ki_pid != pid) { + free(proc); + return QString(); + } +# endif QString name = QFile::decodeName(proc->ki_comm); free(proc); return name; diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index ecda86a91d..3539c75548 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -156,16 +156,8 @@ QStringList QProcessEnvironmentPrivate::toList() const { QStringList result; result.reserve(hash.size()); - Hash::ConstIterator it = hash.constBegin(), - end = hash.constEnd(); - for ( ; it != end; ++it) { - QString data = nameToString(it.key()); - QString value = valueToString(it.value()); - data.reserve(data.length() + value.length() + 1); - data.append(QLatin1Char('=')); - data.append(value); - result << data; - } + for (Hash::const_iterator it = hash.cbegin(), end = hash.cend(); it != end; ++it) + result << nameToString(it.key()) + QLatin1Char('=') + valueToString(it.value()); return result; } diff --git a/src/corelib/io/qresource.cpp b/src/corelib/io/qresource.cpp index 4e6079306b..0674ef34e0 100644 --- a/src/corelib/io/qresource.cpp +++ b/src/corelib/io/qresource.cpp @@ -800,8 +800,8 @@ bool QResourceRoot::mappingRootSubdir(const QString &path, QString *match) const { const QString root = mappingRoot(); if(!root.isEmpty()) { - const QStringList root_segments = root.split(QLatin1Char('/'), QString::SkipEmptyParts), - path_segments = path.split(QLatin1Char('/'), QString::SkipEmptyParts); + const QVector<QStringRef> root_segments = root.splitRef(QLatin1Char('/'), QString::SkipEmptyParts), + path_segments = path.splitRef(QLatin1Char('/'), QString::SkipEmptyParts); if(path_segments.size() <= root_segments.size()) { int matched = 0; for(int i = 0; i < path_segments.size(); ++i) { @@ -811,7 +811,7 @@ bool QResourceRoot::mappingRootSubdir(const QString &path, QString *match) const } if(matched == path_segments.size()) { if(match && root_segments.size() > matched) - *match = root_segments.at(matched); + *match = root_segments.at(matched).toString(); return true; } } diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp index 654d688c53..3460753fbe 100644 --- a/src/corelib/io/qsettings.cpp +++ b/src/corelib/io/qsettings.cpp @@ -488,7 +488,7 @@ QVariant QSettingsPrivate::stringToVariant(const QString &s) if (s.startsWith(QLatin1Char('@'))) { if (s.endsWith(QLatin1Char(')'))) { if (s.startsWith(QLatin1String("@ByteArray("))) { - return QVariant(s.toLatin1().mid(11, s.size() - 12)); + return QVariant(s.midRef(11, s.size() - 12).toLatin1()); } else if (s.startsWith(QLatin1String("@Variant(")) || s.startsWith(QLatin1String("@DateTime("))) { #ifndef QT_NO_DATASTREAM @@ -501,7 +501,7 @@ QVariant QSettingsPrivate::stringToVariant(const QString &s) version = QDataStream::Qt_4_0; offset = 9; } - QByteArray a(s.toLatin1().mid(offset)); + QByteArray a = s.midRef(offset).toLatin1(); QDataStream stream(&a, QIODevice::ReadOnly); stream.setVersion(version); QVariant result; @@ -632,8 +632,9 @@ void QSettingsPrivate::iniEscapedString(const QString &str, QByteArray &result, int startPos = result.size(); result.reserve(startPos + str.size() * 3 / 2); + const QChar *unicode = str.unicode(); for (i = 0; i < str.size(); ++i) { - uint ch = str.at(i).unicode(); + uint ch = unicode[i].unicode(); if (ch == ';' || ch == ',' || ch == '=') needsQuotes = true; @@ -687,7 +688,7 @@ void QSettingsPrivate::iniEscapedString(const QString &str, QByteArray &result, #ifndef QT_NO_TEXTCODEC } else if (useCodec) { // slow - result += codec->fromUnicode(str.at(i)); + result += codec->fromUnicode(&unicode[i], 1); #endif } else { result += (char)ch; diff --git a/src/corelib/io/qsettings_mac.cpp b/src/corelib/io/qsettings_mac.cpp index 1ad198b990..e0b317b4c2 100644 --- a/src/corelib/io/qsettings_mac.cpp +++ b/src/corelib/io/qsettings_mac.cpp @@ -386,7 +386,7 @@ QMacSettingsPrivate::QMacSettingsPrivate(QSettings::Scope scope, const QString & if (main_bundle_identifier != NULL) { QString bundle_identifier(qtKey(main_bundle_identifier)); // CFBundleGetIdentifier returns identifier separated by slashes rather than periods. - QStringList bundle_identifier_components = bundle_identifier.split(QLatin1String("/")); + QStringList bundle_identifier_components = bundle_identifier.split(QLatin1Char('/')); // pre-reverse them so that when they get reversed again below, they are in the com.company.product format. QStringList bundle_identifier_components_reversed; for (int i=0; i<bundle_identifier_components.size(); ++i) { @@ -403,11 +403,11 @@ QMacSettingsPrivate::QMacSettingsPrivate(QSettings::Scope scope, const QString & } while ((nextDot = domainName.indexOf(QLatin1Char('.'), curPos)) != -1) { - javaPackageName.prepend(domainName.mid(curPos, nextDot - curPos)); + javaPackageName.prepend(domainName.midRef(curPos, nextDot - curPos)); javaPackageName.prepend(QLatin1Char('.')); curPos = nextDot + 1; } - javaPackageName.prepend(domainName.mid(curPos)); + javaPackageName.prepend(domainName.midRef(curPos)); javaPackageName = javaPackageName.toLower(); if (curPos == 0) javaPackageName.prepend(QLatin1String("com.")); diff --git a/src/corelib/io/qstandardpaths_win.cpp b/src/corelib/io/qstandardpaths_win.cpp index 0a13f94f05..ed1c14ad8a 100644 --- a/src/corelib/io/qstandardpaths_win.cpp +++ b/src/corelib/io/qstandardpaths_win.cpp @@ -200,7 +200,7 @@ QStringList QStandardPaths::standardLocations(StandardLocation type) case AppDataLocation: case AppLocalDataLocation: case GenericDataLocation: - if (SHGetSpecialFolderPath(0, path, clsidForAppDataLocation(type), FALSE)) { + if (SHGetSpecialFolderPath(0, path, CSIDL_COMMON_APPDATA, FALSE)) { QString result = convertCharArray(path); if (type != GenericDataLocation && type != GenericConfigLocation) { #ifndef QT_BOOTSTRAPPED diff --git a/src/corelib/io/qtemporarydir.cpp b/src/corelib/io/qtemporarydir.cpp index c7150d7b33..71436c6497 100644 --- a/src/corelib/io/qtemporarydir.cpp +++ b/src/corelib/io/qtemporarydir.cpp @@ -49,6 +49,10 @@ #include <private/qfilesystemengine_p.h> #endif +#if !defined(Q_OS_WIN) +#include <errno.h> +#endif + QT_BEGIN_NAMESPACE //************* QTemporaryDirPrivate diff --git a/src/corelib/io/qtextstream.cpp b/src/corelib/io/qtextstream.cpp index ca3be9b7e0..ccf832e2e8 100644 --- a/src/corelib/io/qtextstream.cpp +++ b/src/corelib/io/qtextstream.cpp @@ -2858,7 +2858,7 @@ QTextStream &endl(QTextStream &stream) /*! \relates QTextStream - Calls \l{QTextStream::flush()}{flush()} on \a stream and returns \a stream. + Calls QTextStream::flush() on \a stream and returns \a stream. \sa endl(), reset(), {QTextStream manipulators} */ diff --git a/src/corelib/io/qtldurl.cpp b/src/corelib/io/qtldurl.cpp index d68d0ddf46..265055083e 100644 --- a/src/corelib/io/qtldurl.cpp +++ b/src/corelib/io/qtldurl.cpp @@ -99,19 +99,14 @@ Q_CORE_EXPORT bool qIsEffectiveTLD(const QString &domain) if (containsTLDEntry(domain)) return true; - if (domain.contains(QLatin1Char('.'))) { - int count = domain.size() - domain.indexOf(QLatin1Char('.')); - QString wildCardDomain; - wildCardDomain.reserve(count + 1); - wildCardDomain.append(QLatin1Char('*')); - wildCardDomain.append(domain.right(count)); + const int dot = domain.indexOf(QLatin1Char('.')); + if (dot >= 0) { + int count = domain.size() - dot; + QString wildCardDomain = QLatin1Char('*') + domain.rightRef(count); // 2. if table contains '*.bar.com', // test if table contains '!foo.bar.com' if (containsTLDEntry(wildCardDomain)) { - QString exceptionDomain; - exceptionDomain.reserve(domain.size() + 1); - exceptionDomain.append(QLatin1Char('!')); - exceptionDomain.append(domain); + QString exceptionDomain = QLatin1Char('!') + domain; return (! containsTLDEntry(exceptionDomain)); } } diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index 89f5aad97f..9bf359222a 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -2411,8 +2411,8 @@ void QUrl::setPort(int port) d->clearError(); if (port < -1 || port > 65535) { - port = -1; d->setError(QUrlPrivate::InvalidPortError, QString::number(port), 0); + port = -1; } d->port = port; diff --git a/src/corelib/io/qwindowspipereader.cpp b/src/corelib/io/qwindowspipereader.cpp index 2cc5741250..a49fcdaf9f 100644 --- a/src/corelib/io/qwindowspipereader.cpp +++ b/src/corelib/io/qwindowspipereader.cpp @@ -187,7 +187,7 @@ void QWindowsPipeReader::notified(quint32 numberOfBytesRead, quint32 errorCode, pipeBroken = true; break; default: - emit winError(errorCode, QLatin1String("QWindowsPipeReader::completeAsyncRead")); + emit winError(errorCode, QLatin1String("QWindowsPipeReader::notified")); pipeBroken = true; break; } diff --git a/src/corelib/io/qwindowspipewriter.cpp b/src/corelib/io/qwindowspipewriter.cpp index 57053f129a..fd14523d45 100644 --- a/src/corelib/io/qwindowspipewriter.cpp +++ b/src/corelib/io/qwindowspipewriter.cpp @@ -90,11 +90,38 @@ qint64 QWindowsPipeWriter::write(const char *ptr, qint64 maxlen) return maxlen; } +class QPipeWriterOverlapped +{ +public: + QPipeWriterOverlapped() + { + overlapped.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); + } + + ~QPipeWriterOverlapped() + { + CloseHandle(overlapped.hEvent); + } + + void prepare() + { + const HANDLE hEvent = overlapped.hEvent; + ZeroMemory(&overlapped, sizeof overlapped); + overlapped.hEvent = hEvent; + } + + OVERLAPPED *operator&() + { + return &overlapped; + } + +private: + OVERLAPPED overlapped; +}; + void QWindowsPipeWriter::run() { - OVERLAPPED overl; - memset(&overl, 0, sizeof overl); - overl.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); + QPipeWriterOverlapped overl; forever { lock.lock(); while(data.isEmpty() && (!quitNow)) { @@ -115,26 +142,24 @@ void QWindowsPipeWriter::run() const char *ptrData = copy.data(); qint64 maxlen = copy.size(); qint64 totalWritten = 0; - overl.Offset = 0; - overl.OffsetHigh = 0; + overl.prepare(); while ((!quitNow) && totalWritten < maxlen) { DWORD written = 0; if (!WriteFile(writePipe, ptrData + totalWritten, maxlen - totalWritten, &written, &overl)) { - - if (GetLastError() == 0xE8/*NT_STATUS_INVALID_USER_BUFFER*/) { + const DWORD writeError = GetLastError(); + if (writeError == 0xE8/*NT_STATUS_INVALID_USER_BUFFER*/) { // give the os a rest msleep(100); continue; } #ifndef Q_OS_WINCE - if (GetLastError() == ERROR_IO_PENDING) { - if (!GetOverlappedResult(writePipe, &overl, &written, TRUE)) { - CloseHandle(overl.hEvent); - return; - } - } else { - CloseHandle(overl.hEvent); + if (writeError != ERROR_IO_PENDING) { + qErrnoWarning(writeError, "QWindowsPipeWriter: async WriteFile failed."); + return; + } + if (!GetOverlappedResult(writePipe, &overl, &written, TRUE)) { + qErrnoWarning(GetLastError(), "QWindowsPipeWriter: GetOverlappedResult failed."); return; } #else @@ -154,7 +179,6 @@ void QWindowsPipeWriter::run() emit bytesWritten(totalWritten); emit canWrite(); } - CloseHandle(overl.hEvent); } #endif //QT_NO_THREAD |