diff options
author | Liang Qi <liang.qi@qt.io> | 2017-12-08 13:56:16 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2017-12-08 13:56:17 +0100 |
commit | 812bb236dd1622896b6a0ca9bbe1334a69855aa2 (patch) | |
tree | 94031beabaf904e2380740cec8951b3c1152203c /src/corelib | |
parent | 79d78d814acad4e183e281aea9b131f396abe3fb (diff) | |
parent | 50117d738af526cbfbd5afa50b9a501acb0fb9ce (diff) |
Merge remote-tracking branch 'origin/5.10.0' into 5.10
Change-Id: I6dcf85067ec226136c207ea69ca9d66736c84db5
Diffstat (limited to 'src/corelib')
26 files changed, 172 insertions, 110 deletions
diff --git a/src/corelib/configure.json b/src/corelib/configure.json index 8067ca70f1..bf44f2649d 100644 --- a/src/corelib/configure.json +++ b/src/corelib/configure.json @@ -349,6 +349,15 @@ "qmake": "linux: LIBS += -lpthread -lrt" } }, + "linkat": { + "label": "linkat()", + "type": "compile", + "test": { + "head": "#define _ATFILE_SOURCE 1", + "include": [ "fcntl.h", "unistd.h" ], + "main": "linkat(AT_FDCWD, \"foo\", AT_FDCWD, \"bar\", AT_SYMLINK_FOLLOW);" + } + }, "ppoll": { "label": "ppoll()", "type": "compile", @@ -540,6 +549,12 @@ "condition": "libs.journald", "output": [ "privateFeature" ] }, + "linkat": { + "label": "linkat()", + "autoDetect": "config.linux", + "condition": "tests.linkat", + "output": [ "privateFeature" ] + }, "std-atomic64": { "label": "64 bit atomic operations", "condition": "libs.libatomic", diff --git a/src/corelib/doc/qtcore.qdocconf b/src/corelib/doc/qtcore.qdocconf index 3d64708def..5a42e21845 100644 --- a/src/corelib/doc/qtcore.qdocconf +++ b/src/corelib/doc/qtcore.qdocconf @@ -45,5 +45,8 @@ excludedirs += snippets excludefiles += ../../../examples/widgets/tools/customcompleter/doc/src/customcompleter.qdoc \ ../../../examples/widgets/tools/codecs/doc/src/codecs.qdoc +manifestmeta.highlighted.names = "QtCore/JSON Save Game Example" \ + "QtCore/Local Fortune*" + navigation.landingpage = "Qt Core" navigation.cppclassespage = "Qt Core C++ Classes" diff --git a/src/corelib/global/minimum-linux_p.h b/src/corelib/global/minimum-linux_p.h index 324744b856..bad2488b4d 100644 --- a/src/corelib/global/minimum-linux_p.h +++ b/src/corelib/global/minimum-linux_p.h @@ -67,7 +67,7 @@ QT_BEGIN_NAMESPACE * - inotify_init1 before 2.6.12-rc12 * - futex(2) before 2.6.12-rc12 * - FUTEX_WAKE_OP 2.6.14 FUTEX_OP - * - linkat(2) 2.6.17 O_TMPFILE + * - linkat(2) 2.6.17 O_TMPFILE && QT_CONFIG(linkat) * - FUTEX_PRIVATE_FLAG 2.6.22 * - O_CLOEXEC 2.6.23 * - eventfd 2.6.23 diff --git a/src/corelib/global/qconfig-bootstrapped.h b/src/corelib/global/qconfig-bootstrapped.h index 2164d7f21f..dabb715607 100644 --- a/src/corelib/global/qconfig-bootstrapped.h +++ b/src/corelib/global/qconfig-bootstrapped.h @@ -87,6 +87,11 @@ #define QT_FEATURE_futimens -1 #define QT_FEATURE_futimes -1 #define QT_FEATURE_library -1 +#ifdef __linux__ +# define QT_FEATURE_linkat 1 +#else +# define QT_FEATURE_linkat -1 +#endif #define QT_NO_QOBJECT #define QT_FEATURE_process -1 #define QT_FEATURE_renameat2 -1 diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 36b7560398..2c2dcb663b 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -160,8 +160,8 @@ Q_STATIC_ASSERT_X(std::numeric_limits<float>::radix == 2, // not required by the definition of size_t, but we depend on this Q_STATIC_ASSERT_X(sizeof(size_t) == sizeof(void *), "size_t and a pointer don't have the same size"); -Q_STATIC_ASSERT(sizeof(size_t) == sizeof(qssize_t)); // implied by the definition -Q_STATIC_ASSERT((std::is_same<qssize_t, qptrdiff>::value)); +Q_STATIC_ASSERT(sizeof(size_t) == sizeof(qsizetype)); // implied by the definition +Q_STATIC_ASSERT((std::is_same<qsizetype, qptrdiff>::value)); /*! \class QFlag @@ -824,7 +824,7 @@ Q_STATIC_ASSERT((std::is_same<qssize_t, qptrdiff>::value)); */ /*! - \typedef qssize_t + \typedef qsizetype \relates <QtGlobal> \since 5.10 @@ -833,7 +833,7 @@ Q_STATIC_ASSERT((std::is_same<qssize_t, qptrdiff>::value)); This type is guaranteed to be the same size as a \c size_t on all platforms supported by Qt. - Note that qssize_t is signed. Use \c size_t for unsigned values. + Note that qsizetype is signed. Use \c size_t for unsigned values. \sa qptrdiff */ diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 7b691ca59e..4e7c1b59be 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -439,7 +439,7 @@ namespace QtPrivate { sizeof(void *) == sizeof(quintptr) && sizeof(void *) == sizeof(qptrdiff) - size_t and qssize_t are not guaranteed to be the same size as a pointer, but + size_t and qsizetype are not guaranteed to be the same size as a pointer, but they usually are. */ template <int> struct QIntegerForSize; @@ -456,7 +456,7 @@ typedef QIntegerForSize<Q_PROCESSOR_WORDSIZE>::Unsigned qregisteruint; typedef QIntegerForSizeof<void*>::Unsigned quintptr; typedef QIntegerForSizeof<void*>::Signed qptrdiff; typedef qptrdiff qintptr; -using qssize_t = QIntegerForSizeof<std::size_t>::Signed; +using qsizetype = QIntegerForSizeof<std::size_t>::Signed; /* moc compats (signals/slots) */ #ifndef QT_MOC_COMPAT diff --git a/src/corelib/global/qrandom.cpp b/src/corelib/global/qrandom.cpp index b6e8e03909..5cb3e75791 100644 --- a/src/corelib/global/qrandom.cpp +++ b/src/corelib/global/qrandom.cpp @@ -93,7 +93,7 @@ DECLSPEC_IMPORT BOOLEAN WINAPI SystemFunction036(PVOID RandomBuffer, ULONG Rando QT_BEGIN_NAMESPACE #if defined(Q_PROCESSOR_X86) && QT_COMPILER_SUPPORTS_HERE(RDRND) -static qssize_t qt_random_cpu(void *buffer, qssize_t count) Q_DECL_NOTHROW; +static qsizetype qt_random_cpu(void *buffer, qsizetype count) Q_DECL_NOTHROW; # ifdef Q_PROCESSOR_X86_64 # define _rdrandXX_step _rdrand64_step @@ -101,7 +101,7 @@ static qssize_t qt_random_cpu(void *buffer, qssize_t count) Q_DECL_NOTHROW; # define _rdrandXX_step _rdrand32_step # endif -static QT_FUNCTION_TARGET(RDRND) qssize_t qt_random_cpu(void *buffer, qssize_t count) Q_DECL_NOTHROW +static QT_FUNCTION_TARGET(RDRND) qsizetype qt_random_cpu(void *buffer, qsizetype count) Q_DECL_NOTHROW { unsigned *ptr = reinterpret_cast<unsigned *>(buffer); unsigned *end = ptr + count; @@ -122,7 +122,7 @@ out: return ptr - reinterpret_cast<unsigned *>(buffer); } #else -static qssize_t qt_random_cpu(void *, qssize_t) +static qsizetype qt_random_cpu(void *, qsizetype) { return 0; } @@ -136,10 +136,10 @@ enum { struct QRandomGenerator::SystemGenerator { #if QT_CONFIG(getentropy) - static qssize_t fillBuffer(void *buffer, qssize_t count) Q_DECL_NOTHROW + static qsizetype fillBuffer(void *buffer, qsizetype count) Q_DECL_NOTHROW { // getentropy can read at most 256 bytes, so break the reading - qssize_t read = 0; + qsizetype read = 0; while (count - read > 256) { // getentropy can't fail under normal circumstances int ret = getentropy(reinterpret_cast<uchar *>(buffer) + read, 256); @@ -195,24 +195,24 @@ struct QRandomGenerator::SystemGenerator Q_DECL_CONSTEXPR SystemGenerator() : fdp1 Q_BASIC_ATOMIC_INITIALIZER(0) {} - qssize_t fillBuffer(void *buffer, qssize_t count) + qsizetype fillBuffer(void *buffer, qsizetype count) { int fd = openDevice(); if (Q_UNLIKELY(fd < 0)) return 0; qint64 n = qt_safe_read(fd, buffer, count); - return qMax<qssize_t>(n, 0); // ignore any errors + return qMax<qsizetype>(n, 0); // ignore any errors } #elif defined(Q_OS_WIN) && !defined(Q_OS_WINRT) - qssize_t fillBuffer(void *buffer, qssize_t count) Q_DECL_NOTHROW + qsizetype fillBuffer(void *buffer, qsizetype count) Q_DECL_NOTHROW { auto RtlGenRandom = SystemFunction036; return RtlGenRandom(buffer, ULONG(count)) ? count: 0; } #elif defined(Q_OS_WINRT) - qssize_t fillBuffer(void *, qssize_t) Q_DECL_NOTHROW + qsizetype fillBuffer(void *, qsizetype) Q_DECL_NOTHROW { // always use the fallback return 0; @@ -243,7 +243,7 @@ struct QRandomGenerator::SystemGenerator #if defined(Q_OS_WIN) static void fallback_update_seed(unsigned) {} -static void fallback_fill(quint32 *ptr, qssize_t left) Q_DECL_NOTHROW +static void fallback_fill(quint32 *ptr, qsizetype left) Q_DECL_NOTHROW { // on Windows, rand_s is a high-quality random number generator // and it requires no seeding @@ -255,14 +255,14 @@ static void fallback_fill(quint32 *ptr, qssize_t left) Q_DECL_NOTHROW } #elif QT_CONFIG(getentropy) static void fallback_update_seed(unsigned) {} -static void fallback_fill(quint32 *, qssize_t) Q_DECL_NOTHROW +static void fallback_fill(quint32 *, qsizetype) Q_DECL_NOTHROW { // no fallback necessary, getentropy cannot fail under normal circumstances Q_UNREACHABLE(); } #elif defined(Q_OS_BSD4) static void fallback_update_seed(unsigned) {} -static void fallback_fill(quint32 *ptr, qssize_t left) Q_DECL_NOTHROW +static void fallback_fill(quint32 *ptr, qsizetype left) Q_DECL_NOTHROW { // BSDs have arc4random(4) and these work even in chroot(2) arc4random_buf(ptr, left * sizeof(*ptr)); @@ -281,7 +281,7 @@ Q_NEVER_INLINE #ifdef Q_CC_GNU __attribute__((cold)) // this function is pretty big, so optimize for size #endif -static void fallback_fill(quint32 *ptr, qssize_t left) Q_DECL_NOTHROW +static void fallback_fill(quint32 *ptr, qsizetype left) Q_DECL_NOTHROW { quint32 scratch[12]; // see element count below quint32 *end = scratch; @@ -358,7 +358,7 @@ Q_NEVER_INLINE void QRandomGenerator::SystemGenerator::generate(quint32 *begin, Q_DECL_NOEXCEPT_EXPR(FillBufferNoexcept) { quint32 *buffer = begin; - qssize_t count = end - begin; + qsizetype count = end - begin; if (Q_UNLIKELY(uint(qt_randomdevice_control) & SetRandomData)) { uint value = uint(qt_randomdevice_control) & RandomDataMask; @@ -366,14 +366,14 @@ Q_NEVER_INLINE void QRandomGenerator::SystemGenerator::generate(quint32 *begin, return; } - qssize_t filled = 0; + qsizetype filled = 0; if (qt_has_hwrng() && (uint(qt_randomdevice_control) & SkipHWRNG) == 0) filled += qt_random_cpu(buffer, count); if (filled != count && (uint(qt_randomdevice_control) & SkipSystemRNG) == 0) { - qssize_t bytesFilled = - fillBuffer(buffer + filled, (count - filled) * qssize_t(sizeof(*buffer))); - filled += bytesFilled / qssize_t(sizeof(*buffer)); + qsizetype bytesFilled = + fillBuffer(buffer + filled, (count - filled) * qsizetype(sizeof(*buffer))); + filled += bytesFilled / qsizetype(sizeof(*buffer)); } if (filled) fallback_update_seed(*buffer); @@ -682,7 +682,7 @@ inline QRandomGenerator::SystemGenerator &QRandomGenerator::SystemGenerator::sel */ /*! - \fn QRandomGenerator::QRandomGenerator(const quint32 *seedBuffer, qssize_t len) + \fn QRandomGenerator::QRandomGenerator(const quint32 *seedBuffer, qsizetype len) \overload Initializes this QRandomGenerator object with \a len values found in @@ -874,7 +874,7 @@ inline QRandomGenerator::SystemGenerator &QRandomGenerator::SystemGenerator::sel */ /*! - \fn void QRandomGenerator::fillRange(UInt *buffer, qssize_t count) + \fn void QRandomGenerator::fillRange(UInt *buffer, qsizetype count) Generates \a count 32- or 64-bit quantities (depending on the type \c UInt) and stores them in the buffer pointed by \a buffer. This is the most diff --git a/src/corelib/global/qrandom.h b/src/corelib/global/qrandom.h index bde64646a4..cbeab19a7b 100644 --- a/src/corelib/global/qrandom.h +++ b/src/corelib/global/qrandom.h @@ -55,10 +55,10 @@ public: QRandomGenerator(quint32 seedValue = 1) : QRandomGenerator(&seedValue, 1) {} - template <qssize_t N> QRandomGenerator(const quint32 (&seedBuffer)[N]) + template <qsizetype N> QRandomGenerator(const quint32 (&seedBuffer)[N]) : QRandomGenerator(seedBuffer, seedBuffer + N) {} - QRandomGenerator(const quint32 *seedBuffer, qssize_t len) + QRandomGenerator(const quint32 *seedBuffer, qsizetype len) : QRandomGenerator(seedBuffer, seedBuffer + len) {} Q_CORE_EXPORT QRandomGenerator(std::seed_seq &sseq) Q_DECL_NOTHROW; @@ -131,7 +131,7 @@ public: } template <typename UInt, IfValidUInt<UInt> = true> - void fillRange(UInt *buffer, qssize_t count) + void fillRange(UInt *buffer, qsizetype count) { _fillRange(buffer, buffer + count); } @@ -177,7 +177,8 @@ private: friend class QRandomGenerator64; struct SystemGenerator; struct SystemAndGlobalGenerators; - typedef std::mt19937 RandomEngine; + using RandomEngine = std::mersenne_twister_engine<quint32, + 32,624,397,31,0x9908b0df,11,0xffffffff,7,0x9d2c5680,15,0xefc60000,18,1812433253>; union Storage { uint dummy; @@ -214,10 +215,10 @@ public: QRandomGenerator64(quint32 seedValue = 1) : QRandomGenerator(seedValue) {} - template <qssize_t N> QRandomGenerator64(const quint32 (&seedBuffer)[N]) + template <qsizetype N> QRandomGenerator64(const quint32 (&seedBuffer)[N]) : QRandomGenerator(seedBuffer) {} - QRandomGenerator64(const quint32 *seedBuffer, qssize_t len) + QRandomGenerator64(const quint32 *seedBuffer, qsizetype len) : QRandomGenerator(seedBuffer, len) {} QRandomGenerator64(std::seed_seq &sseq) Q_DECL_NOTHROW diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp index bac995ff25..e4888e9523 100644 --- a/src/corelib/io/qfile.cpp +++ b/src/corelib/io/qfile.cpp @@ -503,7 +503,8 @@ bool QFile::remove() { Q_D(QFile); - if (d->fileName.isEmpty()) { + if (d->fileName.isEmpty() && + !static_cast<QFSFileEngine *>(d->engine())->isUnnamedFile()) { qWarning("QFile::remove: Empty or null file name"); return false; } diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 75d0c60288..e590e259e7 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -102,6 +102,10 @@ static int statx(int dirfd, const char *pathname, int flag, unsigned mask, struc # endif #endif +#ifndef STATX_BASIC_STATS +struct statx { mode_t stx_mode; }; +#endif + QT_BEGIN_NAMESPACE enum { @@ -212,6 +216,8 @@ static inline typename QtPrivate::QEnableIf<(&T::st_atimespec, &T::st_mtimespec, modification->tv_usec = p->st_mtimespec.tv_nsec / 1000; } +# ifndef st_atimensec +// if "st_atimensec" is defined, this would expand to invalid C++ template <typename T> static inline typename QtPrivate::QEnableIf<(&T::st_atimensec, &T::st_mtimensec, true)>::Type get(const T *p, struct timeval *access, struct timeval *modification) { @@ -221,6 +227,7 @@ static inline typename QtPrivate::QEnableIf<(&T::st_atimensec, &T::st_mtimensec, modification->tv_sec = p->st_mtime; modification->tv_usec = p->st_mtimensec / 1000; } +# endif #endif qint64 timespecToMSecs(const timespec &spec) @@ -278,6 +285,7 @@ mtime(const T &statBuffer, int) { return timespecToMSecs(statBuffer.st_mtimespec); } #endif +#ifndef st_mtimensec // Xtimensec template <typename T> Q_DECL_UNUSED static typename std::enable_if<(&T::st_atimensec, true), qint64>::type @@ -298,8 +306,9 @@ template <typename T> Q_DECL_UNUSED static typename std::enable_if<(&T::st_mtimensec, true), qint64>::type mtime(const T &statBuffer, int) { return statBuffer.st_mtime * Q_INT64_C(1000) + statBuffer.st_mtimensec / 1000000; } -} -} +#endif +} // namespace GetFileTimes +} // unnamed namespace #ifdef STATX_BASIC_STATS static int qt_real_statx(int fd, const char *pathname, int flags, struct statx *statxBuffer) @@ -395,7 +404,6 @@ inline void QFileSystemMetaData::fillFromStatxBuf(const struct statx &statxBuffe groupId_ = statxBuffer.stx_gid; } #else -struct statx { mode_t stx_mode; }; static int qt_statx(const char *, struct statx *) { return -ENOSYS; } @@ -928,7 +936,7 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM data.entryFlags &= ~what; const QByteArray nativeFilePath = entry.nativeFilePath(); - bool entryExists = true; // innocent until proven otherwise + int entryErrno = 0; // innocent until proven otherwise // first, we may try lstat(2). Possible outcomes: // - success and is a symlink: filesystem entry exists, but we need stat(2) @@ -978,7 +986,7 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM } } else { // it doesn't exist - entryExists = false; + entryErrno = errno; data.knownFlagsMask |= QFileSystemMetaData::ExistsAttribute; } @@ -986,8 +994,8 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM } // second, we try a regular stat(2) - if (statResult != 0 && (what & QFileSystemMetaData::PosixStatFlags)) { - if (entryExists && statResult == -1) { + if (statResult == -1 && (what & QFileSystemMetaData::PosixStatFlags)) { + if (entryErrno == 0 && statResult == -1) { data.entryFlags &= ~QFileSystemMetaData::PosixStatFlags; statResult = qt_statx(nativeFilePath, &statxBuffer); if (statResult == -ENOSYS) { @@ -1001,7 +1009,7 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM } if (statResult != 0) { - entryExists = false; + entryErrno = errno; data.birthTime_ = 0; data.metadataChangeTime_ = 0; data.modificationTime_ = 0; @@ -1020,13 +1028,13 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM if (what & (QFileSystemMetaData::UserPermissions | QFileSystemMetaData::ExistsAttribute)) { // calculate user permissions auto checkAccess = [&](QFileSystemMetaData::MetaDataFlag flag, int mode) { - if (!entryExists || (what & flag) == 0) + if (entryErrno != 0 || (what & flag) == 0) return; if (QT_ACCESS(nativeFilePath, mode) == 0) { // access ok (and file exists) data.entryFlags |= flag | QFileSystemMetaData::ExistsAttribute; } else if (errno != EACCES && errno != EROFS) { - entryExists = false; + entryErrno = errno; } }; @@ -1035,9 +1043,10 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM checkAccess(QFileSystemMetaData::UserExecutePermission, X_OK); // if we still haven't found out if the file exists, try F_OK - if (entryExists && (data.entryFlags & QFileSystemMetaData::ExistsAttribute) == 0) { - entryExists = QT_ACCESS(nativeFilePath, F_OK) == 0; - if (entryExists) + if (entryErrno == 0 && (data.entryFlags & QFileSystemMetaData::ExistsAttribute) == 0) { + if (QT_ACCESS(nativeFilePath, F_OK) == -1) + entryErrno = errno; + else data.entryFlags |= QFileSystemMetaData::ExistsAttribute; } @@ -1047,13 +1056,13 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM #if defined(Q_OS_DARWIN) if (what & QFileSystemMetaData::AliasType) { - if (entryExists && hasResourcePropertyFlag(data, entry, kCFURLIsAliasFileKey)) + if (entryErrno == 0 && hasResourcePropertyFlag(data, entry, kCFURLIsAliasFileKey)) data.entryFlags |= QFileSystemMetaData::AliasType; data.knownFlagsMask |= QFileSystemMetaData::AliasType; } if (what & QFileSystemMetaData::BundleType) { - if (entryExists && isPackage(data, entry)) + if (entryErrno == 0 && isPackage(data, entry)) data.entryFlags |= QFileSystemMetaData::BundleType; data.knownFlagsMask |= QFileSystemMetaData::BundleType; @@ -1065,19 +1074,19 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM QString fileName = entry.fileName(); if ((fileName.size() > 0 && fileName.at(0) == QLatin1Char('.')) #if defined(Q_OS_DARWIN) - || (entryExists && hasResourcePropertyFlag(data, entry, kCFURLIsHiddenKey)) + || (entryErrno == 0 && hasResourcePropertyFlag(data, entry, kCFURLIsHiddenKey)) #endif ) data.entryFlags |= QFileSystemMetaData::HiddenAttribute; data.knownFlagsMask |= QFileSystemMetaData::HiddenAttribute; } - if (!entryExists) { + if (entryErrno != 0) { what &= ~QFileSystemMetaData::LinkType; // don't clear link: could be broken symlink data.clearFlags(what); return false; } - return data.hasFlags(what); + return true; } // static diff --git a/src/corelib/io/qfilesystemmetadata_p.h b/src/corelib/io/qfilesystemmetadata_p.h index 55e44d52c7..4d2a5acb9b 100644 --- a/src/corelib/io/qfilesystemmetadata_p.h +++ b/src/corelib/io/qfilesystemmetadata_p.h @@ -64,6 +64,10 @@ # endif #endif +#ifdef Q_OS_UNIX +struct statx; +#endif + QT_BEGIN_NAMESPACE class QFileSystemEngine; diff --git a/src/corelib/io/qfsfileengine_p.h b/src/corelib/io/qfsfileengine_p.h index 1f34dfc2be..faef84cbe2 100644 --- a/src/corelib/io/qfsfileengine_p.h +++ b/src/corelib/io/qfsfileengine_p.h @@ -112,6 +112,9 @@ public: qint64 write(const char *data, qint64 len) Q_DECL_OVERRIDE; bool cloneTo(QAbstractFileEngine *target) override; + virtual bool isUnnamedFile() const + { return false; } + bool extension(Extension extension, const ExtensionOption *option = 0, ExtensionReturn *output = 0) Q_DECL_OVERRIDE; bool supportsExtension(Extension extension) const Q_DECL_OVERRIDE; diff --git a/src/corelib/io/qresource.cpp b/src/corelib/io/qresource.cpp index c1187e5145..31f02e977d 100644 --- a/src/corelib/io/qresource.cpp +++ b/src/corelib/io/qresource.cpp @@ -86,8 +86,8 @@ public: } const QChar *m_data; - qssize_t m_len; - qssize_t m_pos = 0; + qsizetype m_len; + qsizetype m_pos = 0; QChar m_splitChar = QLatin1Char('/'); }; diff --git a/src/corelib/io/qtemporaryfile.cpp b/src/corelib/io/qtemporaryfile.cpp index b8d3e859cf..35699d52df 100644 --- a/src/corelib/io/qtemporaryfile.cpp +++ b/src/corelib/io/qtemporaryfile.cpp @@ -393,7 +393,9 @@ bool QTemporaryFileEngine::remove() // we must explicitly call QFSFileEngine::close() before we remove it. d->unmapAll(); QFSFileEngine::close(); - if (isUnnamedFile() || QFSFileEngine::remove()) { + if (isUnnamedFile()) + return true; + if (!filePathIsTemplate && QFSFileEngine::remove()) { d->fileEntry.clear(); // If a QTemporaryFile is constructed using a template file path, the path // is generated in QTemporaryFileEngine::open() and then filePathIsTemplate @@ -511,7 +513,10 @@ bool QTemporaryFileEngine::materializeUnnamedFile(const QString &newName, QTempo bool QTemporaryFileEngine::isUnnamedFile() const { #ifdef LINUX_UNNAMED_TMPFILE - Q_ASSERT(unnamedFile == d_func()->fileEntry.isEmpty()); + if (unnamedFile) { + Q_ASSERT(d_func()->fileEntry.isEmpty()); + Q_ASSERT(filePathIsTemplate); + } return unnamedFile; #else return false; @@ -749,10 +754,21 @@ bool QTemporaryFile::autoRemove() const } /*! - Sets the QTemporaryFile into auto-remove mode if \a b is true. + Sets the QTemporaryFile into auto-remove mode if \a b is \c true. Auto-remove is on by default. + If you set this property to \c false, ensure the application provides a way + to remove the file once it is no longer needed, including passing the + responsibility on to another process. Always use the fileName() function to + obtain the name and never try to guess the name that QTemporaryFile has + generated. + + On some systems, if fileName() is not called before closing the file, the + temporary file may be removed regardless of the state of this property. + This behavior should not be relied upon, so application code should either + call fileName() or leave the auto removal functionality enabled. + \sa autoRemove(), remove() */ void QTemporaryFile::setAutoRemove(bool b) diff --git a/src/corelib/io/qtemporaryfile_p.h b/src/corelib/io/qtemporaryfile_p.h index 46a0d7aba3..fb8887af53 100644 --- a/src/corelib/io/qtemporaryfile_p.h +++ b/src/corelib/io/qtemporaryfile_p.h @@ -58,7 +58,7 @@ #include "private/qfile_p.h" #include "qtemporaryfile.h" -#ifdef Q_OS_LINUX +#if defined(Q_OS_LINUX) && QT_CONFIG(linkat) # include <fcntl.h> # ifdef O_TMPFILE // some early libc support had the wrong values for O_TMPFILE @@ -74,8 +74,8 @@ QT_BEGIN_NAMESPACE struct QTemporaryFileName { QFileSystemEntry::NativePath path; - qssize_t pos; - qssize_t length; + qsizetype pos; + qsizetype length; QTemporaryFileName(const QString &templateName); QFileSystemEntry::NativePath generateNext(); @@ -140,7 +140,7 @@ public: enum MaterializationMode { Overwrite, DontOverwrite, NameIsTemplate }; bool materializeUnnamedFile(const QString &newName, MaterializationMode mode); - bool isUnnamedFile() const; + bool isUnnamedFile() const override final; const QString &templateName; quint32 fileMode; diff --git a/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/src/corelib/itemmodels/qsortfilterproxymodel.cpp index ef3281df30..7dad892606 100644 --- a/src/corelib/itemmodels/qsortfilterproxymodel.cpp +++ b/src/corelib/itemmodels/qsortfilterproxymodel.cpp @@ -2657,8 +2657,8 @@ void QSortFilterProxyModel::setFilterRole(int role) } /*! - \since 5.9 - \property QSortFilterProxyModel::recursiveFiltering + \since 5.10 + \property QSortFilterProxyModel::recursiveFilteringEnabled \brief whether the filter to be applied recursively on children, and for any matching child, its parents will be visible as well. @@ -2666,13 +2666,13 @@ void QSortFilterProxyModel::setFilterRole(int role) \sa filterAcceptsRow() */ -bool QSortFilterProxyModel::recursiveFiltering() const +bool QSortFilterProxyModel::isRecursiveFilteringEnabled() const { Q_D(const QSortFilterProxyModel); return d->filter_recursive; } -void QSortFilterProxyModel::setRecursiveFiltering(bool recursive) +void QSortFilterProxyModel::setRecursiveFilteringEnabled(bool recursive) { Q_D(QSortFilterProxyModel); if (d->filter_recursive == recursive) diff --git a/src/corelib/itemmodels/qsortfilterproxymodel.h b/src/corelib/itemmodels/qsortfilterproxymodel.h index 6f2e9806ed..9f9b59733d 100644 --- a/src/corelib/itemmodels/qsortfilterproxymodel.h +++ b/src/corelib/itemmodels/qsortfilterproxymodel.h @@ -67,7 +67,7 @@ class Q_CORE_EXPORT QSortFilterProxyModel : public QAbstractProxyModel Q_PROPERTY(bool isSortLocaleAware READ isSortLocaleAware WRITE setSortLocaleAware) Q_PROPERTY(int sortRole READ sortRole WRITE setSortRole) Q_PROPERTY(int filterRole READ filterRole WRITE setFilterRole) - Q_PROPERTY(bool recursiveFiltering READ recursiveFiltering WRITE setRecursiveFiltering) + Q_PROPERTY(bool recursiveFilteringEnabled READ isRecursiveFilteringEnabled WRITE setRecursiveFilteringEnabled) public: explicit QSortFilterProxyModel(QObject *parent = Q_NULLPTR); @@ -108,8 +108,8 @@ public: int filterRole() const; void setFilterRole(int role); - bool recursiveFiltering() const; - void setRecursiveFiltering(bool recursive); + bool isRecursiveFilteringEnabled() const; + void setRecursiveFilteringEnabled(bool recursive); public Q_SLOTS: void setFilterRegExp(const QString &pattern); diff --git a/src/corelib/tools/qdatetime.h b/src/corelib/tools/qdatetime.h index adab47fc1f..3b741553d5 100644 --- a/src/corelib/tools/qdatetime.h +++ b/src/corelib/tools/qdatetime.h @@ -81,7 +81,7 @@ public: int daysInYear() const; int weekNumber(int *yearNum = Q_NULLPTR) const; -#if QT_DEPRECATED_SINCE(5, 11) && !defined QT_NO_TEXTDATE +#if QT_DEPRECATED_SINCE(5, 10) && !defined QT_NO_TEXTDATE QT_DEPRECATED_X("Use QLocale::monthName or QLocale::standaloneMonthName") static QString shortMonthName(int month, MonthNameType type = DateFormat); QT_DEPRECATED_X("Use QLocale::dayName or QLocale::standaloneDayName") diff --git a/src/corelib/tools/qdatetimeparser.cpp b/src/corelib/tools/qdatetimeparser.cpp index 6860cd6ef0..1a56418aaf 100644 --- a/src/corelib/tools/qdatetimeparser.cpp +++ b/src/corelib/tools/qdatetimeparser.cpp @@ -1169,7 +1169,8 @@ QDateTimeParser::scanString(const QDateTime &defaultValue, #if QT_CONFIG(timezone) // Synchronize with what findTimeZone() found: QStringRef zoneName = input->midRef(pos, sect.used); Q_ASSERT(!zoneName.isEmpty()); // sect.used > 0 - const QByteArray latinZone(zoneName.toLatin1()); + const QByteArray latinZone(zoneName == QLatin1String("Z") + ? QByteArray("UTC") : zoneName.toLatin1()); timeZone = QTimeZone(latinZone); tspec = timeZone.isValid() ? (QTimeZone::isTimeZoneIdAvailable(latinZone) @@ -1615,6 +1616,10 @@ QDateTimeParser::findTimeZone(QStringRef str, const QDateTime &when, while (index > 0) { str.truncate(index); + if (str == QLatin1String("Z")) { + offset = 0; // "Zulu" time - a.k.a. UTC + break; + } QTimeZone zone(str.toLatin1()); if (zone.isValid()) { offset = zone.offsetFromUtc(when); diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index 07bc1f8275..a072ea411c 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -576,7 +576,7 @@ int qt_repeatCount(QStringView s) if (s.isEmpty()) return 0; const QChar c = s.front(); - qssize_t j = 1; + qsizetype j = 1; while (j < s.size() && s.at(j) == c) ++j; return int(j); @@ -3443,7 +3443,7 @@ bool QLocaleData::validateChars(QStringView str, NumberMode numMode, QByteArray bool dec = false; int decDigitCnt = 0; - for (qssize_t i = 0; i < str.size(); ++i) { + for (qsizetype i = 0; i < str.size(); ++i) { char c = digitToCLocale(str.at(i)); if (c >= '0' && c <= '9') { diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 7e8a8dca9a..4e59686d97 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -160,9 +160,9 @@ static inline bool qt_ends_with(QStringView haystack, QStringView needle, Qt::Ca static inline bool qt_ends_with(QStringView haystack, QLatin1String needle, Qt::CaseSensitivity cs); static inline bool qt_ends_with(QStringView haystack, QChar needle, Qt::CaseSensitivity cs); -qssize_t QtPrivate::qustrlen(const ushort *str) Q_DECL_NOTHROW +qsizetype QtPrivate::qustrlen(const ushort *str) Q_DECL_NOTHROW { - qssize_t result = 0; + qsizetype result = 0; #ifdef __SSE2__ // find the 16-byte alignment immediately prior or equal to str diff --git a/src/corelib/tools/qstringalgorithms.h b/src/corelib/tools/qstringalgorithms.h index 336da87468..aaa702301e 100644 --- a/src/corelib/tools/qstringalgorithms.h +++ b/src/corelib/tools/qstringalgorithms.h @@ -55,7 +55,7 @@ template <typename T> class QVector; namespace QtPrivate { -Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qssize_t qustrlen(const ushort *str) Q_DECL_NOTHROW; +Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype qustrlen(const ushort *str) Q_DECL_NOTHROW; Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QStringView lhs, QStringView rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW; Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QStringView lhs, QLatin1String rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW; diff --git a/src/corelib/tools/qstringiterator.qdoc b/src/corelib/tools/qstringiterator.qdoc index 95c2247bc1..caec8803f3 100644 --- a/src/corelib/tools/qstringiterator.qdoc +++ b/src/corelib/tools/qstringiterator.qdoc @@ -120,7 +120,7 @@ */ /*! - \fn QStringIterator::QStringIterator(QStringView string, qssize_t idx) + \fn QStringIterator::QStringIterator(QStringView string, qsizetype idx) Constructs an iterator over the contents of \a string. The iterator will point before position \a idx in the string. diff --git a/src/corelib/tools/qstringiterator_p.h b/src/corelib/tools/qstringiterator_p.h index 8b1a6a1cd3..219589b6e4 100644 --- a/src/corelib/tools/qstringiterator_p.h +++ b/src/corelib/tools/qstringiterator_p.h @@ -62,7 +62,7 @@ class QStringIterator QString::const_iterator i, pos, e; Q_STATIC_ASSERT((std::is_same<QString::const_iterator, const QChar *>::value)); public: - explicit QStringIterator(QStringView string, qssize_t idx = 0) + explicit QStringIterator(QStringView string, qsizetype idx = 0) : i(string.begin()), pos(i + idx), e(string.end()) diff --git a/src/corelib/tools/qstringview.cpp b/src/corelib/tools/qstringview.cpp index f510f44ce7..6321427a2d 100644 --- a/src/corelib/tools/qstringview.cpp +++ b/src/corelib/tools/qstringview.cpp @@ -131,9 +131,9 @@ QT_BEGIN_NAMESPACE /*! \typedef QStringView::size_type - Alias for qssize_t. Provided for compatibility with the STL. + Alias for qsizetype. Provided for compatibility with the STL. - Unlike other Qt classes, QStringView uses qssize_t as its \c size_type, to allow + Unlike other Qt classes, QStringView uses qsizetype as its \c size_type, to allow accepting data from \c{std::basic_string} without truncation. The Qt API functions, for example length(), return \c int, while the STL-compatible functions, for example size(), return \c size_type. @@ -224,7 +224,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn QStringView::QStringView(const Char *str, qssize_t len) + \fn QStringView::QStringView(const Char *str, qsizetype len) Constructs a string view on \a str with length \a len. @@ -486,7 +486,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn qssize_t QStringView::size() const + \fn qsizetype QStringView::size() const Returns the size of this string view, in UTF-16 code points (that is, surrogate pairs count as two for the purposes of this function, the same @@ -510,7 +510,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn QChar QStringView::operator[](qssize_t n) const + \fn QChar QStringView::operator[](qsizetype n) const Returns the character at position \a n in this string view. @@ -520,7 +520,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn QChar QStringView::at(qssize_t n) const + \fn QChar QStringView::at(qsizetype n) const Returns the character at position \a n in this string view. @@ -582,7 +582,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn QStringView QStringView::mid(qssize_t start) const + \fn QStringView QStringView::mid(qsizetype start) const Returns the substring starting at position \a start in this object, and extending to the end of the string. @@ -593,7 +593,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn QStringView QStringView::mid(qssize_t start, qssize_t length) const + \fn QStringView QStringView::mid(qsizetype start, qsizetype length) const \overload Returns the substring of length \a length starting at position @@ -606,7 +606,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn QStringView QStringView::left(qssize_t length) const + \fn QStringView QStringView::left(qsizetype length) const Returns the substring of length \a length starting at position 0 in this object. @@ -617,7 +617,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn QStringView QStringView::right(qssize_t length) const + \fn QStringView QStringView::right(qsizetype length) const Returns the substring of length \a length starting at position size() - \a length in this object. @@ -628,7 +628,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn QStringView QStringView::chopped(qssize_t length) const + \fn QStringView QStringView::chopped(qsizetype length) const Returns the substring of length size() - \a length starting at the beginning of this object. @@ -641,7 +641,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn void QStringView::truncate(qssize_t length) + \fn void QStringView::truncate(qsizetype length) Truncates this string view to length \a length. @@ -653,7 +653,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn void QStringView::chop(qssize_t length) + \fn void QStringView::chop(qsizetype length) Truncates this string view by \a length characters. diff --git a/src/corelib/tools/qstringview.h b/src/corelib/tools/qstringview.h index 6ff287a570..ef442e5b65 100644 --- a/src/corelib/tools/qstringview.h +++ b/src/corelib/tools/qstringview.h @@ -111,7 +111,7 @@ public: #endif typedef const QChar value_type; typedef std::ptrdiff_t difference_type; - typedef qssize_t size_type; + typedef qsizetype size_type; typedef value_type &reference; typedef value_type &const_reference; typedef value_type *pointer; @@ -139,17 +139,17 @@ private: using if_compatible_qstring_like = typename std::enable_if<std::is_same<T, QString>::value || std::is_same<T, QStringRef>::value, bool>::type; template <typename Char, size_t N> - static Q_DECL_CONSTEXPR qssize_t lengthHelperArray(const Char (&)[N]) Q_DECL_NOTHROW + static Q_DECL_CONSTEXPR qsizetype lengthHelperArray(const Char (&)[N]) Q_DECL_NOTHROW { - return qssize_t(N - 1); + return qsizetype(N - 1); } template <typename Char> - static qssize_t lengthHelperPointer(const Char *str) Q_DECL_NOTHROW + static qsizetype lengthHelperPointer(const Char *str) Q_DECL_NOTHROW { #if defined(Q_CC_GNU) && !defined(Q_CC_CLANG) && !defined(Q_CC_INTEL) if (__builtin_constant_p(*str)) { - qssize_t result = 0; + qsizetype result = 0; while (*str++) ++result; return result; @@ -157,7 +157,7 @@ private: #endif return QtPrivate::qustrlen(reinterpret_cast<const ushort *>(str)); } - static qssize_t lengthHelperPointer(const QChar *str) Q_DECL_NOTHROW + static qsizetype lengthHelperPointer(const QChar *str) Q_DECL_NOTHROW { return QtPrivate::qustrlen(reinterpret_cast<const ushort *>(str)); } @@ -175,7 +175,7 @@ public: : QStringView() {} template <typename Char, if_compatible_char<Char> = true> - Q_DECL_CONSTEXPR QStringView(const Char *str, qssize_t len) + Q_DECL_CONSTEXPR QStringView(const Char *str, qsizetype len) : m_size((Q_ASSERT(len >= 0), Q_ASSERT(str || !len), len)), m_data(castHelper(str)) {} @@ -205,20 +205,20 @@ public: #else template <typename String, if_compatible_qstring_like<String> = true> QStringView(const String &str) Q_DECL_NOTHROW - : QStringView(str.isNull() ? nullptr : str.data(), qssize_t(str.size())) {} + : QStringView(str.isNull() ? nullptr : str.data(), qsizetype(str.size())) {} #endif template <typename StdBasicString, if_compatible_string<StdBasicString> = true> QStringView(const StdBasicString &str) Q_DECL_NOTHROW - : QStringView(str.data(), qssize_t(str.size())) {} + : QStringView(str.data(), qsizetype(str.size())) {} Q_REQUIRED_RESULT inline QString toString() const; // defined in qstring.h - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR qssize_t size() const Q_DECL_NOTHROW { return m_size; } + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR qsizetype size() const Q_DECL_NOTHROW { return m_size; } Q_REQUIRED_RESULT const_pointer data() const Q_DECL_NOTHROW { return reinterpret_cast<const_pointer>(m_data); } Q_REQUIRED_RESULT Q_DECL_CONSTEXPR const storage_type *utf16() const Q_DECL_NOTHROW { return m_data; } - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QChar operator[](qssize_t n) const + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QChar operator[](qsizetype n) const { return Q_ASSERT(n >= 0), Q_ASSERT(n < size()), QChar(m_data[n]); } // @@ -230,22 +230,22 @@ public: Q_REQUIRED_RESULT QByteArray toLocal8Bit() const { return QtPrivate::convertToLocal8Bit(*this); } Q_REQUIRED_RESULT inline QVector<uint> toUcs4() const; // defined in qvector.h - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QChar at(qssize_t n) const { return (*this)[n]; } + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QChar at(qsizetype n) const { return (*this)[n]; } - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QStringView mid(qssize_t pos) const + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QStringView mid(qsizetype pos) const { return Q_ASSERT(pos >= 0), Q_ASSERT(pos <= size()), QStringView(m_data + pos, m_size - pos); } - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QStringView mid(qssize_t pos, qssize_t n) const + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QStringView mid(qsizetype pos, qsizetype n) const { return Q_ASSERT(pos >= 0), Q_ASSERT(n >= 0), Q_ASSERT(pos + n <= size()), QStringView(m_data + pos, n); } - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QStringView left(qssize_t n) const + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QStringView left(qsizetype n) const { return Q_ASSERT(n >= 0), Q_ASSERT(n <= size()), QStringView(m_data, n); } - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QStringView right(qssize_t n) const + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QStringView right(qsizetype n) const { return Q_ASSERT(n >= 0), Q_ASSERT(n <= size()), QStringView(m_data + m_size - n, n); } - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QStringView chopped(qssize_t n) const + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QStringView chopped(qsizetype n) const { return Q_ASSERT(n >= 0), Q_ASSERT(n <= size()), QStringView(m_data, m_size - n); } - Q_DECL_RELAXED_CONSTEXPR void truncate(qssize_t n) + Q_DECL_RELAXED_CONSTEXPR void truncate(qsizetype n) { Q_ASSERT(n >= 0); Q_ASSERT(n <= size()); m_size = n; } - Q_DECL_RELAXED_CONSTEXPR void chop(qssize_t n) + Q_DECL_RELAXED_CONSTEXPR void chop(qsizetype n) { Q_ASSERT(n >= 0); Q_ASSERT(n <= size()); m_size -= n; } Q_REQUIRED_RESULT QStringView trimmed() const Q_DECL_NOTHROW { return QtPrivate::trimmed(*this); } @@ -292,7 +292,7 @@ public: Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QChar first() const { return front(); } Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QChar last() const { return back(); } private: - qssize_t m_size; + qsizetype m_size; const storage_type *m_data; }; Q_DECLARE_TYPEINFO(QStringView, Q_PRIMITIVE_TYPE); |