diff options
author | Liang Qi <liang.qi@qt.io> | 2016-10-13 09:49:38 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2016-10-13 09:49:38 +0200 |
commit | dfc177e3a99dd593db4b1e9445d6243ce75ebf07 (patch) | |
tree | 4e33c7be90a44642e672fff22ea163b500ff3aef /src/corelib | |
parent | 72efb2e6f4af2fd909daaf9104f09fd1425acfb0 (diff) | |
parent | 1d6eb70dcec105af28d6a5e9b59d56c895c70389 (diff) |
Merge remote-tracking branch 'origin/5.8' into dev
Conflicts:
qmake/library/qmakeevaluator.cpp
(cherry picked from commit 1af6dc2c8fb4d91400fddc5050166f972ae57c9a in qttools)
src/corelib/kernel/qcore_mac_objc.mm
src/gui/painting/qcolor.h
src/plugins/platforms/cocoa/qcocoawindow.mm
Change-Id: I5b3ec468a5a9a73911b528d3d24ff8e19f339f31
Diffstat (limited to 'src/corelib')
72 files changed, 501 insertions, 401 deletions
diff --git a/src/corelib/configure.json b/src/corelib/configure.json index b0c78f5122..c1bd37fd0c 100644 --- a/src/corelib/configure.json +++ b/src/corelib/configure.json @@ -353,6 +353,7 @@ }, "qeventtransition": { "label": "QEventTransition class", + "condition": "features.statemachine", "output": [ "publicFeature" ] }, "sharedmemory": { @@ -557,6 +558,30 @@ "purpose": "Provides a framework for gestures.", "section": "Utilities", "output": [ "publicFeature", "feature" ] + }, + "sha3-fast": { + "label": "Speed optimized SHA3", + "purpose": "Optimizes SHA3 for speed instead of size.", + "section": "Utilities", + "output": [ "privateFeature" ] + }, + "timezone": { + "label": "QTimeZone", + "purpose": "Provides support for timezone handling.", + "section": "Utilities", + "output": [ "publicFeature" ] + }, + "commandlineparser": { + "label": "QCommandlineParser", + "purpose": "Provides support for command line parsing.", + "section": "Utilities", + "output": [ "publicFeature" ] + }, + "topleveldomain": { + "label": "QUrl::topLevelDomain()", + "description": "Provides support for extracting the top level domain from URLs.", + "section": "Utilities", + "output": [ "publicFeature" ] } }, diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index a3d816f0c3..dcdddeb04d 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -1351,10 +1351,16 @@ /* Clang can not parse namespaced attributes in C mode, but defines __has_cpp_attribute */ # if QT_HAS_CPP_ATTRIBUTE(clang::fallthrough) # define Q_FALLTHROUGH() [[clang::fallthrough]] +# elif QT_HAS_CPP_ATTRIBUTE(gnu::fallthrough) +# define Q_FALLTHROUGH() [[gnu::fallthrough]] # endif #endif #ifndef Q_FALLTHROUGH -# define Q_FALLTHROUGH() (void)0 +# if defined(Q_CC_GNU) && Q_CC_GNU >= 700 +# define Q_FALLTHROUGH() __attribute__((fallthrough)) +# else +# define Q_FALLTHROUGH() (void)0 +#endif #endif diff --git a/src/corelib/global/qconfig-bootstrapped.h b/src/corelib/global/qconfig-bootstrapped.h new file mode 100644 index 0000000000..3b86e94cdd --- /dev/null +++ b/src/corelib/global/qconfig-bootstrapped.h @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// +// Despite its file name, this really is not a public header. +// It is an implementation detail of the private bootstrap library. +// + +#if 0 +// silence syncqt warnings +#pragma qt_sync_skip_header_check +#pragma qt_sync_stop_processing +#endif + +#ifdef QT_BOOTSTRAPPED + +#ifndef QT_NO_EXCEPTIONS +#define QT_NO_EXCEPTIONS +#endif + +#define QT_NO_USING_NAMESPACE +#define QT_NO_DEPRECATED + +#define QT_CRYPTOGRAPHICHASH_ONLY_SHA1 +#define QT_NO_DATASTREAM +#define QT_NO_LIBRARY +#define QT_FEATURE_library -1 +#define QT_NO_QOBJECT +#define QT_NO_SYSTEMLOCALE +#define QT_NO_THREAD +#define QT_FEATURE_timezone -1 +#define QT_FEATURE_topleveldomain -1 +#define QT_NO_TRANSLATION +#define QT_FEATURE_translation -1 +#define QT_NO_GEOM_VARIANT + +#if defined(QT_BUILD_QMAKE) || defined(QT_BUILD_CONFIGURE) +#define QT_FEATURE_commandlineparser -1 +#define QT_NO_COMPRESS +#define QT_JSON_READONLY +#define QT_NO_TEXTCODEC +#define QT_FEATURE_textcodec -1 +#else +#define QT_NO_CODECS +#define QT_FEATURE_codecs -1 +#define QT_FEATURE_commandlineparser 1 +#define QT_FEATURE_textcodec 1 +#endif + +#if defined(QT_BUILD_QMAKE) +#define QT_NO_STANDARDPATHS +#endif + +#endif // QT_BOOTSTRAPPED diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index c78e6f2482..1ed63aea9b 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -3381,7 +3381,7 @@ Q_GLOBAL_STATIC(AndroidRandomStorage, randomTLS) pseudo random integers to be returned by qrand(). The sequence of random numbers generated is deterministic per thread. For example, - if two threads call qsrand(1) and subsequently calls qrand(), the threads will get + if two threads call qsrand(1) and subsequently call qrand(), the threads will get the same random number sequence. \sa qrand() diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index dd8b6110b3..8b67f0d3ef 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -56,7 +56,9 @@ */ #define QT_VERSION_CHECK(major, minor, patch) ((major<<16)|(minor<<8)|(patch)) -#ifndef QT_BOOTSTRAPPED +#ifdef QT_BOOTSTRAPPED +#include <QtCore/qconfig-bootstrapped.h> +#else #include <QtCore/qconfig.h> #include <QtCore/qtcore-config.h> #endif diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index edb568a2d6..5a66319164 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -558,7 +558,7 @@ public: Key_Insert = 0x01000006, Key_Delete = 0x01000007, Key_Pause = 0x01000008, - Key_Print = 0x01000009, + Key_Print = 0x01000009, // print screen Key_SysReq = 0x0100000a, Key_Clear = 0x0100000b, Key_Home = 0x01000010, // cursor movement diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index d8df25dcc6..7768070e4f 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -1761,17 +1761,6 @@ \value Key_Zoom \value Key_Exit \value Key_Cancel - \value Key_MicVolumeUp - \value Key_Find - \value Key_Open - \value Key_MicVolumeDown - \value Key_New - \value Key_Settings - \value Key_Redo - \value Key_Exit - \value Key_Info - \value Key_Undo - \value Key_Guide \sa QKeyEvent::key() */ @@ -2300,7 +2289,7 @@ \enum Qt::ItemSelectionMode This enum is used in QGraphicsItem, QGraphicsScene and QGraphicsView to - specify how items are selected, or how to determine if a shapes and items + specify how items are selected, or how to determine if shapes and items collide. \value ContainsItemShape The output list contains only items whose diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 6aaaa4c05a..c9f7672ac3 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -101,13 +101,13 @@ static bool isPackage(const QFileSystemMetaData &data, const QFileSystemEntry &e if (suffix.length() > 0) { // First step: is the extension known ? - QCFType<CFStringRef> extensionRef = QCFString::toCFStringRef(suffix); + QCFType<CFStringRef> extensionRef = suffix.toCFString(); QCFType<CFStringRef> uniformTypeIdentifier = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, extensionRef, NULL); if (UTTypeConformsTo(uniformTypeIdentifier, kUTTypeBundle)) return true; // Second step: check if an application knows the package type - QCFType<CFStringRef> path = QCFString::toCFStringRef(entry.filePath()); + QCFType<CFStringRef> path = entry.filePath().toCFString(); QCFType<CFURLRef> url = CFURLCreateWithFileSystemPath(0, path, kCFURLPOSIXPathStyle, true); UInt32 type, creator; @@ -126,7 +126,7 @@ static bool isPackage(const QFileSystemMetaData &data, const QFileSystemEntry &e if (application) { QCFType<CFBundleRef> bundle = CFBundleCreate(kCFAllocatorDefault, application); CFStringRef identifier = CFBundleGetIdentifier(bundle); - QString applicationId = QCFString::toQString(identifier); + QString applicationId = QString::fromCFString(identifier); if (applicationId != QLatin1String("com.apple.finder")) return true; } @@ -222,7 +222,7 @@ QFileSystemEntry QFileSystemEngine::getLinkTarget(const QFileSystemEntry &link, if (!cfstr) return QFileSystemEntry(); - return QFileSystemEntry(QCFString::toQString(cfstr)); + return QFileSystemEntry(QString::fromCFString(cfstr)); } #endif return QFileSystemEntry(); @@ -412,7 +412,7 @@ QString QFileSystemEngine::bundleName(const QFileSystemEntry &entry) if (QCFType<CFDictionaryRef> dict = CFBundleCopyInfoDictionaryForURL(url)) { if (CFTypeRef name = (CFTypeRef)CFDictionaryGetValue(dict, kCFBundleNameKey)) { if (CFGetTypeID(name) == CFStringGetTypeID()) - return QCFString::toQString((CFStringRef)name); + return QString::fromCFString((CFStringRef)name); } } return QString(); diff --git a/src/corelib/io/qfilesystemwatcher_fsevents.mm b/src/corelib/io/qfilesystemwatcher_fsevents.mm index beb8acb05f..a5558b62e7 100644 --- a/src/corelib/io/qfilesystemwatcher_fsevents.mm +++ b/src/corelib/io/qfilesystemwatcher_fsevents.mm @@ -87,7 +87,7 @@ bool QFseventsFileSystemWatcherEngine::checkDir(DirsByName::iterator &it) if (res == -1) { needsRestart |= derefPath(info.watchedPath); emit emitDirectoryChanged(info.origPath, true); - it = watchedDirectories.erase(it); + it = watchingState.watchedDirectories.erase(it); } else if (st.st_ctimespec != info.ctime || st.st_mode != info.mode) { info.ctime = st.st_ctimespec; info.mode = st.st_mode; @@ -138,7 +138,8 @@ bool QFseventsFileSystemWatcherEngine::rescanDirs(const QString &path) { bool needsRestart = false; - for (DirsByName::iterator it = watchedDirectories.begin(); it != watchedDirectories.end(); ) { + for (DirsByName::iterator it = watchingState.watchedDirectories.begin(); + it != watchingState.watchedDirectories.end(); ) { if (it.key().startsWith(path)) needsRestart |= checkDir(it); else @@ -177,11 +178,12 @@ bool QFseventsFileSystemWatcherEngine::rescanFiles(const QString &path) { bool needsRestart = false; - for (FilesByPath::iterator i = watchedFiles.begin(); i != watchedFiles.end(); ) { + for (FilesByPath::iterator i = watchingState.watchedFiles.begin(); + i != watchingState.watchedFiles.end(); ) { if (i.key().startsWith(path)) { needsRestart |= rescanFiles(i.value()); if (i.value().isEmpty()) { - i = watchedFiles.erase(i); + i = watchingState.watchedFiles.erase(i); continue; } } @@ -232,8 +234,8 @@ void QFseventsFileSystemWatcherEngine::processEvent(ConstFSEventStreamRef stream if (eFlags & kFSEventStreamEventFlagRootChanged) { // re-check everything: - DirsByName::iterator dirIt = watchedDirectories.find(path); - if (dirIt != watchedDirectories.end()) + DirsByName::iterator dirIt = watchingState.watchedDirectories.find(path); + if (dirIt != watchingState.watchedDirectories.end()) needsRestart |= checkDir(dirIt); needsRestart |= rescanFiles(path); continue; @@ -243,13 +245,13 @@ void QFseventsFileSystemWatcherEngine::processEvent(ConstFSEventStreamRef stream needsRestart |= rescanDirs(path); // check watched directories: - DirsByName::iterator dirIt = watchedDirectories.find(path); - if (dirIt != watchedDirectories.end()) + DirsByName::iterator dirIt = watchingState.watchedDirectories.find(path); + if (dirIt != watchingState.watchedDirectories.end()) needsRestart |= checkDir(dirIt); // check watched files: - FilesByPath::iterator pIt = watchedFiles.find(path); - if (pIt != watchedFiles.end()) + FilesByPath::iterator pIt = watchingState.watchedFiles.find(path); + if (pIt != watchingState.watchedFiles.end()) needsRestart |= rescanFiles(pIt.value()); } @@ -276,12 +278,11 @@ void QFseventsFileSystemWatcherEngine::doEmitDirectoryChanged(const QString &pat emit directoryChanged(path, removed); } -void QFseventsFileSystemWatcherEngine::restartStream() +bool QFseventsFileSystemWatcherEngine::restartStream() { - QMacAutoReleasePool pool; QMutexLocker locker(&lock); stopStream(); - startStream(); + return startStream(); } QFseventsFileSystemWatcherEngine *QFseventsFileSystemWatcherEngine::create(QObject *parent) @@ -311,6 +312,7 @@ QFseventsFileSystemWatcherEngine::~QFseventsFileSystemWatcherEngine() { QMacAutoReleasePool pool; + // Stop the stream in case we have to wait for the lock below to be acquired. if (stream) FSEventStreamStop(stream); @@ -334,8 +336,10 @@ QStringList QFseventsFileSystemWatcherEngine::addPaths(const QStringList &paths, QMutexLocker locker(&lock); + bool wasRunning = stream != Q_NULLPTR; bool needsRestart = false; + WatchingState oldState = watchingState; QStringList p = paths; QMutableListIterator<QString> it(p); while (it.hasNext()) { @@ -356,7 +360,7 @@ QStringList QFseventsFileSystemWatcherEngine::addPaths(const QStringList &paths, const bool isDir = S_ISDIR(st.st_mode); if (isDir) { - if (watchedDirectories.contains(realPath)) + if (watchingState.watchedDirectories.contains(realPath)) continue; directories->append(origPath); watchedPath = realPath; @@ -371,17 +375,18 @@ QStringList QFseventsFileSystemWatcherEngine::addPaths(const QStringList &paths, parentPath = watchedPath; } - for (PathRefCounts::const_iterator i = watchedPaths.begin(), ei = watchedPaths.end(); i != ei; ++i) { + for (PathRefCounts::const_iterator i = watchingState.watchedPaths.begin(), + ei = watchingState.watchedPaths.end(); i != ei; ++i) { if (watchedPath.startsWith(i.key())) { watchedPath = i.key(); break; } } - PathRefCounts::iterator it = watchedPaths.find(watchedPath); - if (it == watchedPaths.end()) { + PathRefCounts::iterator it = watchingState.watchedPaths.find(watchedPath); + if (it == watchingState.watchedPaths.end()) { needsRestart = true; - watchedPaths.insert(watchedPath, 1); + watchingState.watchedPaths.insert(watchedPath, 1); DEBUG("Adding '%s' to watchedPaths", qPrintable(watchedPath)); } else { ++it.value(); @@ -392,18 +397,25 @@ QStringList QFseventsFileSystemWatcherEngine::addPaths(const QStringList &paths, DirInfo dirInfo; dirInfo.dirInfo = info; dirInfo.entries = scanForDirEntries(realPath); - watchedDirectories.insert(realPath, dirInfo); + watchingState.watchedDirectories.insert(realPath, dirInfo); DEBUG("-- Also adding '%s' to watchedDirectories", qPrintable(realPath)); } else { - watchedFiles[parentPath].insert(realPath, info); + watchingState.watchedFiles[parentPath].insert(realPath, info); DEBUG("-- Also adding '%s' to watchedFiles", qPrintable(realPath)); } } if (needsRestart) { stopStream(); - if (!startStream()) + if (!startStream()) { + // ok, something went wrong, let's try to restore the previous state + watchingState = qMove(oldState); + // and because we don't know which path caused the issue (if any), fail on all of them p = paths; + + if (wasRunning) + startStream(); + } } return p; @@ -419,6 +431,7 @@ QStringList QFseventsFileSystemWatcherEngine::removePaths(const QStringList &pat bool needsRestart = false; + WatchingState oldState = watchingState; QStringList p = paths; QMutableListIterator<QString> it(p); while (it.hasNext()) { @@ -431,10 +444,10 @@ QStringList QFseventsFileSystemWatcherEngine::removePaths(const QStringList &pat realPath = fi.canonicalFilePath(); if (fi.isDir()) { - DirsByName::iterator dirIt = watchedDirectories.find(realPath); - if (dirIt != watchedDirectories.end()) { + DirsByName::iterator dirIt = watchingState.watchedDirectories.find(realPath); + if (dirIt != watchingState.watchedDirectories.end()) { needsRestart |= derefPath(dirIt->dirInfo.watchedPath); - watchedDirectories.erase(dirIt); + watchingState.watchedDirectories.erase(dirIt); directories->removeAll(origPath); it.remove(); DEBUG("Removed directory '%s'", qPrintable(realPath)); @@ -442,15 +455,15 @@ QStringList QFseventsFileSystemWatcherEngine::removePaths(const QStringList &pat } else { QFileInfo fi(realPath); QString parentPath = fi.path(); - FilesByPath::iterator pIt = watchedFiles.find(parentPath); - if (pIt != watchedFiles.end()) { + FilesByPath::iterator pIt = watchingState.watchedFiles.find(parentPath); + if (pIt != watchingState.watchedFiles.end()) { InfoByName &filesInDir = pIt.value(); InfoByName::iterator fIt = filesInDir.find(realPath); if (fIt != filesInDir.end()) { needsRestart |= derefPath(fIt->watchedPath); filesInDir.erase(fIt); if (filesInDir.isEmpty()) - watchedFiles.erase(pIt); + watchingState.watchedFiles.erase(pIt); files->removeAll(origPath); it.remove(); DEBUG("Removed file '%s'", qPrintable(realPath)); @@ -461,26 +474,33 @@ QStringList QFseventsFileSystemWatcherEngine::removePaths(const QStringList &pat locker.unlock(); - if (needsRestart) - restartStream(); + if (needsRestart) { + if (!restartStream()) { + watchingState = qMove(oldState); + startStream(); + } + } return p; } +// Returns false if FSEventStream* calls failed for some mysterious reason, true if things got a +// thumbs-up. bool QFseventsFileSystemWatcherEngine::startStream() { Q_ASSERT(stream == 0); - QMacAutoReleasePool pool; - if (stream) // This shouldn't happen, but let's be nice and handle it. + if (stream) // Ok, this really shouldn't happen, esp. not after the assert. But let's be nice in release mode and still handle it. stopStream(); - if (watchedPaths.isEmpty()) - return false; + QMacAutoReleasePool pool; - DEBUG() << "Starting stream with paths" << watchedPaths.keys(); + if (watchingState.watchedPaths.isEmpty()) + return true; // we succeeded in doing nothing - NSMutableArray *pathsToWatch = [NSMutableArray arrayWithCapacity:watchedPaths.size()]; - for (PathRefCounts::const_iterator i = watchedPaths.begin(), ei = watchedPaths.end(); i != ei; ++i) + DEBUG() << "Starting stream with paths" << watchingState.watchedPaths.keys(); + + NSMutableArray *pathsToWatch = [NSMutableArray arrayWithCapacity:watchingState.watchedPaths.size()]; + for (PathRefCounts::const_iterator i = watchingState.watchedPaths.begin(), ei = watchingState.watchedPaths.end(); i != ei; ++i) [pathsToWatch addObject:i.key().toNSString()]; struct FSEventStreamContext callBackInfo = { @@ -504,7 +524,7 @@ bool QFseventsFileSystemWatcherEngine::startStream() latency, FSEventStreamCreateFlags(0)); - if (!stream) { + if (!stream) { // nope, no way to know what went wrong, so just fail DEBUG() << "Failed to create stream!"; return false; } @@ -514,7 +534,7 @@ bool QFseventsFileSystemWatcherEngine::startStream() if (FSEventStreamStart(stream)) { DEBUG() << "Stream started successfully with sinceWhen =" << lastReceivedEvent; return true; - } else { + } else { // again, no way to know what went wrong, so just clean up and fail DEBUG() << "Stream failed to start!"; FSEventStreamInvalidate(stream); FSEventStreamRelease(stream); @@ -525,6 +545,7 @@ bool QFseventsFileSystemWatcherEngine::startStream() void QFseventsFileSystemWatcherEngine::stopStream(bool isStopped) { + QMacAutoReleasePool pool; if (stream) { if (!isStopped) FSEventStreamStop(stream); @@ -554,9 +575,9 @@ QFseventsFileSystemWatcherEngine::InfoByName QFseventsFileSystemWatcherEngine::s bool QFseventsFileSystemWatcherEngine::derefPath(const QString &watchedPath) { - PathRefCounts::iterator it = watchedPaths.find(watchedPath); - if (it != watchedPaths.end() && --it.value() < 1) { - watchedPaths.erase(it); + PathRefCounts::iterator it = watchingState.watchedPaths.find(watchedPath); + if (it != watchingState.watchedPaths.end() && --it.value() < 1) { + watchingState.watchedPaths.erase(it); DEBUG("Removing '%s' from watchedPaths.", qPrintable(watchedPath)); return true; } diff --git a/src/corelib/io/qfilesystemwatcher_fsevents_p.h b/src/corelib/io/qfilesystemwatcher_fsevents_p.h index dc4e5bf38b..1b0b8ae15c 100644 --- a/src/corelib/io/qfilesystemwatcher_fsevents_p.h +++ b/src/corelib/io/qfilesystemwatcher_fsevents_p.h @@ -87,7 +87,7 @@ Q_SIGNALS: private slots: void doEmitFileChanged(const QString &path, bool removed); void doEmitDirectoryChanged(const QString &path, bool removed); - void restartStream(); + bool restartStream(); private: struct Info { @@ -118,6 +118,19 @@ private: typedef QHash<QString, DirInfo> DirsByName; typedef QHash<QString, qint64> PathRefCounts; + struct WatchingState { + // These fields go hand-in-hand. FSEvents watches paths, and there is no use in watching + // the same path multiple times. So, the "refcount" on a path is the number of watched + // files that have the same path, plus the number of directories that have the same path. + // + // If the stream fails to start after adding files/directories, the watcher will try to + // keep watching files/directories that it was already watching. It does that by restoring + // the previous WatchingState and restarting the stream. + FilesByPath watchedFiles; + DirsByName watchedDirectories; + PathRefCounts watchedPaths; + }; + QFseventsFileSystemWatcherEngine(QObject *parent); bool startStream(); void stopStream(bool isStopped = false); @@ -131,10 +144,8 @@ private: QMutex lock; dispatch_queue_t queue; FSEventStreamRef stream; - FilesByPath watchedFiles; - DirsByName watchedDirectories; - PathRefCounts watchedPaths; FSEventStreamEventId lastReceivedEvent; + WatchingState watchingState; }; QT_END_NAMESPACE diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp index c560bc7a03..52a78ad1c4 100644 --- a/src/corelib/io/qiodevice.cpp +++ b/src/corelib/io/qiodevice.cpp @@ -120,6 +120,14 @@ static void checkWarnMessage(const QIODevice *device, const char *function, cons } \ } while (0) +#define CHECK_MAXBYTEARRAYSIZE(function) \ + do { \ + if (maxSize >= MaxByteArraySize) { \ + checkWarnMessage(this, #function, "maxSize argument exceeds QByteArray size limit"); \ + maxSize = MaxByteArraySize - 1; \ + } \ + } while (0) + #define CHECK_WRITABLE(function, returnType) \ do { \ if ((d->openMode & WriteOnly) == 0) { \ @@ -1178,10 +1186,7 @@ QByteArray QIODevice::read(qint64 maxSize) } CHECK_MAXLEN(read, result); - if (maxSize >= MaxByteArraySize) { - checkWarnMessage(this, "read", "maxSize argument exceeds QByteArray size limit"); - maxSize = MaxByteArraySize - 1; - } + CHECK_MAXBYTEARRAYSIZE(read); result.resize(int(maxSize)); qint64 readBytes = read(result.data(), result.size()); @@ -1402,17 +1407,13 @@ QByteArray QIODevice::readLine(qint64 maxSize) QByteArray result; CHECK_MAXLEN(readLine, result); + CHECK_MAXBYTEARRAYSIZE(readLine); #if defined QIODEVICE_DEBUG printf("%p QIODevice::readLine(%lld), d->pos = %lld, d->buffer.size() = %lld\n", this, maxSize, d->pos, d->buffer.size()); #endif - if (maxSize >= MaxByteArraySize) { - qWarning("QIODevice::read: maxSize argument exceeds QByteArray size limit"); - maxSize = MaxByteArraySize - 1; - } - result.resize(int(maxSize)); qint64 readBytes = 0; if (!result.size()) { diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp index 1d425653a3..b39816dd7d 100644 --- a/src/corelib/io/qprocess_unix.cpp +++ b/src/corelib/io/qprocess_unix.cpp @@ -418,7 +418,7 @@ void QProcessPrivate::startProcess() } if (url) { const QCFString str = CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle); - encodedProgramName += (QDir::separator() + QDir(program).relativeFilePath(QCFString::toQString(str))).toUtf8(); + encodedProgramName += (QDir::separator() + QDir(program).relativeFilePath(QString::fromCFString(str))).toUtf8(); } } #endif diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp index b67afe0e0f..675b375b22 100644 --- a/src/corelib/io/qsettings.cpp +++ b/src/corelib/io/qsettings.cpp @@ -427,7 +427,9 @@ QString QSettingsPrivate::variantToString(const QVariant &v) case QVariant::Double: case QVariant::KeySequence: { result = v.toString(); - if (result.startsWith(QLatin1Char('@'))) + if (result.contains(QChar::Null)) + result = QLatin1String("@String(") + result + QLatin1Char(')'); + else if (result.startsWith(QLatin1Char('@'))) result.prepend(QLatin1Char('@')); break; } @@ -487,6 +489,8 @@ QVariant QSettingsPrivate::stringToVariant(const QString &s) if (s.endsWith(QLatin1Char(')'))) { if (s.startsWith(QLatin1String("@ByteArray("))) { return QVariant(s.midRef(11, s.size() - 12).toLatin1()); + } else if (s.startsWith(QLatin1String("@String("))) { + return QVariant(s.midRef(8, s.size() - 9).toString()); } else if (s.startsWith(QLatin1String("@Variant(")) || s.startsWith(QLatin1String("@DateTime("))) { #ifndef QT_NO_DATASTREAM diff --git a/src/corelib/io/qsettings.h b/src/corelib/io/qsettings.h index 21fb9519de..edd59026ed 100644 --- a/src/corelib/io/qsettings.h +++ b/src/corelib/io/qsettings.h @@ -80,6 +80,9 @@ public: AccessError, FormatError }; +#ifndef QT_NO_QOBJECT + Q_ENUM(Status) +#endif enum Format { NativeFormat, @@ -108,11 +111,17 @@ public: CustomFormat15, CustomFormat16 }; +#ifndef QT_NO_QOBJECT + Q_ENUM(Format) +#endif enum Scope { UserScope, SystemScope }; +#ifndef QT_NO_QOBJECT + Q_ENUM(Scope) +#endif #ifndef QT_NO_QOBJECT explicit QSettings(const QString &organization, diff --git a/src/corelib/io/qsettings_mac.cpp b/src/corelib/io/qsettings_mac.cpp index 4ad5a7b398..a31dfc5366 100644 --- a/src/corelib/io/qsettings_mac.cpp +++ b/src/corelib/io/qsettings_mac.cpp @@ -83,12 +83,12 @@ static QString rotateSlashesDotsAndMiddots(const QString &key, int shift) static QCFType<CFStringRef> macKey(const QString &key) { - return QCFString::toCFStringRef(rotateSlashesDotsAndMiddots(key, Macify)); + return rotateSlashesDotsAndMiddots(key, Macify).toCFString(); } static QString qtKey(CFStringRef cfkey) { - return rotateSlashesDotsAndMiddots(QCFString::toQString(cfkey), Qtify); + return rotateSlashesDotsAndMiddots(QString::fromCFString(cfkey), Qtify); } static QCFType<CFPropertyListRef> macValue(const QVariant &value); @@ -160,7 +160,7 @@ static QCFType<CFPropertyListRef> macValue(const QVariant &value) } } - cfkeys[numUniqueKeys] = QCFString::toCFStringRef(key); + cfkeys[numUniqueKeys] = key.toCFString(); cfvalues[numUniqueKeys] = singleton ? macValue(values.constFirst()) : macList(values); ++numUniqueKeys; } @@ -175,17 +175,12 @@ static QCFType<CFPropertyListRef> macValue(const QVariant &value) break; case QVariant::DateTime: { - /* - CFDate, unlike QDateTime, doesn't store timezone information. - */ - QDateTime dt = value.toDateTime(); - if (dt.timeSpec() == Qt::LocalTime) { - QDateTime reference; - reference.setSecsSinceEpoch(qint64(kCFAbsoluteTimeIntervalSince1970)); - result = CFDateCreate(kCFAllocatorDefault, CFAbsoluteTime(reference.secsTo(dt))); - } else { + QDateTime dateTime = value.toDateTime(); + // CFDate, unlike QDateTime, doesn't store timezone information + if (dateTime.timeSpec() == Qt::LocalTime) + result = dateTime.toCFDate(); + else goto string_case; - } } break; case QVariant::Bool: @@ -214,7 +209,11 @@ static QCFType<CFPropertyListRef> macValue(const QVariant &value) case QVariant::String: string_case: default: - result = QCFString::toCFStringRef(QSettingsPrivate::variantToString(value)); + QString string = QSettingsPrivate::variantToString(value); + if (string.contains(QChar::Null)) + result = string.toUtf8().toCFData(); + else + result = string.toCFString(); } return result; } @@ -230,7 +229,7 @@ static QVariant qtValue(CFPropertyListRef cfvalue) Sorted grossly from most to least frequent type. */ if (typeId == CFStringGetTypeID()) { - return QSettingsPrivate::stringToVariant(QCFString::toQString(static_cast<CFStringRef>(cfvalue))); + return QSettingsPrivate::stringToVariant(QString::fromCFString(static_cast<CFStringRef>(cfvalue))); } else if (typeId == CFNumberGetTypeID()) { CFNumberRef cfnumber = static_cast<CFNumberRef>(cfvalue); if (CFNumberIsFloatType(cfnumber)) { @@ -266,9 +265,16 @@ static QVariant qtValue(CFPropertyListRef cfvalue) } else if (typeId == CFBooleanGetTypeID()) { return (bool)CFBooleanGetValue(static_cast<CFBooleanRef>(cfvalue)); } else if (typeId == CFDataGetTypeID()) { - CFDataRef cfdata = static_cast<CFDataRef>(cfvalue); - return QByteArray(reinterpret_cast<const char *>(CFDataGetBytePtr(cfdata)), - CFDataGetLength(cfdata)); + QByteArray byteArray = QByteArray::fromRawCFData(static_cast<CFDataRef>(cfvalue)); + + // Fast-path for QByteArray, so that we don't have to go + // though the expensive and lossy conversion via UTF-8. + if (!byteArray.startsWith('@')) + return byteArray; + + const QString str = QString::fromUtf8(byteArray.constData(), byteArray.size()); + return QSettingsPrivate::stringToVariant(str); + } else if (typeId == CFDictionaryGetTypeID()) { CFDictionaryRef cfdict = static_cast<CFDictionaryRef>(cfvalue); CFTypeID arrayTypeId = CFArrayGetTypeID(); @@ -279,7 +285,7 @@ static QVariant qtValue(CFPropertyListRef cfvalue) QMultiMap<QString, QVariant> map; for (int i = 0; i < size; ++i) { - QString key = QCFString::toQString(static_cast<CFStringRef>(keys[i])); + QString key = QString::fromCFString(static_cast<CFStringRef>(keys[i])); if (CFGetTypeID(values[i]) == arrayTypeId) { CFArrayRef cfarray = static_cast<CFArrayRef>(values[i]); @@ -292,9 +298,7 @@ static QVariant qtValue(CFPropertyListRef cfvalue) } return map; } else if (typeId == CFDateGetTypeID()) { - QDateTime dt; - dt.setSecsSinceEpoch(qint64(kCFAbsoluteTimeIntervalSince1970)); - return dt.addSecs((int)CFDateGetAbsoluteTime(static_cast<CFDateRef>(cfvalue))); + return QDateTime::fromCFDate(static_cast<CFDateRef>(cfvalue)); } return QVariant(); } @@ -571,7 +575,7 @@ QString QMacSettingsPrivate::fileName() const if (scope == QSettings::UserScope) result = QDir::homePath(); result += QLatin1String("/Library/Preferences/"); - result += QCFString::toQString(domains[0].applicationOrSuiteId); + result += QString::fromCFString(domains[0].applicationOrSuiteId); result += QLatin1String(".plist"); return result; } diff --git a/src/corelib/io/qsettings_win.cpp b/src/corelib/io/qsettings_win.cpp index 3f06ab7043..1c10548cbc 100644 --- a/src/corelib/io/qsettings_win.cpp +++ b/src/corelib/io/qsettings_win.cpp @@ -667,15 +667,6 @@ void QWinSettingsPrivate::remove(const QString &uKey) } } -static bool stringContainsNullChar(const QString &s) -{ - for (int i = 0; i < s.length(); ++i) { - if (s.at(i).unicode() == 0) - return true; - } - return false; -} - void QWinSettingsPrivate::set(const QString &uKey, const QVariant &value) { if (writeHandle() == 0) { @@ -704,7 +695,7 @@ void QWinSettingsPrivate::set(const QString &uKey, const QVariant &value) QStringList l = variantListToStringList(value.toList()); QStringList::const_iterator it = l.constBegin(); for (; it != l.constEnd(); ++it) { - if ((*it).length() == 0 || stringContainsNullChar(*it)) { + if ((*it).length() == 0 || it->contains(QChar::Null)) { type = REG_BINARY; break; } @@ -748,7 +739,7 @@ void QWinSettingsPrivate::set(const QString &uKey, const QVariant &value) // If the string does not contain '\0', we can use REG_SZ, the native registry // string type. Otherwise we use REG_BINARY. QString s = variantToString(value); - type = stringContainsNullChar(s) ? REG_BINARY : REG_SZ; + type = s.contains(QChar::Null) ? REG_BINARY : REG_SZ; if (type == REG_BINARY) { regValueBuff = QByteArray((const char*)s.utf16(), s.length() * 2); } else { diff --git a/src/corelib/io/qsettings_winrt.cpp b/src/corelib/io/qsettings_winrt.cpp index 708287ce5e..209b56d920 100644 --- a/src/corelib/io/qsettings_winrt.cpp +++ b/src/corelib/io/qsettings_winrt.cpp @@ -402,7 +402,7 @@ void QWinRTSettingsPrivate::set(const QString &uKey, const QVariant &value) QStringList::const_iterator it = l.constBegin(); bool containsNull = false; for (; it != l.constEnd(); ++it) { - if ((*it).length() == 0 || it->indexOf(QChar::Null) != -1) { + if ((*it).length() == 0 || it->contains(QChar::Null)) { // We can only store as binary containsNull = true; break; @@ -445,7 +445,7 @@ void QWinRTSettingsPrivate::set(const QString &uKey, const QVariant &value) break; default: { const QString s = variantToString(value); - if (s.indexOf(QChar::Null) != -1) { + if (s.contains(QChar::Null)) { hr = valueStatics->CreateUInt8Array(s.length() * 2, (BYTE*) s.utf16(), &val); } else { HStringReference ref((const wchar_t*)s.utf16(), s.size()); diff --git a/src/corelib/io/qstandardpaths_mac.mm b/src/corelib/io/qstandardpaths_mac.mm index dc3d7737b6..a293d4862f 100644 --- a/src/corelib/io/qstandardpaths_mac.mm +++ b/src/corelib/io/qstandardpaths_mac.mm @@ -168,36 +168,11 @@ static QString baseWritableLocation(QStandardPaths::StandardLocation type, QString QStandardPaths::writableLocation(StandardLocation type) { - if (isTestModeEnabled()) { - const QString qttestDir = QDir::homePath() + QLatin1String("/.qttest"); - QString path; - switch (type) { - case GenericDataLocation: - case AppDataLocation: - case AppLocalDataLocation: - path = qttestDir + QLatin1String("/Application Support"); - if (type != GenericDataLocation) - appendOrganizationAndApp(path); - return path; - case GenericCacheLocation: - case CacheLocation: - path = qttestDir + QLatin1String("/Cache"); - if (type == CacheLocation) - appendOrganizationAndApp(path); - return path; - case GenericConfigLocation: - case ConfigLocation: - case AppConfigLocation: - path = qttestDir + QLatin1String("/Preferences"); - if (type == AppConfigLocation) - appendOrganizationAndApp(path); - return path; - default: - break; - } - } + QString location = baseWritableLocation(type, NSUserDomainMask, true); + if (isTestModeEnabled()) + location = location.replace(QDir::homePath(), QDir::homePath() + QLatin1String("/.qttest")); - return baseWritableLocation(type, NSUserDomainMask, true); + return location; } QStringList QStandardPaths::standardLocations(StandardLocation type) @@ -230,13 +205,13 @@ QStringList QStandardPaths::standardLocations(StandardLocation type) if (mainBundle) { CFURLRef bundleUrl = CFBundleCopyBundleURL(mainBundle); CFStringRef cfBundlePath = CFURLCopyPath(bundleUrl); - QString bundlePath = QCFString::toQString(cfBundlePath); + QString bundlePath = QString::fromCFString(cfBundlePath); CFRelease(cfBundlePath); CFRelease(bundleUrl); CFURLRef resourcesUrl = CFBundleCopyResourcesDirectoryURL(mainBundle); CFStringRef cfResourcesPath = CFURLCopyPath(resourcesUrl); - QString resourcesPath = QCFString::toQString(cfResourcesPath); + QString resourcesPath = QString::fromCFString(cfResourcesPath); CFRelease(cfResourcesPath); CFRelease(resourcesUrl); diff --git a/src/corelib/io/qtemporaryfile.cpp b/src/corelib/io/qtemporaryfile.cpp index c430c7714a..7aae128796 100644 --- a/src/corelib/io/qtemporaryfile.cpp +++ b/src/corelib/io/qtemporaryfile.cpp @@ -665,7 +665,7 @@ QString QTemporaryFile::fileTemplate() const /*! Sets the static portion of the file name to \a name. If the file - template ends in XXXXXX that will automatically be replaced with + template contains XXXXXX that will automatically be replaced with the unique part of the filename, otherwise a filename will be determined automatically based on the static portion specified. diff --git a/src/corelib/io/qtldurl.cpp b/src/corelib/io/qtldurl.cpp index dd0ee6068d..96543bbbfd 100644 --- a/src/corelib/io/qtldurl.cpp +++ b/src/corelib/io/qtldurl.cpp @@ -37,6 +37,10 @@ ** ****************************************************************************/ +#include <qglobal.h> + +#if QT_CONFIG(topleveldomain) + #include "qplatformdefs.h" #include "qurl.h" #include "private/qurltlds_p.h" @@ -125,3 +129,5 @@ Q_CORE_EXPORT bool qIsEffectiveTLD(const QStringRef &domain) } QT_END_NAMESPACE + +#endif diff --git a/src/corelib/io/qtldurl_p.h b/src/corelib/io/qtldurl_p.h index b9fbdebbc5..4636f18874 100644 --- a/src/corelib/io/qtldurl_p.h +++ b/src/corelib/io/qtldurl_p.h @@ -55,6 +55,8 @@ #include "QtCore/qurl.h" #include "QtCore/qstring.h" +QT_REQUIRE_CONFIG(topleveldomain); + QT_BEGIN_NAMESPACE Q_CORE_EXPORT QString qTopLevelDomain(const QString &domain); diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index 42a742213b..c165aef5a2 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -3117,6 +3117,7 @@ bool QUrl::hasFragment() const return d->hasFragment(); } +#if QT_CONFIG(topleveldomain) /*! \since 4.8 @@ -3151,6 +3152,7 @@ QString QUrl::topLevelDomain(ComponentFormattingOptions options) const } return tld; } +#endif /*! Returns the result of the merge of this URL with \a relative. This diff --git a/src/corelib/io/qurl.h b/src/corelib/io/qurl.h index bce271fcb1..a554a3b07e 100644 --- a/src/corelib/io/qurl.h +++ b/src/corelib/io/qurl.h @@ -235,7 +235,9 @@ public: void setHost(const QString &host, ParsingMode mode = DecodedMode); QString host(ComponentFormattingOptions = FullyDecoded) const; +#if QT_CONFIG(topleveldomain) QString topLevelDomain(ComponentFormattingOptions options = FullyDecoded) const; +#endif void setPort(int port); int port(int defaultPort = -1) const; diff --git a/src/corelib/kernel/qcore_foundation.mm b/src/corelib/kernel/qcore_foundation.mm index 2291017a5d..f5ccd1c1f2 100644 --- a/src/corelib/kernel/qcore_foundation.mm +++ b/src/corelib/kernel/qcore_foundation.mm @@ -375,8 +375,8 @@ QDateTime QDateTime::fromCFDate(CFDateRef date) { if (!date) return QDateTime(); - return QDateTime::fromMSecsSinceEpoch(static_cast<qint64>((CFDateGetAbsoluteTime(date) - + kCFAbsoluteTimeIntervalSince1970) * 1000)); + CFAbsoluteTime sSinceEpoch = kCFAbsoluteTimeIntervalSince1970 + CFDateGetAbsoluteTime(date); + return QDateTime::fromMSecsSinceEpoch(qRound64(sSinceEpoch * 1000)); } /*! @@ -404,7 +404,7 @@ QDateTime QDateTime::fromNSDate(const NSDate *date) { if (!date) return QDateTime(); - return QDateTime::fromMSecsSinceEpoch(static_cast<qint64>([date timeIntervalSince1970] * 1000)); + return QDateTime::fromMSecsSinceEpoch(qRound64([date timeIntervalSince1970] * 1000)); } /*! diff --git a/src/corelib/kernel/qcore_mac.cpp b/src/corelib/kernel/qcore_mac.cpp index 10b8d03d1c..c689f47d8f 100644 --- a/src/corelib/kernel/qcore_mac.cpp +++ b/src/corelib/kernel/qcore_mac.cpp @@ -43,37 +43,17 @@ QT_BEGIN_NAMESPACE -QString QCFString::toQString(CFStringRef str) -{ - if(!str) - return QString(); - CFIndex length = CFStringGetLength(str); - const UniChar *chars = CFStringGetCharactersPtr(str); - if (chars) - return QString(reinterpret_cast<const QChar *>(chars), length); - - QVarLengthArray<UniChar> buffer(length); - CFStringGetCharacters(str, CFRangeMake(0, length), buffer.data()); - return QString(reinterpret_cast<const QChar *>(buffer.constData()), length); -} - QCFString::operator QString() const { if (string.isEmpty() && type) - const_cast<QCFString*>(this)->string = toQString(type); + const_cast<QCFString*>(this)->string = QString::fromCFString(type); return string; } -CFStringRef QCFString::toCFStringRef(const QString &string) -{ - return CFStringCreateWithCharacters(0, reinterpret_cast<const UniChar *>(string.unicode()), - string.length()); -} - QCFString::operator CFStringRef() const { if (!type) - const_cast<QCFString*>(this)->type = toCFStringRef(string); + const_cast<QCFString*>(this)->type = string.toCFString(); return type; } diff --git a/src/corelib/kernel/qcore_mac_objc.mm b/src/corelib/kernel/qcore_mac_objc.mm index 42f5699928..231afb991c 100644 --- a/src/corelib/kernel/qcore_mac_objc.mm +++ b/src/corelib/kernel/qcore_mac_objc.mm @@ -49,17 +49,6 @@ QT_BEGIN_NAMESPACE -NSString *QCFString::toNSString(const QString &string) -{ - // The const cast below is safe: CfStringRef is immutable and so is NSString. - return [const_cast<NSString *>(reinterpret_cast<const NSString *>(toCFStringRef(string))) autorelease]; -} - -QString QCFString::toQString(const NSString *nsstr) -{ - return toQString(reinterpret_cast<CFStringRef>(nsstr)); -} - // ------------------------------------------------------------------------- QDebug operator<<(QDebug dbg, const NSObject *nsObject) diff --git a/src/corelib/kernel/qcore_mac_p.h b/src/corelib/kernel/qcore_mac_p.h index 8a710a8a1f..d0edef33a2 100644 --- a/src/corelib/kernel/qcore_mac_p.h +++ b/src/corelib/kernel/qcore_mac_p.h @@ -126,12 +126,6 @@ public: inline QCFString(const QCFType<CFStringRef> &other) : QCFType<CFStringRef>(other) {} operator QString() const; operator CFStringRef() const; - static QString toQString(CFStringRef cfstr); - static CFStringRef toCFStringRef(const QString &str); -#ifdef __OBJC__ - static QString toQString(const NSString *nsstr); - static NSString *toNSString(const QString &string); -#endif private: QString string; diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 0413e06665..adefea4f09 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -150,7 +150,7 @@ QString QCoreApplicationPrivate::macMenuBarName() QString bundleName; CFTypeRef string = CFBundleGetValueForInfoDictionaryKey(CFBundleGetMainBundle(), CFSTR("CFBundleName")); if (string) - bundleName = QCFString::toQString(static_cast<CFStringRef>(string)); + bundleName = QString::fromCFString(static_cast<CFStringRef>(string)); return bundleName; } #endif @@ -1260,18 +1260,30 @@ int QCoreApplication::exec() self->d_func()->aboutToQuitEmitted = false; int returnCode = eventLoop.exec(); threadData->quitNow = false; - if (self) { - self->d_func()->in_exec = false; - if (!self->d_func()->aboutToQuitEmitted) - emit self->aboutToQuit(QPrivateSignal()); - self->d_func()->aboutToQuitEmitted = true; - sendPostedEvents(0, QEvent::DeferredDelete); - } + + if (self) + self->d_func()->execCleanup(); return returnCode; } +// Cleanup after eventLoop is done executing in QCoreApplication::exec(). +// This is for use cases in which QCoreApplication is instantiated by a +// library and not by an application executable, for example, Active X +// servers. + +void QCoreApplicationPrivate::execCleanup() +{ + threadData->quitNow = false; + in_exec = false; + if (!aboutToQuitEmitted) + emit q_func()->aboutToQuit(QCoreApplication::QPrivateSignal()); + aboutToQuitEmitted = true; + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); +} + + /*! Tells the application to exit with a return code. diff --git a/src/corelib/kernel/qcoreapplication_p.h b/src/corelib/kernel/qcoreapplication_p.h index 445bae01b4..3601add098 100644 --- a/src/corelib/kernel/qcoreapplication_p.h +++ b/src/corelib/kernel/qcoreapplication_p.h @@ -145,6 +145,8 @@ public: static inline void clearApplicationFilePath() { delete cachedApplicationFilePath; cachedApplicationFilePath = 0; } #ifndef QT_NO_QOBJECT + void execCleanup(); + bool in_exec; bool aboutToQuitEmitted; bool threadData_clean; diff --git a/src/corelib/kernel/qcoreglobaldata.cpp b/src/corelib/kernel/qcoreglobaldata.cpp index e5fb50715c..e2087b9e64 100644 --- a/src/corelib/kernel/qcoreglobaldata.cpp +++ b/src/corelib/kernel/qcoreglobaldata.cpp @@ -45,15 +45,19 @@ QT_BEGIN_NAMESPACE Q_GLOBAL_STATIC(QCoreGlobalData, globalInstance) QCoreGlobalData::QCoreGlobalData() +#if QT_CONFIG(textcodec) : codecForLocale(0) +#endif { } QCoreGlobalData::~QCoreGlobalData() { +#if QT_CONFIG(textcodec) codecForLocale = 0; for (QList<QTextCodec *>::const_iterator it = allCodecs.constBegin(); it != allCodecs.constEnd(); ++it) delete *it; +#endif } QCoreGlobalData *QCoreGlobalData::instance() diff --git a/src/corelib/kernel/qcoreglobaldata_p.h b/src/corelib/kernel/qcoreglobaldata_p.h index 32b5becf4f..c3c2f7b4a4 100644 --- a/src/corelib/kernel/qcoreglobaldata_p.h +++ b/src/corelib/kernel/qcoreglobaldata_p.h @@ -71,9 +71,11 @@ struct QCoreGlobalData { QMap<QString, QStringList> dirSearchPaths; QReadWriteLock dirSearchPathsLock; +#if QT_CONFIG(textcodec) QList<QTextCodec*> allCodecs; QAtomicPointer<QTextCodec> codecForLocale; QTextCodecCache codecCache; +#endif static QCoreGlobalData *instance(); }; diff --git a/src/corelib/kernel/qeventdispatcher_cf.mm b/src/corelib/kernel/qeventdispatcher_cf.mm index eecc72fd94..9ac48f144d 100644 --- a/src/corelib/kernel/qeventdispatcher_cf.mm +++ b/src/corelib/kernel/qeventdispatcher_cf.mm @@ -117,7 +117,7 @@ static CFStringRef runLoopMode(NSDictionary *dictionary) if (CFStringCompare(mode, [self currentMode], 0) == kCFCompareEqualTo) m_runLoopModes.pop(); else - qWarning("Tried to pop run loop mode '%s' that was never pushed!", qPrintable(QCFString::toQString(mode))); + qWarning("Tried to pop run loop mode '%s' that was never pushed!", qPrintable(QString::fromCFString(mode))); Q_ASSERT(m_runLoopModes.size() >= 1); } @@ -285,7 +285,7 @@ bool QEventDispatcherCoreFoundation::processEvents(QEventLoop::ProcessEventsFlag CFTimeInterval duration = (m_processEvents.flags & QEventLoop::WaitForMoreEvents) ? kCFTimeIntervalDistantFuture : kCFTimeIntervalMinimum; - qEventDispatcherDebug() << "Calling CFRunLoopRunInMode = " << qPrintable(QCFString::toQString(mode)) + qEventDispatcherDebug() << "Calling CFRunLoopRunInMode = " << qPrintable(QString::fromCFString(mode)) << " for " << duration << " ms, processing single source = " << returnAfterSingleSourceHandled; qIndent(); SInt32 result = CFRunLoopRunInMode(mode, duration, returnAfterSingleSourceHandled); diff --git a/src/corelib/kernel/qfunctions_winrt.h b/src/corelib/kernel/qfunctions_winrt.h index e0777b8df8..9b33f8b120 100644 --- a/src/corelib/kernel/qfunctions_winrt.h +++ b/src/corelib/kernel/qfunctions_winrt.h @@ -180,7 +180,7 @@ static inline HRESULT _await_impl(const Microsoft::WRL::ComPtr<T> &asyncOp, Awai t.start(); switch (awaitStyle) { case ProcessMainThreadEvents: - while (SUCCEEDED(hr = asyncInfo->get_Status(&status)) && status == Started) { + while (SUCCEEDED(hr = asyncInfo->get_Status(&status)) && status == AsyncStatus::Started) { QCoreApplication::processEvents(); if (timeout && t.hasExpired(timeout)) return ERROR_TIMEOUT; @@ -188,7 +188,7 @@ static inline HRESULT _await_impl(const Microsoft::WRL::ComPtr<T> &asyncOp, Awai break; case ProcessThreadEvents: if (QAbstractEventDispatcher *dispatcher = QThread::currentThread()->eventDispatcher()) { - while (SUCCEEDED(hr = asyncInfo->get_Status(&status)) && status == Started) { + while (SUCCEEDED(hr = asyncInfo->get_Status(&status)) && status == AsyncStatus::Started) { dispatcher->processEvents(QEventLoop::AllEvents); if (timeout && t.hasExpired(timeout)) return ERROR_TIMEOUT; @@ -198,7 +198,7 @@ static inline HRESULT _await_impl(const Microsoft::WRL::ComPtr<T> &asyncOp, Awai // fall through default: case YieldThread: - while (SUCCEEDED(hr = asyncInfo->get_Status(&status)) && status == Started) { + while (SUCCEEDED(hr = asyncInfo->get_Status(&status)) && status == AsyncStatus::Started) { QThread::yieldCurrentThread(); if (timeout && t.hasExpired(timeout)) return ERROR_TIMEOUT; @@ -206,7 +206,7 @@ static inline HRESULT _await_impl(const Microsoft::WRL::ComPtr<T> &asyncOp, Awai break; } - if (FAILED(hr) || status != Completed) { + if (FAILED(hr) || status != AsyncStatus::Completed) { HRESULT ec; hr = asyncInfo->get_ErrorCode(&ec); if (FAILED(hr)) diff --git a/src/corelib/kernel/qtimer.cpp b/src/corelib/kernel/qtimer.cpp index 8ba494ec3d..6d39233aa7 100644 --- a/src/corelib/kernel/qtimer.cpp +++ b/src/corelib/kernel/qtimer.cpp @@ -611,6 +611,8 @@ void QTimer::singleShot(int msec, Qt::TimerType timerType, const QObject *receiv A single-shot timer fires only once, non-single-shot timers fire every \l interval milliseconds. + The default value for this property is \c false. + \sa interval, singleShot() */ diff --git a/src/corelib/statemachine/qabstractstate.cpp b/src/corelib/statemachine/qabstractstate.cpp index 13b669d3f6..13bf41faa9 100644 --- a/src/corelib/statemachine/qabstractstate.cpp +++ b/src/corelib/statemachine/qabstractstate.cpp @@ -38,9 +38,6 @@ ****************************************************************************/ #include "qabstractstate.h" - -#ifndef QT_NO_STATEMACHINE - #include "qabstractstate_p.h" #include "qstate.h" #include "qstate_p.h" @@ -237,5 +234,3 @@ bool QAbstractState::event(QEvent *e) } QT_END_NAMESPACE - -#endif //QT_NO_STATEMACHINE diff --git a/src/corelib/statemachine/qabstractstate.h b/src/corelib/statemachine/qabstractstate.h index 24e312ac5b..02c7d9e830 100644 --- a/src/corelib/statemachine/qabstractstate.h +++ b/src/corelib/statemachine/qabstractstate.h @@ -42,10 +42,9 @@ #include <QtCore/qobject.h> -QT_BEGIN_NAMESPACE - +QT_REQUIRE_CONFIG(statemachine); -#ifndef QT_NO_STATEMACHINE +QT_BEGIN_NAMESPACE class QState; class QStateMachine; @@ -84,8 +83,6 @@ private: Q_DECLARE_PRIVATE(QAbstractState) }; -#endif //QT_NO_STATEMACHINE - QT_END_NAMESPACE #endif diff --git a/src/corelib/statemachine/qabstractstate_p.h b/src/corelib/statemachine/qabstractstate_p.h index 552125f95a..11befc187e 100644 --- a/src/corelib/statemachine/qabstractstate_p.h +++ b/src/corelib/statemachine/qabstractstate_p.h @@ -51,13 +51,11 @@ // We mean it. // -#include <QtCore/qglobal.h> - -#ifndef QT_NO_STATEMACHINE - #include <private/qobject_p.h> #include <QtCore/qabstractstate.h> +QT_REQUIRE_CONFIG(statemachine); + QT_BEGIN_NAMESPACE class QStateMachine; @@ -98,6 +96,4 @@ public: QT_END_NAMESPACE -#endif // QT_NO_STATEMACHINE - #endif // QABSTRACTSTATE_P_H diff --git a/src/corelib/statemachine/qabstracttransition.cpp b/src/corelib/statemachine/qabstracttransition.cpp index 42d1342e10..8c30d5f11c 100644 --- a/src/corelib/statemachine/qabstracttransition.cpp +++ b/src/corelib/statemachine/qabstracttransition.cpp @@ -38,9 +38,6 @@ ****************************************************************************/ #include "qabstracttransition.h" - -#ifndef QT_NO_STATEMACHINE - #include "qabstracttransition_p.h" #include "qabstractstate.h" #include "qhistorystate.h" @@ -434,5 +431,3 @@ bool QAbstractTransition::event(QEvent *e) } QT_END_NAMESPACE - -#endif //QT_NO_STATEMACHINE diff --git a/src/corelib/statemachine/qabstracttransition.h b/src/corelib/statemachine/qabstracttransition.h index 41acaa643b..b86d26e969 100644 --- a/src/corelib/statemachine/qabstracttransition.h +++ b/src/corelib/statemachine/qabstracttransition.h @@ -44,10 +44,9 @@ #include <QtCore/qlist.h> -QT_BEGIN_NAMESPACE - +QT_REQUIRE_CONFIG(statemachine); -#ifndef QT_NO_STATEMACHINE +QT_BEGIN_NAMESPACE class QEvent; class QAbstractState; @@ -113,8 +112,6 @@ private: Q_DECLARE_PRIVATE(QAbstractTransition) }; -#endif //QT_NO_STATEMACHINE - QT_END_NAMESPACE #endif diff --git a/src/corelib/statemachine/qabstracttransition_p.h b/src/corelib/statemachine/qabstracttransition_p.h index fd7a9dc311..e11514670e 100644 --- a/src/corelib/statemachine/qabstracttransition_p.h +++ b/src/corelib/statemachine/qabstracttransition_p.h @@ -57,6 +57,8 @@ #include <QtCore/qvector.h> #include <QtCore/qsharedpointer.h> +QT_REQUIRE_CONFIG(statemachine); + QT_BEGIN_NAMESPACE class QAbstractState; diff --git a/src/corelib/statemachine/qeventtransition.cpp b/src/corelib/statemachine/qeventtransition.cpp index ecf40e9c9c..cd0cfe2f85 100644 --- a/src/corelib/statemachine/qeventtransition.cpp +++ b/src/corelib/statemachine/qeventtransition.cpp @@ -38,9 +38,6 @@ ****************************************************************************/ #include "qeventtransition.h" - -#ifndef QT_NO_STATEMACHINE - #include "qeventtransition_p.h" #include "qstate.h" #include "qstate_p.h" @@ -255,5 +252,3 @@ bool QEventTransition::event(QEvent *e) } QT_END_NAMESPACE - -#endif //QT_NO_STATEMACHINE diff --git a/src/corelib/statemachine/qeventtransition.h b/src/corelib/statemachine/qeventtransition.h index 454ad1199c..3c66e72658 100644 --- a/src/corelib/statemachine/qeventtransition.h +++ b/src/corelib/statemachine/qeventtransition.h @@ -43,10 +43,9 @@ #include <QtCore/qabstracttransition.h> #include <QtCore/qcoreevent.h> -QT_BEGIN_NAMESPACE - +QT_REQUIRE_CONFIG(qeventtransition); -#ifndef QT_NO_STATEMACHINE +QT_BEGIN_NAMESPACE class QEventTransitionPrivate; class Q_CORE_EXPORT QEventTransition : public QAbstractTransition @@ -81,8 +80,6 @@ private: Q_DECLARE_PRIVATE(QEventTransition) }; -#endif //QT_NO_STATEMACHINE - QT_END_NAMESPACE #endif diff --git a/src/corelib/statemachine/qeventtransition_p.h b/src/corelib/statemachine/qeventtransition_p.h index 020a2f9cba..e30e12bc8d 100644 --- a/src/corelib/statemachine/qeventtransition_p.h +++ b/src/corelib/statemachine/qeventtransition_p.h @@ -53,6 +53,8 @@ #include "private/qabstracttransition_p.h" +QT_REQUIRE_CONFIG(qeventtransition); + QT_BEGIN_NAMESPACE class QEventTransition; diff --git a/src/corelib/statemachine/qfinalstate.cpp b/src/corelib/statemachine/qfinalstate.cpp index efcb364794..bef9fc4239 100644 --- a/src/corelib/statemachine/qfinalstate.cpp +++ b/src/corelib/statemachine/qfinalstate.cpp @@ -39,8 +39,6 @@ #include "qfinalstate_p.h" -#ifndef QT_NO_STATEMACHINE - QT_BEGIN_NAMESPACE /*! @@ -139,5 +137,3 @@ bool QFinalState::event(QEvent *e) } QT_END_NAMESPACE - -#endif //QT_NO_STATEMACHINE diff --git a/src/corelib/statemachine/qfinalstate.h b/src/corelib/statemachine/qfinalstate.h index 9b6b193231..1563bef397 100644 --- a/src/corelib/statemachine/qfinalstate.h +++ b/src/corelib/statemachine/qfinalstate.h @@ -42,9 +42,9 @@ #include <QtCore/qabstractstate.h> -QT_BEGIN_NAMESPACE +QT_REQUIRE_CONFIG(statemachine); -#ifndef QT_NO_STATEMACHINE +QT_BEGIN_NAMESPACE class QFinalStatePrivate; class Q_CORE_EXPORT QFinalState : public QAbstractState @@ -68,8 +68,6 @@ private: Q_DECLARE_PRIVATE(QFinalState) }; -#endif //QT_NO_STATEMACHINE - QT_END_NAMESPACE #endif diff --git a/src/corelib/statemachine/qfinalstate_p.h b/src/corelib/statemachine/qfinalstate_p.h index 74640289f1..57de703fe9 100644 --- a/src/corelib/statemachine/qfinalstate_p.h +++ b/src/corelib/statemachine/qfinalstate_p.h @@ -48,7 +48,7 @@ #include "qfinalstate.h" #include "private/qabstractstate_p.h" -#ifndef QT_NO_STATEMACHINE +QT_REQUIRE_CONFIG(statemachine); QT_BEGIN_NAMESPACE @@ -63,6 +63,4 @@ public: QT_END_NAMESPACE -#endif // QT_NO_STATEMACHINE - #endif // QFINALSTATE_P_H diff --git a/src/corelib/statemachine/qhistorystate.cpp b/src/corelib/statemachine/qhistorystate.cpp index 338c89c688..b1c5a92d00 100644 --- a/src/corelib/statemachine/qhistorystate.cpp +++ b/src/corelib/statemachine/qhistorystate.cpp @@ -38,9 +38,6 @@ ****************************************************************************/ #include "qhistorystate.h" - -#ifndef QT_NO_STATEMACHINE - #include "qhistorystate_p.h" QT_BEGIN_NAMESPACE @@ -313,5 +310,3 @@ bool QHistoryState::event(QEvent *e) */ QT_END_NAMESPACE - -#endif //QT_NO_STATEMACHINE diff --git a/src/corelib/statemachine/qhistorystate.h b/src/corelib/statemachine/qhistorystate.h index 89d4d7a9e4..c20053abf6 100644 --- a/src/corelib/statemachine/qhistorystate.h +++ b/src/corelib/statemachine/qhistorystate.h @@ -42,10 +42,9 @@ #include <QtCore/qabstractstate.h> -QT_BEGIN_NAMESPACE - +QT_REQUIRE_CONFIG(statemachine); -#ifndef QT_NO_STATEMACHINE +QT_BEGIN_NAMESPACE class QAbstractTransition; class QHistoryStatePrivate; @@ -91,8 +90,6 @@ private: Q_DECLARE_PRIVATE(QHistoryState) }; -#endif //QT_NO_STATEMACHINE - QT_END_NAMESPACE #endif diff --git a/src/corelib/statemachine/qhistorystate_p.h b/src/corelib/statemachine/qhistorystate_p.h index ae9ed431cb..4a4442d7dd 100644 --- a/src/corelib/statemachine/qhistorystate_p.h +++ b/src/corelib/statemachine/qhistorystate_p.h @@ -52,13 +52,12 @@ // #include "private/qabstractstate_p.h" - -#ifndef QT_NO_STATEMACHINE - #include <QtCore/qabstracttransition.h> #include <QtCore/qhistorystate.h> #include <QtCore/qlist.h> +QT_REQUIRE_CONFIG(statemachine); + QT_BEGIN_NAMESPACE class QHistoryStatePrivate : public QAbstractStatePrivate @@ -95,6 +94,4 @@ protected: QT_END_NAMESPACE -#endif // QT_NO_STATEMACHINE - #endif // QHISTORYSTATE_P_H diff --git a/src/corelib/statemachine/qsignaleventgenerator_p.h b/src/corelib/statemachine/qsignaleventgenerator_p.h index 92b1ee3b70..271f6317bd 100644 --- a/src/corelib/statemachine/qsignaleventgenerator_p.h +++ b/src/corelib/statemachine/qsignaleventgenerator_p.h @@ -54,6 +54,8 @@ #include <QtCore/private/qglobal_p.h> #include <QtCore/qobject.h> +QT_REQUIRE_CONFIG(statemachine); + QT_BEGIN_NAMESPACE class QStateMachine; diff --git a/src/corelib/statemachine/qsignaltransition.cpp b/src/corelib/statemachine/qsignaltransition.cpp index c4ba8e5315..3b219bda53 100644 --- a/src/corelib/statemachine/qsignaltransition.cpp +++ b/src/corelib/statemachine/qsignaltransition.cpp @@ -38,9 +38,6 @@ ****************************************************************************/ #include "qsignaltransition.h" - -#ifndef QT_NO_STATEMACHINE - #include "qsignaltransition_p.h" #include "qstate.h" #include "qstate_p.h" @@ -287,5 +284,3 @@ void QSignalTransitionPrivate::callOnTransition(QEvent *e) QT_END_NAMESPACE - -#endif //QT_NO_STATEMACHINE diff --git a/src/corelib/statemachine/qsignaltransition.h b/src/corelib/statemachine/qsignaltransition.h index d7cf8584da..97c2916d9a 100644 --- a/src/corelib/statemachine/qsignaltransition.h +++ b/src/corelib/statemachine/qsignaltransition.h @@ -43,10 +43,9 @@ #include <QtCore/qabstracttransition.h> #include <QtCore/qmetaobject.h> -QT_BEGIN_NAMESPACE - +QT_REQUIRE_CONFIG(statemachine); -#ifndef QT_NO_STATEMACHINE +QT_BEGIN_NAMESPACE class QSignalTransitionPrivate; class Q_CORE_EXPORT QSignalTransition : public QAbstractTransition @@ -95,8 +94,6 @@ private: Q_DECLARE_PRIVATE(QSignalTransition) }; -#endif //QT_NO_STATEMACHINE - QT_END_NAMESPACE #endif diff --git a/src/corelib/statemachine/qsignaltransition_p.h b/src/corelib/statemachine/qsignaltransition_p.h index 6820bf3bcb..f270a5be4a 100644 --- a/src/corelib/statemachine/qsignaltransition_p.h +++ b/src/corelib/statemachine/qsignaltransition_p.h @@ -53,6 +53,8 @@ #include "private/qabstracttransition_p.h" +QT_REQUIRE_CONFIG(statemachine); + QT_BEGIN_NAMESPACE class QSignalTransition; diff --git a/src/corelib/statemachine/qstate.cpp b/src/corelib/statemachine/qstate.cpp index cae6474c32..48456424cf 100644 --- a/src/corelib/statemachine/qstate.cpp +++ b/src/corelib/statemachine/qstate.cpp @@ -38,9 +38,6 @@ ****************************************************************************/ #include "qstate_p.h" - -#ifndef QT_NO_STATEMACHINE - #include "qhistorystate.h" #include "qhistorystate_p.h" #include "qabstracttransition.h" @@ -602,5 +599,3 @@ bool QState::event(QEvent *e) */ QT_END_NAMESPACE - -#endif //QT_NO_STATEMACHINE diff --git a/src/corelib/statemachine/qstate.h b/src/corelib/statemachine/qstate.h index 7a9dc9c132..33f84c2de0 100644 --- a/src/corelib/statemachine/qstate.h +++ b/src/corelib/statemachine/qstate.h @@ -44,10 +44,9 @@ #include <QtCore/qlist.h> #include <QtCore/qmetaobject.h> -QT_BEGIN_NAMESPACE - +QT_REQUIRE_CONFIG(statemachine); -#ifndef QT_NO_STATEMACHINE +QT_BEGIN_NAMESPACE class QAbstractTransition; class QSignalTransition; @@ -130,8 +129,6 @@ private: Q_DECLARE_PRIVATE(QState) }; -#endif //QT_NO_STATEMACHINE - QT_END_NAMESPACE #endif diff --git a/src/corelib/statemachine/qstate_p.h b/src/corelib/statemachine/qstate_p.h index 913657e53b..7fb40392e7 100644 --- a/src/corelib/statemachine/qstate_p.h +++ b/src/corelib/statemachine/qstate_p.h @@ -59,7 +59,7 @@ #include <QtCore/qpointer.h> #include <QtCore/qvariant.h> -#ifndef QT_NO_STATEMACHINE +QT_REQUIRE_CONFIG(statemachine); QT_BEGIN_NAMESPACE @@ -124,6 +124,4 @@ public: QT_END_NAMESPACE -#endif // QT_NO_STATEMACHINE - #endif diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp index db395b24dd..433f595611 100644 --- a/src/corelib/statemachine/qstatemachine.cpp +++ b/src/corelib/statemachine/qstatemachine.cpp @@ -38,9 +38,6 @@ ****************************************************************************/ #include "qstatemachine.h" - -#ifndef QT_NO_STATEMACHINE - #include "qstate.h" #include "qstate_p.h" #include "qstatemachine_p.h" @@ -3235,5 +3232,3 @@ QT_END_NAMESPACE #include "qstatemachine.moc" #include "moc_qstatemachine.cpp" - -#endif //QT_NO_STATEMACHINE diff --git a/src/corelib/statemachine/qstatemachine.h b/src/corelib/statemachine/qstatemachine.h index 031d9ceee2..4f31252eed 100644 --- a/src/corelib/statemachine/qstatemachine.h +++ b/src/corelib/statemachine/qstatemachine.h @@ -48,10 +48,9 @@ #include <QtCore/qset.h> #include <QtCore/qvariant.h> -QT_BEGIN_NAMESPACE - +QT_REQUIRE_CONFIG(statemachine); -#ifndef QT_NO_STATEMACHINE +QT_BEGIN_NAMESPACE class QStateMachinePrivate; class QAbstractAnimation; @@ -183,8 +182,6 @@ private: Q_PRIVATE_SLOT(d_func(), void _q_killDelayedEventTimer(int, int)) }; -#endif //QT_NO_STATEMACHINE - QT_END_NAMESPACE #endif diff --git a/src/corelib/statemachine/qstatemachine_p.h b/src/corelib/statemachine/qstatemachine_p.h index 45634e27fb..9418813afd 100644 --- a/src/corelib/statemachine/qstatemachine_p.h +++ b/src/corelib/statemachine/qstatemachine_p.h @@ -63,6 +63,8 @@ #include <QtCore/qvector.h> #include <private/qfreelist_p.h> +QT_REQUIRE_CONFIG(statemachine); + QT_BEGIN_NAMESPACE class QEvent; diff --git a/src/corelib/statemachine/statemachine.pri b/src/corelib/statemachine/statemachine.pri index 52df10a3bc..ee701ebc37 100644 --- a/src/corelib/statemachine/statemachine.pri +++ b/src/corelib/statemachine/statemachine.pri @@ -1,3 +1,5 @@ +!qtConfig(statemachine): return() + HEADERS += $$PWD/qstatemachine.h \ $$PWD/qstatemachine_p.h \ $$PWD/qsignaleventgenerator_p.h \ diff --git a/src/corelib/tools/qcommandlineoption.h b/src/corelib/tools/qcommandlineoption.h index 6ebaab3d48..4dcae03ad9 100644 --- a/src/corelib/tools/qcommandlineoption.h +++ b/src/corelib/tools/qcommandlineoption.h @@ -43,6 +43,8 @@ #include <QtCore/qstringlist.h> #include <QtCore/qshareddata.h> +QT_REQUIRE_CONFIG(commandlineparser); + QT_BEGIN_NAMESPACE class QCommandLineOptionPrivate; diff --git a/src/corelib/tools/qcommandlineparser.h b/src/corelib/tools/qcommandlineparser.h index 51bab66ca7..4584c384cc 100644 --- a/src/corelib/tools/qcommandlineparser.h +++ b/src/corelib/tools/qcommandlineparser.h @@ -45,6 +45,8 @@ #include <QtCore/qcoreapplication.h> #include <QtCore/qcommandlineoption.h> +QT_REQUIRE_CONFIG(commandlineparser); + QT_BEGIN_NAMESPACE class QCommandLineParserPrivate; diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index ac8054ce82..50b9f0decb 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -46,7 +46,9 @@ #include "qset.h" #include "qlocale.h" #include "qdatetime.h" +#if QT_CONFIG(timezone) #include "qtimezoneprivate_p.h" +#endif #include "qregexp.h" #include "qdebug.h" #ifndef Q_OS_WIN @@ -1328,7 +1330,7 @@ QDate QDate::fromString(const QString& string, Qt::DateFormat format) QDate QDate::fromString(const QString &string, const QString &format) { QDate date; -#ifndef QT_BOOTSTRAPPED +#if QT_CONFIG(timezone) QDateTimeParser dt(QVariant::Date, QDateTimeParser::FromString); // dt.setDefaultLocale(QLocale::c()); ### Qt 6 if (dt.parseFormat(format)) @@ -2017,7 +2019,7 @@ QTime QTime::fromString(const QString& string, Qt::DateFormat format) QTime QTime::fromString(const QString &string, const QString &format) { QTime time; -#ifndef QT_BOOTSTRAPPED +#if QT_CONFIG(timezone) QDateTimeParser dt(QVariant::Time, QDateTimeParser::FromString); // dt.setDefaultLocale(QLocale::c()); ### Qt 6 if (dt.parseFormat(format)) @@ -2576,7 +2578,7 @@ static void refreshDateTime(QDateTimeData &d) QTime testTime; Q_ASSERT(spec == Qt::TimeZone || spec == Qt::LocalTime); -#ifndef QT_BOOTSTRAPPED +#if QT_CONFIG(timezone) // If not valid time zone then is invalid if (spec == Qt::TimeZone) { if (!d->m_timeZone.isValid()) @@ -2584,7 +2586,7 @@ static void refreshDateTime(QDateTimeData &d) else epochMSecs = QDateTimePrivate::zoneMSecsToEpochMSecs(msecs, d->m_timeZone, &testDate, &testTime); } -#endif // QT_BOOTSTRAPPED +#endif // timezone // If not valid date and time then is invalid if (!(status & QDateTimePrivate::ValidDate) || !(status & QDateTimePrivate::ValidTime)) { @@ -2676,9 +2678,9 @@ static void setTimeSpec(QDateTimeData &d, Qt::TimeSpec spec, int offsetSeconds) d.detach(); d->m_status = status & ~QDateTimePrivate::ShortData; d->m_offsetFromUtc = offsetSeconds; -#ifndef QT_BOOTSTRAPPED +#if QT_CONFIG(timezone) d->m_timeZone = QTimeZone(); -#endif // QT_BOOTSTRAPPED +#endif // timezone } } @@ -2889,7 +2891,7 @@ QDateTime::Data QDateTimePrivate::create(const QDate &toDate, const QTime &toTim return result; } -#ifndef QT_BOOTSTRAPPED +#if QT_CONFIG(timezone) inline QDateTime::Data QDateTimePrivate::create(const QDate &toDate, const QTime &toTime, const QTimeZone &toTimeZone) { @@ -2918,7 +2920,7 @@ inline qint64 QDateTimePrivate::zoneMSecsToEpochMSecs(qint64 zoneMSecs, const QT return zoneMSecs - (data.standardTimeOffset * 1000); } } -#endif // QT_BOOTSTRAPPED +#endif // timezone /***************************************************************************** QDateTime member functions @@ -3112,7 +3114,7 @@ QDateTime::QDateTime(const QDate &date, const QTime &time, Qt::TimeSpec spec, in { } -#ifndef QT_BOOTSTRAPPED +#if QT_CONFIG(timezone) /*! \since 5.2 @@ -3128,7 +3130,7 @@ QDateTime::QDateTime(const QDate &date, const QTime &time, const QTimeZone &time : d(QDateTimePrivate::create(date, time, timeZone)) { } -#endif // QT_BOOTSTRAPPED +#endif // timezone /*! Constructs a copy of the \a other datetime. @@ -3248,7 +3250,7 @@ Qt::TimeSpec QDateTime::timeSpec() const return getSpec(d); } -#ifndef QT_BOOTSTRAPPED +#if QT_CONFIG(timezone) /*! \since 5.2 @@ -3276,7 +3278,7 @@ QTimeZone QDateTime::timeZone() const } return QTimeZone(); } -#endif // QT_BOOTSTRAPPED +#endif // timezone /*! \since 5.2 @@ -3339,15 +3341,15 @@ QString QDateTime::timeZoneAbbreviation() const { switch (getSpec(d)) { case Qt::UTC: - return QTimeZonePrivate::utcQString(); + return QLatin1String("UTC"); case Qt::OffsetFromUTC: - return QTimeZonePrivate::utcQString() + toOffsetString(Qt::ISODate, d->m_offsetFromUtc); + return QLatin1String("UTC") + toOffsetString(Qt::ISODate, d->m_offsetFromUtc); case Qt::TimeZone: -#ifdef QT_BOOTSTRAPPED +#if !QT_CONFIG(timezone) break; #else return d->m_timeZone.d->abbreviation(toMSecsSinceEpoch()); -#endif // QT_BOOTSTRAPPED +#endif // timezone case Qt::LocalTime: { QString abbrev; auto status = extractDaylightStatus(getStatus(d)); @@ -3376,11 +3378,11 @@ bool QDateTime::isDaylightTime() const case Qt::OffsetFromUTC: return false; case Qt::TimeZone: -#ifdef QT_BOOTSTRAPPED +#if !QT_CONFIG(timezone) break; #else return d->m_timeZone.d->isDaylightTime(toMSecsSinceEpoch()); -#endif // QT_BOOTSTRAPPED +#endif // timezone case Qt::LocalTime: { auto status = extractDaylightStatus(getStatus(d)); if (status == QDateTimePrivate::UnknownDaylightTime) @@ -3464,7 +3466,7 @@ void QDateTime::setOffsetFromUtc(int offsetSeconds) checkValidDateTime(d); } -#ifndef QT_BOOTSTRAPPED +#if QT_CONFIG(timezone) /*! \since 5.2 @@ -3484,7 +3486,7 @@ void QDateTime::setTimeZone(const QTimeZone &toZone) d->m_timeZone = toZone; refreshDateTime(d); } -#endif // QT_BOOTSTRAPPED +#endif // timezone /*! \since 4.7 @@ -3517,7 +3519,7 @@ qint64 QDateTime::toMSecsSinceEpoch() const } case Qt::TimeZone: -#ifdef QT_BOOTSTRAPPED +#if !QT_CONFIG(timezone) return 0; #else return QDateTimePrivate::zoneMSecsToEpochMSecs(d->m_msecs, d->m_timeZone); @@ -3615,7 +3617,7 @@ void QDateTime::setMSecsSinceEpoch(qint64 msecs) break; case Qt::TimeZone: Q_ASSERT(!d.isShort()); -#ifndef QT_BOOTSTRAPPED +#if QT_CONFIG(timezone) // Docs state any LocalTime before 1970-01-01 will *not* have any DST applied // but all affected times afterwards will have DST applied. d.detach(); @@ -3628,7 +3630,7 @@ void QDateTime::setMSecsSinceEpoch(qint64 msecs) | QDateTimePrivate::ValidDate | QDateTimePrivate::ValidTime | QDateTimePrivate::ValidDateTime; -#endif // QT_BOOTSTRAPPED +#endif // timezone break; case Qt::LocalTime: { QDate dt; @@ -3905,10 +3907,10 @@ static inline void massageAdjustedDateTime(const QDateTimeData &d, QDate *date, if (spec == Qt::LocalTime) { QDateTimePrivate::DaylightStatus status = QDateTimePrivate::UnknownDaylightTime; localMSecsToEpochMSecs(timeToMSecs(*date, *time), &status, date, time); -#ifndef QT_BOOTSTRAPPED +#if QT_CONFIG(timezone) } else if (spec == Qt::TimeZone) { QDateTimePrivate::zoneMSecsToEpochMSecs(timeToMSecs(*date, *time), d->m_timeZone, date, time); -#endif // QT_BOOTSTRAPPED +#endif // timezone } } @@ -4168,7 +4170,7 @@ QDateTime QDateTime::toOffsetFromUtc(int offsetSeconds) const return fromMSecsSinceEpoch(toMSecsSinceEpoch(), Qt::OffsetFromUTC, offsetSeconds); } -#ifndef QT_BOOTSTRAPPED +#if QT_CONFIG(timezone) /*! \since 5.2 @@ -4190,7 +4192,7 @@ QDateTime QDateTime::toTimeZone(const QTimeZone &timeZone) const return fromMSecsSinceEpoch(toMSecsSinceEpoch(), timeZone); } -#endif // QT_BOOTSTRAPPED +#endif // timezone /*! Returns \c true if this datetime is equal to the \a other datetime; @@ -4449,7 +4451,7 @@ QDateTime QDateTime::fromTime_t(uint seconds, Qt::TimeSpec spec, int offsetSecon return fromMSecsSinceEpoch((qint64)seconds * 1000, spec, offsetSeconds); } -#ifndef QT_BOOTSTRAPPED +#if QT_CONFIG(timezone) /*! \since 5.2 \deprecated @@ -4542,7 +4544,7 @@ QDateTime QDateTime::fromSecsSinceEpoch(qint64 secs, Qt::TimeSpec spec, int offs return fromMSecsSinceEpoch(secs * 1000, spec, offsetSeconds); } -#ifndef QT_BOOTSTRAPPED +#if QT_CONFIG(timezone) /*! \since 5.2 @@ -4931,7 +4933,7 @@ QDateTime QDateTime::fromString(const QString& string, Qt::DateFormat format) QDateTime QDateTime::fromString(const QString &string, const QString &format) { -#ifndef QT_BOOTSTRAPPED +#if QT_CONFIG(timezone) QTime time; QDate date; @@ -5075,10 +5077,10 @@ QDataStream &operator<<(QDataStream &out, const QDateTime &dateTime) out << dateAndTime << qint8(dateTime.timeSpec()); if (dateTime.timeSpec() == Qt::OffsetFromUTC) out << qint32(dateTime.offsetFromUtc()); -#ifndef QT_BOOTSTRAPPED +#if QT_CONFIG(timezone) else if (dateTime.timeSpec() == Qt::TimeZone) out << dateTime.timeZone(); -#endif // QT_BOOTSTRAPPED +#endif // timezone } else if (out.version() == QDataStream::Qt_5_0) { @@ -5135,9 +5137,9 @@ QDataStream &operator>>(QDataStream &in, QDateTime &dateTime) qint8 ts = 0; Qt::TimeSpec spec = Qt::LocalTime; qint32 offset = 0; -#ifndef QT_BOOTSTRAPPED +#if QT_CONFIG(timezone) QTimeZone tz; -#endif // QT_BOOTSTRAPPED +#endif // timezone if (in.version() >= QDataStream::Qt_5_2) { @@ -5147,11 +5149,11 @@ QDataStream &operator>>(QDataStream &in, QDateTime &dateTime) if (spec == Qt::OffsetFromUTC) { in >> offset; dateTime = QDateTime(dt, tm, spec, offset); -#ifndef QT_BOOTSTRAPPED +#if QT_CONFIG(timezone) } else if (spec == Qt::TimeZone) { in >> tz; dateTime = QDateTime(dt, tm, tz); -#endif // QT_BOOTSTRAPPED +#endif // timezone } else { dateTime = QDateTime(dt, tm, spec); } @@ -5177,7 +5179,7 @@ QDataStream &operator>>(QDataStream &in, QDateTime &dateTime) break; case QDateTimePrivate::TimeZone: spec = Qt::TimeZone; -#ifndef QT_BOOTSTRAPPED +#if QT_CONFIG(timezone) // FIXME: need to use a different constructor ! #endif break; @@ -5234,9 +5236,9 @@ QDebug operator<<(QDebug dbg, const QDateTime &date) dbg << ' ' << date.offsetFromUtc() << 's'; break; case Qt::TimeZone: -#ifndef QT_BOOTSTRAPPED +#if QT_CONFIG(timezone) dbg << ' ' << date.timeZone().id(); -#endif // QT_BOOTSTRAPPED +#endif // timezone break; case Qt::LocalTime: break; diff --git a/src/corelib/tools/qdatetime.h b/src/corelib/tools/qdatetime.h index ebf9b45570..c7f14ed40a 100644 --- a/src/corelib/tools/qdatetime.h +++ b/src/corelib/tools/qdatetime.h @@ -253,9 +253,9 @@ public: QDateTime(const QDate &, const QTime &, Qt::TimeSpec spec = Qt::LocalTime); // ### Qt 6: Merge with above with default offsetSeconds = 0 QDateTime(const QDate &date, const QTime &time, Qt::TimeSpec spec, int offsetSeconds); -#ifndef QT_BOOTSTRAPPED +#if QT_CONFIG(timezone) QDateTime(const QDate &date, const QTime &time, const QTimeZone &timeZone); -#endif // QT_BOOTSTRAPPED +#endif // timezone QDateTime(const QDateTime &other) Q_DECL_NOTHROW; QDateTime(QDateTime &&other) Q_DECL_NOTHROW; ~QDateTime(); @@ -274,9 +274,9 @@ public: QTime time() const; Qt::TimeSpec timeSpec() const; int offsetFromUtc() const; -#ifndef QT_BOOTSTRAPPED +#if QT_CONFIG(timezone) QTimeZone timeZone() const; -#endif // QT_BOOTSTRAPPED +#endif // timezone QString timeZoneAbbreviation() const; bool isDaylightTime() const; @@ -287,9 +287,9 @@ public: void setTime(const QTime &time); void setTimeSpec(Qt::TimeSpec spec); void setOffsetFromUtc(int offsetSeconds); -#ifndef QT_BOOTSTRAPPED +#if QT_CONFIG(timezone) void setTimeZone(const QTimeZone &toZone); -#endif // QT_BOOTSTRAPPED +#endif // timezone void setMSecsSinceEpoch(qint64 msecs); void setSecsSinceEpoch(qint64 secs); @@ -307,9 +307,9 @@ public: inline QDateTime toLocalTime() const { return toTimeSpec(Qt::LocalTime); } inline QDateTime toUTC() const { return toTimeSpec(Qt::UTC); } QDateTime toOffsetFromUtc(int offsetSeconds) const; -#ifndef QT_BOOTSTRAPPED +#if QT_CONFIG(timezone) QDateTime toTimeZone(const QTimeZone &toZone) const; -#endif // QT_BOOTSTRAPPED +#endif // timezone qint64 daysTo(const QDateTime &) const; qint64 secsTo(const QDateTime &) const; @@ -348,7 +348,7 @@ public: static QDateTime fromMSecsSinceEpoch(qint64 msecs, Qt::TimeSpec spec, int offsetFromUtc = 0); static QDateTime fromSecsSinceEpoch(qint64 secs, Qt::TimeSpec spe = Qt::LocalTime, int offsetFromUtc = 0); -#ifndef QT_BOOTSTRAPPED +#if QT_CONFIG(timezone) static QDateTime fromMSecsSinceEpoch(qint64 msecs, const QTimeZone &timeZone); static QDateTime fromSecsSinceEpoch(qint64 secs, const QTimeZone &timeZone); #endif diff --git a/src/corelib/tools/qdatetime_p.h b/src/corelib/tools/qdatetime_p.h index 38a084b257..eb33dddbb7 100644 --- a/src/corelib/tools/qdatetime_p.h +++ b/src/corelib/tools/qdatetime_p.h @@ -58,7 +58,9 @@ #include "QtCore/qdatetime.h" #include "QtCore/qpair.h" +#if QT_CONFIG(timezone) #include "qtimezone.h" +#endif QT_BEGIN_NAMESPACE @@ -118,22 +120,22 @@ public: static QDateTime::Data create(const QDate &toDate, const QTime &toTime, Qt::TimeSpec toSpec, int offsetSeconds); -#ifndef QT_BOOTSTRAPPED +#if QT_CONFIG(timezone) static QDateTime::Data create(const QDate &toDate, const QTime &toTime, const QTimeZone & timeZone); -#endif // QT_BOOTSTRAPPED +#endif // timezone qint64 m_msecs; StatusFlags m_status; int m_offsetFromUtc; mutable QAtomicInt ref; -#ifndef QT_BOOTSTRAPPED +#if QT_CONFIG(timezone) QTimeZone m_timeZone; -#endif // QT_BOOTSTRAPPED +#endif // timezone -#ifndef QT_BOOTSTRAPPED +#if QT_CONFIG(timezone) static qint64 zoneMSecsToEpochMSecs(qint64 msecs, const QTimeZone &zone, QDate *localDate = 0, QTime *localTime = 0); -#endif // QT_BOOTSTRAPPED +#endif // timezone static inline qint64 minJd() { return QDate::minJd(); } static inline qint64 maxJd() { return QDate::maxJd(); } diff --git a/src/corelib/tools/qlist.cpp b/src/corelib/tools/qlist.cpp index 1762da2c8f..5f26e704c4 100644 --- a/src/corelib/tools/qlist.cpp +++ b/src/corelib/tools/qlist.cpp @@ -370,7 +370,7 @@ void **QListData::erase(void **xi) application must interface with a C API. \note Iterators into a QLinkedList and references into - heap-allocating QLists remain valid long as the referenced items + heap-allocating QLists remain valid as long as the referenced items remain in the container. This is not true for iterators and references into a QVector and non-heap-allocating QLists. diff --git a/src/corelib/tools/qlocale_mac.mm b/src/corelib/tools/qlocale_mac.mm index 4f6efc8832..8587716446 100644 --- a/src/corelib/tools/qlocale_mac.mm +++ b/src/corelib/tools/qlocale_mac.mm @@ -76,7 +76,7 @@ static QByteArray getMacLocaleName() || (result != "C" && !qt_splitLocaleName(QString::fromLocal8Bit(result), lang, script, cntry))) { QCFType<CFLocaleRef> l = CFLocaleCopyCurrent(); CFStringRef locale = CFLocaleGetIdentifier(l); - result = QCFString::toQString(locale).toUtf8(); + result = QString::fromCFString(locale).toUtf8(); } return result; } @@ -96,7 +96,7 @@ static QString macMonthName(int month, bool short_format) : kCFDateFormatterMonthSymbols)); if (values != 0) { CFStringRef cfstring = static_cast<CFStringRef>(CFArrayGetValueAtIndex(values, month)); - return QCFString::toQString(cfstring); + return QString::fromCFString(cfstring); } return QString(); } @@ -114,7 +114,7 @@ static QString macDayName(int day, bool short_format) : kCFDateFormatterWeekdaySymbols)); if (values != 0) { CFStringRef cfstring = static_cast<CFStringRef>(CFArrayGetValueAtIndex(values, day % 7)); - return QCFString::toQString(cfstring); + return QString::fromCFString(cfstring); } return QString(); } @@ -293,7 +293,7 @@ QString getMacDateFormat(CFDateFormatterStyle style) QCFType<CFLocaleRef> l = CFLocaleCopyCurrent(); QCFType<CFDateFormatterRef> formatter = CFDateFormatterCreate(kCFAllocatorDefault, l, style, kCFDateFormatterNoStyle); - return macToQtFormat(QCFString::toQString(CFDateFormatterGetFormat(formatter))); + return macToQtFormat(QString::fromCFString(CFDateFormatterGetFormat(formatter))); } static QString getMacTimeFormat(CFDateFormatterStyle style) @@ -301,21 +301,21 @@ static QString getMacTimeFormat(CFDateFormatterStyle style) QCFType<CFLocaleRef> l = CFLocaleCopyCurrent(); QCFType<CFDateFormatterRef> formatter = CFDateFormatterCreate(kCFAllocatorDefault, l, kCFDateFormatterNoStyle, style); - return macToQtFormat(QCFString::toQString(CFDateFormatterGetFormat(formatter))); + return macToQtFormat(QString::fromCFString(CFDateFormatterGetFormat(formatter))); } static QString getCFLocaleValue(CFStringRef key) { QCFType<CFLocaleRef> locale = CFLocaleCopyCurrent(); CFTypeRef value = CFLocaleGetValue(locale, key); - return QCFString::toQString(CFStringRef(static_cast<CFTypeRef>(value))); + return QString::fromCFString(CFStringRef(static_cast<CFTypeRef>(value))); } static QLocale::MeasurementSystem macMeasurementSystem() { QCFType<CFLocaleRef> locale = CFLocaleCopyCurrent(); CFStringRef system = static_cast<CFStringRef>(CFLocaleGetValue(locale, kCFLocaleMeasurementSystem)); - if (QCFString::toQString(system) == QLatin1String("Metric")) { + if (QString::fromCFString(system) == QLatin1String("Metric")) { return QLocale::MetricSystem; } else { return QLocale::ImperialSystem; @@ -337,13 +337,13 @@ static QString macCurrencySymbol(QLocale::CurrencySymbolFormat format) QCFType<CFLocaleRef> locale = CFLocaleCopyCurrent(); switch (format) { case QLocale::CurrencyIsoCode: - return QCFString::toQString(static_cast<CFStringRef>(CFLocaleGetValue(locale, kCFLocaleCurrencyCode))); + return QString::fromCFString(static_cast<CFStringRef>(CFLocaleGetValue(locale, kCFLocaleCurrencyCode))); case QLocale::CurrencySymbol: - return QCFString::toQString(static_cast<CFStringRef>(CFLocaleGetValue(locale, kCFLocaleCurrencySymbol))); + return QString::fromCFString(static_cast<CFStringRef>(CFLocaleGetValue(locale, kCFLocaleCurrencySymbol))); case QLocale::CurrencyDisplayName: { CFStringRef code = static_cast<CFStringRef>(CFLocaleGetValue(locale, kCFLocaleCurrencyCode)); QCFType<CFStringRef> value = CFLocaleCopyDisplayNameForPropertyValue(locale, kCFLocaleCurrencyCode, code); - return QCFString::toQString(value); + return QString::fromCFString(value); } default: break; @@ -382,10 +382,10 @@ static QString macFormatCurrency(const QSystemLocale::CurrencyToStringArgument & CFNumberFormatterCreate(NULL, locale, kCFNumberFormatterCurrencyStyle); if (!arg.symbol.isEmpty()) { CFNumberFormatterSetProperty(currencyFormatter, kCFNumberFormatterCurrencySymbol, - QCFString::toCFStringRef(arg.symbol)); + arg.symbol.toCFString()); } QCFType<CFStringRef> result = CFNumberFormatterCreateStringWithNumber(NULL, currencyFormatter, value); - return QCFString::toQString(result); + return QString::fromCFString(result); } static QVariant macQuoteString(QSystemLocale::QueryType type, const QStringRef &str) @@ -394,12 +394,12 @@ static QVariant macQuoteString(QSystemLocale::QueryType type, const QStringRef & QCFType<CFLocaleRef> locale = CFLocaleCopyCurrent(); switch (type) { case QSystemLocale::StringToStandardQuotation: - begin = QCFString::toQString(static_cast<CFStringRef>(CFLocaleGetValue(locale, kCFLocaleQuotationBeginDelimiterKey))); - end = QCFString::toQString(static_cast<CFStringRef>(CFLocaleGetValue(locale, kCFLocaleQuotationEndDelimiterKey))); + begin = QString::fromCFString(static_cast<CFStringRef>(CFLocaleGetValue(locale, kCFLocaleQuotationBeginDelimiterKey))); + end = QString::fromCFString(static_cast<CFStringRef>(CFLocaleGetValue(locale, kCFLocaleQuotationEndDelimiterKey))); return QString(begin % str % end); case QSystemLocale::StringToAlternateQuotation: - begin = QCFString::toQString(static_cast<CFStringRef>(CFLocaleGetValue(locale, kCFLocaleAlternateQuotationBeginDelimiterKey))); - end = QCFString::toQString(static_cast<CFStringRef>(CFLocaleGetValue(locale, kCFLocaleAlternateQuotationEndDelimiterKey))); + begin = QString::fromCFString(static_cast<CFStringRef>(CFLocaleGetValue(locale, kCFLocaleAlternateQuotationBeginDelimiterKey))); + end = QString::fromCFString(static_cast<CFStringRef>(CFLocaleGetValue(locale, kCFLocaleAlternateQuotationEndDelimiterKey))); return QString(begin % str % end); default: break; @@ -468,7 +468,7 @@ QVariant QSystemLocale::query(QueryType type, QVariant in = QVariant()) const QCFType<CFDateFormatterRef> formatter = CFDateFormatterCreate(NULL, locale, kCFDateFormatterLongStyle, kCFDateFormatterLongStyle); QCFType<CFStringRef> value = static_cast<CFStringRef>(CFDateFormatterCopyProperty(formatter, (type == AMText ? kCFDateFormatterAMSymbol : kCFDateFormatterPMSymbol))); - return QCFString::toQString(value); + return QString::fromCFString(value); } case FirstDayOfWeek: return QVariant(macFirstDayOfWeek()); @@ -491,15 +491,15 @@ QVariant QSystemLocale::query(QueryType type, QVariant in = QVariant()) const const int cnt = CFArrayGetCount(languages.as<CFArrayRef>()); result.reserve(cnt); for (int i = 0; i < cnt; ++i) { - const QString lang = QCFString::toQString( + const QString lang = QString::fromCFString( static_cast<CFStringRef>(CFArrayGetValueAtIndex(languages.as<CFArrayRef>(), i))); result.append(lang); } } else if (typeId == CFStringGetTypeID()) { - result = QStringList(QCFString::toQString(languages.as<CFStringRef>())); + result = QStringList(QString::fromCFString(languages.as<CFStringRef>())); } else { qWarning("QLocale::uiLanguages(): CFPreferencesCopyValue returned unhandled type \"%s\"; please report to http://bugreports.qt.io", - qPrintable(QCFString::toQString(CFCopyTypeIDDescription(typeId)))); + qPrintable(QString::fromCFString(CFCopyTypeIDDescription(typeId)))); } return QVariant(result); } diff --git a/src/corelib/tools/qsimd_p.h b/src/corelib/tools/qsimd_p.h index 2fd4be00a5..3b6c85ca8a 100644 --- a/src/corelib/tools/qsimd_p.h +++ b/src/corelib/tools/qsimd_p.h @@ -471,6 +471,9 @@ static inline quint64 qCpuFeatures() #define ALIGNMENT_PROLOGUE_32BYTES(ptr, i, length) \ for (; i < static_cast<int>(qMin(static_cast<quintptr>(length), ((8 - ((reinterpret_cast<quintptr>(ptr) >> 2) & 0x7)) & 0x7))); ++i) +#define SIMD_EPILOGUE(i, length, max) \ + for (int _i = 0; _i < max && i < length; ++i, ++_i) + QT_END_NAMESPACE #endif // QSIMD_P_H diff --git a/src/corelib/tools/qtimezone.h b/src/corelib/tools/qtimezone.h index db99f07f44..083f87f39f 100644 --- a/src/corelib/tools/qtimezone.h +++ b/src/corelib/tools/qtimezone.h @@ -45,6 +45,8 @@ #include <QtCore/qlocale.h> #include <QtCore/qdatetime.h> +QT_REQUIRE_CONFIG(timezone); + QT_BEGIN_NAMESPACE class QTimeZonePrivate; diff --git a/src/corelib/tools/qtimezoneprivate_mac.mm b/src/corelib/tools/qtimezoneprivate_mac.mm index 77c04ac20c..5dfffeaf36 100644 --- a/src/corelib/tools/qtimezoneprivate_mac.mm +++ b/src/corelib/tools/qtimezoneprivate_mac.mm @@ -90,7 +90,7 @@ QTimeZonePrivate *QMacTimeZonePrivate::clone() void QMacTimeZonePrivate::init(const QByteArray &ianaId) { if (availableTimeZoneIds().contains(ianaId)) { - m_nstz = [[NSTimeZone timeZoneWithName:QCFString::toNSString(QString::fromUtf8(ianaId))] retain]; + m_nstz = [[NSTimeZone timeZoneWithName:QString::fromUtf8(ianaId).toNSString()] retain]; if (m_nstz) m_id = ianaId; } @@ -98,7 +98,7 @@ void QMacTimeZonePrivate::init(const QByteArray &ianaId) QString QMacTimeZonePrivate::comment() const { - return QCFString::toQString([m_nstz description]); + return QString::fromNSString([m_nstz description]); } QString QMacTimeZonePrivate::displayName(QTimeZone::TimeType timeType, @@ -140,9 +140,9 @@ QString QMacTimeZonePrivate::displayName(QTimeZone::TimeType timeType, break; } - NSString *macLocaleCode = QCFString::toNSString(locale.name()); + NSString *macLocaleCode = locale.name().toNSString(); NSLocale *macLocale = [[NSLocale alloc] initWithLocaleIdentifier:macLocaleCode]; - const QString result = QCFString::toQString([m_nstz localizedName:style locale:macLocale]); + const QString result = QString::fromNSString([m_nstz localizedName:style locale:macLocale]); [macLocale release]; return result; } @@ -150,7 +150,7 @@ QString QMacTimeZonePrivate::displayName(QTimeZone::TimeType timeType, QString QMacTimeZonePrivate::abbreviation(qint64 atMSecsSinceEpoch) const { const NSTimeInterval seconds = atMSecsSinceEpoch / 1000.0; - return QCFString::toQString([m_nstz abbreviationForDate:[NSDate dateWithTimeIntervalSince1970:seconds]]); + return QString::fromNSString([m_nstz abbreviationForDate:[NSDate dateWithTimeIntervalSince1970:seconds]]); } int QMacTimeZonePrivate::offsetFromUtc(qint64 atMSecsSinceEpoch) const @@ -191,7 +191,7 @@ QTimeZonePrivate::Data QMacTimeZonePrivate::data(qint64 forMSecsSinceEpoch) cons data.offsetFromUtc = [m_nstz secondsFromGMTForDate:date]; data.daylightTimeOffset = [m_nstz daylightSavingTimeOffsetForDate:date]; data.standardTimeOffset = data.offsetFromUtc - data.daylightTimeOffset; - data.abbreviation = QCFString::toQString([m_nstz abbreviationForDate:date]); + data.abbreviation = QString::fromNSString([m_nstz abbreviationForDate:date]); return data; } @@ -220,7 +220,7 @@ QTimeZonePrivate::Data QMacTimeZonePrivate::nextTransition(qint64 afterMSecsSinc tran.offsetFromUtc = [m_nstz secondsFromGMTForDate:nextDate]; tran.daylightTimeOffset = [m_nstz daylightSavingTimeOffsetForDate:nextDate]; tran.standardTimeOffset = tran.offsetFromUtc - tran.daylightTimeOffset; - tran.abbreviation = QCFString::toQString([m_nstz abbreviationForDate:nextDate]); + tran.abbreviation = QString::fromNSString([m_nstz abbreviationForDate:nextDate]); return tran; } @@ -253,18 +253,18 @@ QByteArray QMacTimeZonePrivate::systemTimeZoneId() const { // Reset the cached system tz then return the name [NSTimeZone resetSystemTimeZone]; - return QCFString::toQString([[NSTimeZone systemTimeZone] name]).toUtf8(); + return QString::fromNSString([[NSTimeZone systemTimeZone] name]).toUtf8(); } QList<QByteArray> QMacTimeZonePrivate::availableTimeZoneIds() const { NSEnumerator *enumerator = [[NSTimeZone knownTimeZoneNames] objectEnumerator]; - QByteArray tzid = QCFString::toQString([enumerator nextObject]).toUtf8(); + QByteArray tzid = QString::fromNSString([enumerator nextObject]).toUtf8(); QList<QByteArray> list; while (!tzid.isEmpty()) { list << tzid; - tzid = QCFString::toQString([enumerator nextObject]).toUtf8(); + tzid = QString::fromNSString([enumerator nextObject]).toUtf8(); } std::sort(list.begin(), list.end()); diff --git a/src/corelib/tools/qvector.cpp b/src/corelib/tools/qvector.cpp index ef1c9c17b0..0ea47b1a1a 100644 --- a/src/corelib/tools/qvector.cpp +++ b/src/corelib/tools/qvector.cpp @@ -77,7 +77,7 @@ application must interface with a C API. \note Iterators into a QLinkedList and references into - heap-allocating QLists remain valid long as the referenced items + heap-allocating QLists remain valid as long as the referenced items remain in the container. This is not true for iterators and references into a QVector and non-heap-allocating QLists. diff --git a/src/corelib/tools/tools.pri b/src/corelib/tools/tools.pri index e3d89651e4..47b0b2d4be 100644 --- a/src/corelib/tools/tools.pri +++ b/src/corelib/tools/tools.pri @@ -15,8 +15,6 @@ HEADERS += \ tools/qbytedata_p.h \ tools/qcache.h \ tools/qchar.h \ - tools/qcommandlineoption.h \ - tools/qcommandlineparser.h \ tools/qcollator.h \ tools/qcollator_p.h \ tools/qcontainerfwd.h \ @@ -67,9 +65,6 @@ HEADERS += \ tools/qstringmatcher.h \ tools/qtextboundaryfinder.h \ tools/qtimeline.h \ - tools/qtimezone.h \ - tools/qtimezoneprivate_p.h \ - tools/qtimezoneprivate_data_p.h \ tools/qtools_p.h \ tools/qunicodetables_p.h \ tools/qunicodetools_p.h \ @@ -85,8 +80,6 @@ SOURCES += \ tools/qbytearraylist.cpp \ tools/qbytearraymatcher.cpp \ tools/qcollator.cpp \ - tools/qcommandlineoption.cpp \ - tools/qcommandlineparser.cpp \ tools/qcryptographichash.cpp \ tools/qdatetime.cpp \ tools/qdatetimeparser.cpp \ @@ -116,8 +109,6 @@ SOURCES += \ tools/qstringlist.cpp \ tools/qtextboundaryfinder.cpp \ tools/qtimeline.cpp \ - tools/qtimezone.cpp \ - tools/qtimezoneprivate.cpp \ tools/qunicodetools.cpp \ tools/qvector.cpp \ tools/qvsnprintf.cpp \ @@ -128,18 +119,13 @@ msvc: NO_PCH_SOURCES += tools/qvector_msvc.cpp false: SOURCES += $$NO_PCH_SOURCES # Hack for QtCreator !nacl:mac: { - OBJECTIVE_SOURCES += tools/qlocale_mac.mm \ - tools/qtimezoneprivate_mac.mm \ -} -else:android { - SOURCES += tools/qlocale_unix.cpp tools/qtimezoneprivate_android.cpp + SOURCES += tools/qlocale_mac.mm } else:unix { - SOURCES += tools/qlocale_unix.cpp tools/qtimezoneprivate_tz.cpp + SOURCES += tools/qlocale_unix.cpp } else:win32 { - SOURCES += tools/qlocale_win.cpp \ - tools/qtimezoneprivate_win.cpp + SOURCES += tools/qlocale_win.cpp winphone: LIBS_PRIVATE += -lWindowsPhoneGlobalizationUtil winrt-*-msvc2013: LIBS += advapi32.lib } else:integrity { @@ -157,8 +143,7 @@ qtConfig(icu) { include($$PWD/../../3rdparty/icu_dependency.pri) SOURCES += tools/qlocale_icu.cpp \ - tools/qcollator_icu.cpp \ - tools/qtimezoneprivate_icu.cpp + tools/qcollator_icu.cpp DEFINES += QT_USE_ICU } else: win32 { SOURCES += tools/qcollator_win.cpp @@ -168,6 +153,26 @@ qtConfig(icu) { SOURCES += tools/qcollator_posix.cpp } +qtConfig(timezone) { + HEADERS += \ + tools/qtimezone.h \ + tools/qtimezoneprivate_p.h \ + tools/qtimezoneprivate_data_p.h + SOURCES += \ + tools/qtimezone.cpp \ + tools/qtimezoneprivate.cpp + !nacl:darwin: \ + SOURCES += tools/qtimezoneprivate_mac.mm + else: android: \ + SOURCES += tools/qtimezoneprivate_android.cpp + else: unix: \ + SOURCES += tools/qtimezoneprivate_tz.cpp + else: win32: \ + SOURCES += tools/qtimezoneprivate_win.cpp + qtConfig(icu): \ + SOURCES += tools/qtimezoneprivate_icu.cpp +} + qtConfig(regularexpression) { include($$PWD/../../3rdparty/pcre_dependency.pri) @@ -175,6 +180,15 @@ qtConfig(regularexpression) { SOURCES += tools/qregularexpression.cpp } +qtConfig(commandlineparser) { + HEADERS += \ + tools/qcommandlineoption.h \ + tools/qcommandlineparser.h + SOURCES += \ + tools/qcommandlineoption.cpp \ + tools/qcommandlineparser.cpp +} + INCLUDEPATH += ../3rdparty/harfbuzz/src HEADERS += ../3rdparty/harfbuzz/src/harfbuzz.h SOURCES += ../3rdparty/harfbuzz/src/harfbuzz-buffer.c \ |