diff --git a/configure.json b/configure.json index ae5f71291c3..16a2af5babf 100644 --- a/configure.json +++ b/configure.json @@ -1106,10 +1106,17 @@ "condition": "libs.zlib", "output": [ "privateFeature" ] }, + "thread": { + "label": "Thread support", + "purpose": "Provides QThread and related classes.", + "section": "Kernel", + "output": [ "publicFeature" ] + }, "future": { "label": "QFuture", "purpose": "Provides QFuture and related classes.", "section": "Kernel", + "condition": "features.thread", "output": [ "publicFeature" ] }, "concurrent": { @@ -1122,6 +1129,7 @@ "dbus": { "label": "Qt D-Bus", "autoDetect": "!config.uikit && !config.android && !config.winrt", + "condition": "features.thread", "output": [ "privateFeature", "feature" ] }, "dbus-linked": { @@ -1153,10 +1161,12 @@ }, "network": { "label": "Qt Network", + "condition": "features.thread", "output": [ "privateFeature" ] }, "sql": { "label": "Qt Sql", + "condition": "features.thread", "output": [ "privateFeature" ] }, "testlib": { diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp index b3db200ed1b..48983def79b 100644 --- a/src/corelib/animation/qabstractanimation.cpp +++ b/src/corelib/animation/qabstractanimation.cpp @@ -215,9 +215,7 @@ typedef QList::ConstIterator AnimationListConstIt; QUnifiedTimer drives animations indirectly, via QAbstractAnimationTimer. */ -#ifndef QT_NO_THREAD Q_GLOBAL_STATIC(QThreadStorage, unifiedTimer) -#endif QUnifiedTimer::QUnifiedTimer() : QObject(), defaultDriver(this), lastTick(0), timingInterval(DEFAULT_TIMER_INTERVAL), @@ -234,18 +232,12 @@ QUnifiedTimer::QUnifiedTimer() : QUnifiedTimer *QUnifiedTimer::instance(bool create) { QUnifiedTimer *inst; -#ifndef QT_NO_THREAD if (create && !unifiedTimer()->hasLocalData()) { inst = new QUnifiedTimer; unifiedTimer()->setLocalData(inst); } else { inst = unifiedTimer() ? unifiedTimer()->localData() : 0; } -#else - Q_UNUSED(create); - static QUnifiedTimer unifiedTimer; - inst = &unifiedTimer; -#endif return inst; } @@ -554,7 +546,7 @@ bool QUnifiedTimer::canUninstallAnimationDriver(QAnimationDriver *d) return d == driver && driver != &defaultDriver; } -#ifndef QT_NO_THREAD +#if QT_CONFIG(thread) Q_GLOBAL_STATIC(QThreadStorage, animationTimer) #endif @@ -569,7 +561,7 @@ QAnimationTimer::QAnimationTimer() : QAnimationTimer *QAnimationTimer::instance(bool create) { QAnimationTimer *inst; -#ifndef QT_NO_THREAD +#if QT_CONFIG(thread) if (create && !animationTimer()->hasLocalData()) { inst = new QAnimationTimer; animationTimer()->setLocalData(inst); diff --git a/src/corelib/global/qconfig-bootstrapped.h b/src/corelib/global/qconfig-bootstrapped.h index b8b064d43ba..a8dbb3edcd9 100644 --- a/src/corelib/global/qconfig-bootstrapped.h +++ b/src/corelib/global/qconfig-bootstrapped.h @@ -115,7 +115,7 @@ #define QT_NO_SYSTEMLOCALE #define QT_FEATURE_systemsemaphore -1 #define QT_FEATURE_temporaryfile 1 -#define QT_NO_THREAD +#define QT_FEATURE_thread -1 #define QT_FEATURE_timezone -1 #define QT_FEATURE_topleveldomain -1 #define QT_NO_TRANSLATION diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 37cc40f577f..a369bbe4903 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -53,10 +53,6 @@ #include -#ifndef QT_NO_QOBJECT -#include -#endif - #include #include #include diff --git a/src/corelib/global/qglobalstatic.h b/src/corelib/global/qglobalstatic.h index 7a6dea9b925..555bdf04c1c 100644 --- a/src/corelib/global/qglobalstatic.h +++ b/src/corelib/global/qglobalstatic.h @@ -55,7 +55,7 @@ enum GuardValues { }; } -#if defined(QT_NO_THREAD) || defined(Q_COMPILER_THREADSAFE_STATICS) +#if !QT_CONFIG(thread) || defined(Q_COMPILER_THREADSAFE_STATICS) // some compilers support thread-safe statics // The IA-64 C++ ABI requires this, so we know that all GCC versions since 3.4 // support it. C++11 also requires this behavior. diff --git a/src/corelib/global/qglobalstatic.qdoc b/src/corelib/global/qglobalstatic.qdoc index 303709bb1df..dbea04ecab2 100644 --- a/src/corelib/global/qglobalstatic.qdoc +++ b/src/corelib/global/qglobalstatic.qdoc @@ -264,7 +264,7 @@ [stmt.decl], but as of the time of this writing, only compilers based on the IA-64 C++ ABI implemented it properly. The implementation requiring thread-safe initialization is also used on the Qt bootstrapped tools, which - define QT_NO_THREAD. + disable the "thread" feature. The implementation requiring thread-safe initialization from the compiler is the simplest: it creates the \a Type object as a function-local static diff --git a/src/corelib/global/qrandom.cpp b/src/corelib/global/qrandom.cpp index 66deac2a297..a7d4aa303a9 100644 --- a/src/corelib/global/qrandom.cpp +++ b/src/corelib/global/qrandom.cpp @@ -1298,7 +1298,7 @@ struct QRandEngine }; } -#if defined(QT_NO_THREAD) || defined(Q_OS_WIN) +#if defined(Q_OS_WIN) // On Windows srand() and rand() already use Thread-Local-Storage // to store the seed between calls static inline QRandEngine *randTLS() diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index d0cd5449f04..835e6a6a441 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -853,7 +853,7 @@ QByteArray QFileSystemEngine::id(int id) //static QString QFileSystemEngine::resolveUserName(uint userId) { -#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD) +#if QT_CONFIG(thread) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD) int size_max = sysconf(_SC_GETPW_R_SIZE_MAX); if (size_max == -1) size_max = 1024; @@ -862,7 +862,7 @@ QString QFileSystemEngine::resolveUserName(uint userId) #if !defined(Q_OS_INTEGRITY) struct passwd *pw = 0; -#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD) && !defined(Q_OS_VXWORKS) +#if QT_CONFIG(thread) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD) && !defined(Q_OS_VXWORKS) struct passwd entry; getpwuid_r(userId, &entry, buf.data(), buf.size(), &pw); #else @@ -877,7 +877,7 @@ QString QFileSystemEngine::resolveUserName(uint userId) //static QString QFileSystemEngine::resolveGroupName(uint groupId) { -#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD) +#if QT_CONFIG(thread) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD) int size_max = sysconf(_SC_GETPW_R_SIZE_MAX); if (size_max == -1) size_max = 1024; @@ -886,7 +886,7 @@ QString QFileSystemEngine::resolveGroupName(uint groupId) #if !defined(Q_OS_INTEGRITY) struct group *gr = 0; -#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD) && !defined(Q_OS_VXWORKS) && (!defined(Q_OS_ANDROID) || defined(Q_OS_ANDROID) && (__ANDROID_API__ >= 24)) +#if QT_CONFIG(thread) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD) && !defined(Q_OS_VXWORKS) && (!defined(Q_OS_ANDROID) || defined(Q_OS_ANDROID) && (__ANDROID_API__ >= 24)) size_max = sysconf(_SC_GETGR_R_SIZE_MAX); if (size_max == -1) size_max = 1024; diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index 93cfd93d7e9..9d3bfbba31c 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -45,7 +45,6 @@ #include "qfile.h" #include "qdir.h" -#include "private/qmutexpool_p.h" #include "qvarlengtharray.h" #include "qdatetime.h" #include "qt_windows.h" diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp index 713af9bd408..7a2daa2a572 100644 --- a/src/corelib/io/qprocess_unix.cpp +++ b/src/corelib/io/qprocess_unix.cpp @@ -101,7 +101,6 @@ QT_END_NAMESPACE #include #include #include -#include #include #include #include diff --git a/src/corelib/kernel/qcore_mac.cpp b/src/corelib/kernel/qcore_mac.cpp index b5df0db232b..58380001a47 100644 --- a/src/corelib/kernel/qcore_mac.cpp +++ b/src/corelib/kernel/qcore_mac.cpp @@ -42,6 +42,7 @@ #include "qhash.h" #include "qpair.h" +#include "qmutex.h" #include "qvarlengtharray.h" QT_BEGIN_NAMESPACE diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index aea8fe6658c..04da52a9606 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -58,9 +58,11 @@ #include #ifndef QT_NO_QOBJECT #include -#include #include #include +#if QT_CONFIG(thread) +#include +#endif #endif #include #include @@ -268,9 +270,7 @@ typedef QList QStartUpFuncList; Q_GLOBAL_STATIC(QStartUpFuncList, preRList) typedef QList QVFuncList; Q_GLOBAL_STATIC(QVFuncList, postRList) -#ifndef QT_NO_QOBJECT static QBasicMutex globalRoutinesMutex; -#endif /*! \internal @@ -289,9 +289,7 @@ void qAddPreRoutine(QtStartUpFunction p) // Due to C++11 parallel dynamic initialization, this can be called // from multiple threads. -#ifndef QT_NO_THREAD QMutexLocker locker(&globalRoutinesMutex); -#endif list->prepend(p); // in case QCoreApplication is re-created, see qt_call_pre_routines } @@ -300,9 +298,7 @@ void qAddPostRoutine(QtCleanUpFunction p) QVFuncList *list = postRList(); if (!list) return; -#ifndef QT_NO_THREAD QMutexLocker locker(&globalRoutinesMutex); -#endif list->prepend(p); } @@ -311,9 +307,7 @@ void qRemovePostRoutine(QtCleanUpFunction p) QVFuncList *list = postRList(); if (!list) return; -#ifndef QT_NO_THREAD QMutexLocker locker(&globalRoutinesMutex); -#endif list->removeAll(p); } @@ -324,9 +318,7 @@ static void qt_call_pre_routines() QVFuncList list; { -#ifndef QT_NO_THREAD QMutexLocker locker(&globalRoutinesMutex); -#endif // Unlike qt_call_post_routines, we don't empty the list, because // Q_COREAPP_STARTUP_FUNCTION is a macro, so the user expects // the function to be executed every time QCoreApplication is created. @@ -345,9 +337,7 @@ void Q_CORE_EXPORT qt_call_post_routines() QVFuncList list; { // extract the current list and make the stored list empty -#ifndef QT_NO_THREAD QMutexLocker locker(&globalRoutinesMutex); -#endif qSwap(*postRList, list); } @@ -513,7 +503,7 @@ QCoreApplicationPrivate::~QCoreApplicationPrivate() void QCoreApplicationPrivate::cleanupThreadData() { if (threadData && !threadData_clean) { -#ifndef QT_NO_THREAD +#if QT_CONFIG(thread) void *data = &threadData->tls; QThreadStorageData::finish((void **)data); #endif @@ -888,7 +878,7 @@ QCoreApplication::~QCoreApplication() QCoreApplicationPrivate::is_app_running = false; #endif -#if !defined(QT_NO_THREAD) +#if QT_CONFIG(thread) // Synchronize and stop the global thread pool threads. QThreadPool *globalThreadPool = 0; QT_TRY { diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index 65d0bd2351c..6c17535f079 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -50,7 +50,9 @@ #include #include #include +#if QT_CONFIG(thread) #include +#endif #include "private/qobject_p.h" #include "private/qmetaobject_p.h" @@ -1540,14 +1542,14 @@ bool QMetaObject::invokeMethodImpl(QObject *object, QtPrivate::QSlotObjectBase * QCoreApplication::postEvent(object, new QMetaCallEvent(slot, 0, -1, 1, types, args)); } else if (type == Qt::BlockingQueuedConnection) { -#ifndef QT_NO_THREAD +#if QT_CONFIG(thread) if (currentThread == objectThread) qWarning("QMetaObject::invokeMethod: Dead lock detected"); QSemaphore semaphore; QCoreApplication::postEvent(object, new QMetaCallEvent(slot, 0, -1, 0, 0, argv, &semaphore)); semaphore.acquire(); -#endif // QT_NO_THREAD +#endif // QT_CONFIG(thread) } else { qWarning("QMetaObject::invokeMethod: Unknown connection type"); return false; @@ -2272,7 +2274,7 @@ bool QMetaMethod::invoke(QObject *object, : Qt::QueuedConnection; } -#ifdef QT_NO_THREAD +#if !QT_CONFIG(thread) if (connectionType == Qt::BlockingQueuedConnection) { connectionType = Qt::DirectConnection; } @@ -2348,7 +2350,7 @@ bool QMetaMethod::invoke(QObject *object, QCoreApplication::postEvent(object, new QMetaCallEvent(idx_offset, idx_relative, callFunction, 0, -1, nargs, types, args)); } else { // blocking queued connection -#ifndef QT_NO_THREAD +#if QT_CONFIG(thread) if (currentThread == objectThread) { qWarning("QMetaMethod::invoke: Dead lock detected in " "BlockingQueuedConnection: Receiver is %s(%p)", @@ -2359,7 +2361,7 @@ bool QMetaMethod::invoke(QObject *object, QCoreApplication::postEvent(object, new QMetaCallEvent(idx_offset, idx_relative, callFunction, 0, -1, 0, 0, param, &semaphore)); semaphore.acquire(); -#endif // QT_NO_THREAD +#endif // QT_CONFIG(thread) } return true; } diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 698ac256ff4..6254330d250 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -59,7 +59,9 @@ #include #include #include +#if QT_CONFIG(thread) #include +#endif #include #include @@ -488,7 +490,7 @@ QMetaCallEvent::~QMetaCallEvent() free(types_); free(args_); } -#ifndef QT_NO_THREAD +#if QT_CONFIG(thread) if (semaphore_) semaphore_->release(); #endif @@ -3727,7 +3729,7 @@ void QMetaObject::activate(QObject *sender, int signalOffset, int local_signal_i || (c->connectionType == Qt::QueuedConnection)) { queued_activate(sender, signal_index, c, argv ? argv : empty_argv, locker); continue; -#ifndef QT_NO_THREAD +#if QT_CONFIG(thread) } else if (c->connectionType == Qt::BlockingQueuedConnection) { if (receiverInSameThread) { qWarning("Qt: Dead lock detected while activating a BlockingQueuedConnection: " diff --git a/src/corelib/kernel/qsystemerror.cpp b/src/corelib/kernel/qsystemerror.cpp index fc825257ecb..53c3136857e 100644 --- a/src/corelib/kernel/qsystemerror.cpp +++ b/src/corelib/kernel/qsystemerror.cpp @@ -49,7 +49,7 @@ QT_BEGIN_NAMESPACE -#if !defined(Q_OS_WIN) && !defined(QT_NO_THREAD) && !defined(Q_OS_INTEGRITY) && !defined(Q_OS_QNX) && \ +#if !defined(Q_OS_WIN) && QT_CONFIG(thread) && !defined(Q_OS_INTEGRITY) && !defined(Q_OS_QNX) && \ defined(_POSIX_THREAD_SAFE_FUNCTIONS) && _POSIX_VERSION >= 200112L namespace { // There are two incompatible versions of strerror_r: @@ -130,7 +130,7 @@ static QString standardLibraryErrorString(int errorCode) s = QT_TRANSLATE_NOOP("QIODevice", "No space left on device"); break; default: { - #if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && _POSIX_VERSION >= 200112L && !defined(Q_OS_INTEGRITY) && !defined(Q_OS_QNX) + #if QT_CONFIG(thread) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && _POSIX_VERSION >= 200112L && !defined(Q_OS_INTEGRITY) && !defined(Q_OS_QNX) QByteArray buf(1024, Qt::Uninitialized); ret = fromstrerror_helper(strerror_r(errorCode, buf.data(), buf.size()), buf); #else diff --git a/src/corelib/thread/qmutex.cpp b/src/corelib/thread/qmutex.cpp index 63fb6f3efbd..3881ac017e5 100644 --- a/src/corelib/thread/qmutex.cpp +++ b/src/corelib/thread/qmutex.cpp @@ -42,8 +42,6 @@ #include "qplatformdefs.h" #include "qmutex.h" #include - -#ifndef QT_NO_THREAD #include "qatomic.h" #include "qelapsedtimer.h" #include "qthread.h" @@ -739,5 +737,3 @@ QT_END_NAMESPACE #else # include "qmutex_unix.cpp" #endif - -#endif // QT_NO_THREAD diff --git a/src/corelib/thread/qmutex.h b/src/corelib/thread/qmutex.h index 7cda53db5f7..837355a6027 100644 --- a/src/corelib/thread/qmutex.h +++ b/src/corelib/thread/qmutex.h @@ -54,7 +54,7 @@ class tst_QMutex; QT_BEGIN_NAMESPACE -#if !defined(QT_NO_THREAD) || defined(Q_CLANG_QDOC) +#if QT_CONFIG(thread) || defined(Q_CLANG_QDOC) #ifdef Q_OS_LINUX # define QT_MUTEX_LOCK_NOEXCEPT Q_DECL_NOTHROW @@ -250,7 +250,7 @@ private: quintptr val; }; -#else // QT_NO_THREAD && !Q_CLANG_QDOC +#else // !QT_CONFIG(thread) && !Q_CLANG_QDOC class Q_CORE_EXPORT QMutex { @@ -301,7 +301,7 @@ private: typedef QMutex QBasicMutex; -#endif // QT_NO_THREAD && !Q_CLANG_QDOC +#endif // !QT_CONFIG(thread) && !Q_CLANG_QDOC QT_END_NAMESPACE diff --git a/src/corelib/thread/qmutex_linux.cpp b/src/corelib/thread/qmutex_linux.cpp index d3d97ea1083..507e72cb76c 100644 --- a/src/corelib/thread/qmutex_linux.cpp +++ b/src/corelib/thread/qmutex_linux.cpp @@ -40,8 +40,6 @@ #include "qplatformdefs.h" #include "qmutex.h" - -#ifndef QT_NO_THREAD #include "qatomic.h" #include "qmutex_p.h" #include "qfutex_p.h" @@ -54,7 +52,6 @@ # define FUTEX_PRIVATE_FLAG 0 #endif - QT_BEGIN_NAMESPACE using namespace QtFutex; @@ -183,5 +180,3 @@ void QBasicMutex::unlockInternal() Q_DECL_NOTHROW } QT_END_NAMESPACE - -#endif // QT_NO_THREAD diff --git a/src/corelib/thread/qmutex_mac.cpp b/src/corelib/thread/qmutex_mac.cpp index 67498611c9d..9a8d9bc750a 100644 --- a/src/corelib/thread/qmutex_mac.cpp +++ b/src/corelib/thread/qmutex_mac.cpp @@ -39,9 +39,6 @@ #include "qplatformdefs.h" #include "qmutex.h" - -#if !defined(QT_NO_THREAD) - #include "qmutex_p.h" #include @@ -89,5 +86,3 @@ void QMutexPrivate::wakeUp() Q_DECL_NOTHROW QT_END_NAMESPACE - -#endif //QT_NO_THREAD diff --git a/src/corelib/thread/qmutex_unix.cpp b/src/corelib/thread/qmutex_unix.cpp index 91f02ba3ec9..3ee24a292c3 100644 --- a/src/corelib/thread/qmutex_unix.cpp +++ b/src/corelib/thread/qmutex_unix.cpp @@ -42,8 +42,6 @@ #include "qmutex.h" #include "qstring.h" #include "qelapsedtimer.h" - -#ifndef QT_NO_THREAD #include "qatomic.h" #include "qmutex_p.h" #include @@ -159,5 +157,3 @@ void QMutexPrivate::wakeUp() Q_DECL_NOTHROW #endif QT_END_NAMESPACE - -#endif // QT_NO_THREAD diff --git a/src/corelib/thread/qmutexpool.cpp b/src/corelib/thread/qmutexpool.cpp index 90b6989467c..3f9e8da9427 100644 --- a/src/corelib/thread/qmutexpool.cpp +++ b/src/corelib/thread/qmutexpool.cpp @@ -40,8 +40,6 @@ #include "qatomic.h" #include "qmutexpool_p.h" -#ifndef QT_NO_THREAD - QT_BEGIN_NAMESPACE Q_GLOBAL_STATIC_WITH_ARGS(QMutexPool, globalMutexPool, (QMutex::Recursive)) @@ -148,5 +146,3 @@ QMutex *QMutexPool::globalInstanceGet(const void *address) } QT_END_NAMESPACE - -#endif // QT_NO_THREAD diff --git a/src/corelib/thread/qmutexpool_p.h b/src/corelib/thread/qmutexpool_p.h index 58d853b0e39..89d006ac29f 100644 --- a/src/corelib/thread/qmutexpool_p.h +++ b/src/corelib/thread/qmutexpool_p.h @@ -56,7 +56,7 @@ #include "QtCore/qmutex.h" #include "QtCore/qvarlengtharray.h" -#ifndef QT_NO_THREAD +QT_REQUIRE_CONFIG(thread); QT_BEGIN_NAMESPACE @@ -85,6 +85,4 @@ private: QT_END_NAMESPACE -#endif // QT_NO_THREAD - #endif // QMUTEXPOOL_P_H diff --git a/src/corelib/thread/qreadwritelock.cpp b/src/corelib/thread/qreadwritelock.cpp index 42befc4b80e..21835ff5921 100644 --- a/src/corelib/thread/qreadwritelock.cpp +++ b/src/corelib/thread/qreadwritelock.cpp @@ -42,7 +42,6 @@ #include "qplatformdefs.h" #include "qreadwritelock.h" -#ifndef QT_NO_THREAD #include "qmutex.h" #include "qthread.h" #include "qwaitcondition.h" @@ -781,5 +780,3 @@ void QReadWriteLockPrivate::release() */ QT_END_NAMESPACE - -#endif // QT_NO_THREAD diff --git a/src/corelib/thread/qreadwritelock.h b/src/corelib/thread/qreadwritelock.h index ecdb98f2f54..65fa76fd6df 100644 --- a/src/corelib/thread/qreadwritelock.h +++ b/src/corelib/thread/qreadwritelock.h @@ -45,7 +45,7 @@ QT_BEGIN_NAMESPACE -#ifndef QT_NO_THREAD +#if QT_CONFIG(thread) class QReadWriteLockPrivate; @@ -174,7 +174,7 @@ inline QWriteLocker::QWriteLocker(QReadWriteLock *areadWriteLock) #pragma warning( pop ) #endif -#else // QT_NO_THREAD +#else // QT_CONFIG(thread) class Q_CORE_EXPORT QReadWriteLock { @@ -225,7 +225,7 @@ private: Q_DISABLE_COPY(QWriteLocker) }; -#endif // QT_NO_THREAD +#endif // QT_CONFIG(thread) QT_END_NAMESPACE diff --git a/src/corelib/thread/qreadwritelock_p.h b/src/corelib/thread/qreadwritelock_p.h index a01d010043c..31da2401c0d 100644 --- a/src/corelib/thread/qreadwritelock_p.h +++ b/src/corelib/thread/qreadwritelock_p.h @@ -56,7 +56,7 @@ #include #include -#ifndef QT_NO_THREAD +QT_REQUIRE_CONFIG(thread); QT_BEGIN_NAMESPACE @@ -99,6 +99,4 @@ public: QT_END_NAMESPACE -#endif // QT_NO_THREAD - #endif // QREADWRITELOCK_P_H diff --git a/src/corelib/thread/qsemaphore.cpp b/src/corelib/thread/qsemaphore.cpp index 82d439a728e..bb578ff6174 100644 --- a/src/corelib/thread/qsemaphore.cpp +++ b/src/corelib/thread/qsemaphore.cpp @@ -39,8 +39,6 @@ ****************************************************************************/ #include "qsemaphore.h" - -#ifndef QT_NO_THREAD #include "qmutex.h" #include "qfutex_p.h" #include "qwaitcondition.h" @@ -646,5 +644,3 @@ bool QSemaphore::tryAcquire(int n, int timeout) QT_END_NAMESPACE - -#endif // QT_NO_THREAD diff --git a/src/corelib/thread/qsemaphore.h b/src/corelib/thread/qsemaphore.h index 2639085e99e..b830ff1bfd5 100644 --- a/src/corelib/thread/qsemaphore.h +++ b/src/corelib/thread/qsemaphore.h @@ -42,11 +42,10 @@ #include +QT_REQUIRE_CONFIG(thread); + QT_BEGIN_NAMESPACE - -#ifndef QT_NO_THREAD - class QSemaphorePrivate; class Q_CORE_EXPORT QSemaphore @@ -113,8 +112,6 @@ private: int m_n; }; -#endif // QT_NO_THREAD - QT_END_NAMESPACE #endif // QSEMAPHORE_H diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp index f784bf5cb6d..a4101764bca 100644 --- a/src/corelib/thread/qthread.cpp +++ b/src/corelib/thread/qthread.cpp @@ -103,7 +103,7 @@ QThreadData::~QThreadData() void QThreadData::ref() { -#ifndef QT_NO_THREAD +#if QT_CONFIG(thread) (void) _ref.ref(); Q_ASSERT(_ref.load() != 0); #endif @@ -111,7 +111,7 @@ void QThreadData::ref() void QThreadData::deref() { -#ifndef QT_NO_THREAD +#if QT_CONFIG(thread) if (!_ref.deref()) delete this; #endif @@ -134,7 +134,7 @@ QAdoptedThread::QAdoptedThread(QThreadData *data) { // thread should be running and not finished for the lifetime // of the application (even if QCoreApplication goes away) -#ifndef QT_NO_THREAD +#if QT_CONFIG(thread) d_func()->running = true; d_func()->finished = false; init(); @@ -148,7 +148,7 @@ QAdoptedThread::~QAdoptedThread() // fprintf(stderr, "~QAdoptedThread = %p\n", this); } -#ifndef QT_NO_THREAD +#if QT_CONFIG(thread) void QAdoptedThread::run() { // this function should never be called @@ -756,7 +756,7 @@ int QThread::loopLevel() const return d->data->eventLoops.size(); } -#else // QT_NO_THREAD +#else // QT_CONFIG(thread) QThread::QThread(QObject *parent) : QObject(*(new QThreadPrivate), parent) @@ -813,7 +813,7 @@ QThreadPrivate::~QThreadPrivate() delete data; } -#endif // QT_NO_THREAD +#endif // QT_CONFIG(thread) /*! \since 5.0 @@ -850,7 +850,7 @@ void QThread::setEventDispatcher(QAbstractEventDispatcher *eventDispatcher) } } -#ifndef QT_NO_THREAD +#if QT_CONFIG(thread) /*! \reimp @@ -1015,7 +1015,7 @@ QDaemonThread::~QDaemonThread() { } -#endif // QT_NO_THREAD +#endif // QT_CONFIG(thread) QT_END_NAMESPACE diff --git a/src/corelib/thread/qthread.h b/src/corelib/thread/qthread.h index 83c3329cc04..d0ffd9f9093 100644 --- a/src/corelib/thread/qthread.h +++ b/src/corelib/thread/qthread.h @@ -66,7 +66,7 @@ class QThreadData; class QThreadPrivate; class QAbstractEventDispatcher; -#ifndef QT_NO_THREAD +#if QT_CONFIG(thread) class Q_CORE_EXPORT QThread : public QObject { Q_OBJECT @@ -239,7 +239,7 @@ QThread *QThread::create(Function &&f) #endif // QT_CONFIG(cxx11_future) -#else // QT_NO_THREAD +#else // QT_CONFIG(thread) class Q_CORE_EXPORT QThread : public QObject { @@ -267,7 +267,7 @@ private: Q_DECLARE_PRIVATE(QThread) }; -#endif // QT_NO_THREAD +#endif // QT_CONFIG(thread) QT_END_NAMESPACE diff --git a/src/corelib/thread/qthread_p.h b/src/corelib/thread/qthread_p.h index 93f245ff6e7..22a0669032b 100644 --- a/src/corelib/thread/qthread_p.h +++ b/src/corelib/thread/qthread_p.h @@ -57,7 +57,9 @@ #include "QtCore/qthread.h" #include "QtCore/qmutex.h" #include "QtCore/qstack.h" +#if QT_CONFIG(thread) #include "QtCore/qwaitcondition.h" +#endif #include "QtCore/qmap.h" #include "QtCore/qcoreapplication.h" #include "private/qobject_p.h" @@ -141,7 +143,7 @@ private: using QVector::insert; }; -#ifndef QT_NO_THREAD +#if QT_CONFIG(thread) class Q_CORE_EXPORT QDaemonThread : public QThread { @@ -210,7 +212,7 @@ public: } }; -#else // QT_NO_THREAD +#else // QT_CONFIG(thread) class QThreadPrivate : public QObjectPrivate { @@ -231,7 +233,7 @@ public: Q_DECLARE_PUBLIC(QThread) }; -#endif // QT_NO_THREAD +#endif // QT_CONFIG(thread) class QThreadData { @@ -327,7 +329,7 @@ public: void init(); private: -#ifndef QT_NO_THREAD +#if QT_CONFIG(thread) void run() override; #endif }; diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp index 0b3c7ddf103..329caa02bab 100644 --- a/src/corelib/thread/qthread_unix.cpp +++ b/src/corelib/thread/qthread_unix.cpp @@ -103,7 +103,7 @@ QT_BEGIN_NAMESPACE -#ifndef QT_NO_THREAD +#if QT_CONFIG(thread) Q_STATIC_ASSERT(sizeof(pthread_t) <= sizeof(Qt::HANDLE)); @@ -270,7 +270,7 @@ extern "C" { typedef void*(*QtThreadCallback)(void*); } -#endif // QT_NO_THREAD +#endif // QT_CONFIG(thread) QAbstractEventDispatcher *QThreadPrivate::createEventDispatcher(QThreadData *data) { @@ -295,7 +295,7 @@ QAbstractEventDispatcher *QThreadPrivate::createEventDispatcher(QThreadData *dat #endif } -#ifndef QT_NO_THREAD +#if QT_CONFIG(thread) #if (defined(Q_OS_LINUX) || defined(Q_OS_MAC) || defined(Q_OS_QNX)) static void setCurrentThreadName(const char *name) @@ -513,7 +513,7 @@ void QThread::yieldCurrentThread() sched_yield(); } -#endif // QT_NO_THREAD +#endif // QT_CONFIG(thread) static timespec makeTimespec(time_t secs, long nsecs) { @@ -538,7 +538,7 @@ void QThread::usleep(unsigned long usecs) qt_nanosleep(makeTimespec(usecs / 1000 / 1000, usecs % (1000*1000) * 1000)); } -#ifndef QT_NO_THREAD +#if QT_CONFIG(thread) #ifdef QT_HAS_THREAD_PRIORITY_SCHEDULING #if defined(Q_OS_QNX) @@ -839,7 +839,7 @@ void QThreadPrivate::setPriority(QThread::Priority threadPriority) #endif } -#endif // QT_NO_THREAD +#endif // QT_CONFIG(thread) QT_END_NAMESPACE diff --git a/src/corelib/thread/qthread_win.cpp b/src/corelib/thread/qthread_win.cpp index 83bcb7d7516..57ae671897f 100644 --- a/src/corelib/thread/qthread_win.cpp +++ b/src/corelib/thread/qthread_win.cpp @@ -63,7 +63,7 @@ QT_BEGIN_NAMESPACE -#ifndef QT_NO_THREAD +#if QT_CONFIG(thread) #ifdef Q_OS_WINRT inline DWORD qWinRTTlsAlloc() { @@ -330,7 +330,7 @@ void qt_set_thread_name(HANDLE threadId, LPCSTR threadName) ** QThreadPrivate *************************************************************************/ -#endif // QT_NO_THREAD +#endif // QT_CONFIG(thread) QAbstractEventDispatcher *QThreadPrivate::createEventDispatcher(QThreadData *data) { @@ -342,7 +342,7 @@ QAbstractEventDispatcher *QThreadPrivate::createEventDispatcher(QThreadData *dat #endif } -#ifndef QT_NO_THREAD +#if QT_CONFIG(thread) unsigned int __stdcall QT_ENSURE_STACK_ALIGNED_FOR_SSE QThreadPrivate::start(void *arg) Q_DECL_NOEXCEPT { @@ -444,7 +444,7 @@ void QThread::yieldCurrentThread() #endif } -#endif // QT_NO_THREAD +#endif // QT_CONFIG(thread) void QThread::sleep(unsigned long secs) { @@ -461,7 +461,7 @@ void QThread::usleep(unsigned long usecs) ::Sleep((usecs / 1000) + 1); } -#ifndef QT_NO_THREAD +#if QT_CONFIG(thread) void QThread::start(Priority priority) { @@ -699,6 +699,6 @@ void QThreadPrivate::setPriority(QThread::Priority threadPriority) } } -#endif // QT_NO_THREAD +#endif // QT_CONFIG(thread) QT_END_NAMESPACE diff --git a/src/corelib/thread/qthreadpool.cpp b/src/corelib/thread/qthreadpool.cpp index 157cbeaf4d4..ea2c611082f 100644 --- a/src/corelib/thread/qthreadpool.cpp +++ b/src/corelib/thread/qthreadpool.cpp @@ -43,8 +43,6 @@ #include -#ifndef QT_NO_THREAD - QT_BEGIN_NAMESPACE Q_GLOBAL_STATIC(QThreadPool, theInstance) @@ -730,5 +728,3 @@ void QThreadPool::cancel(QRunnable *runnable) QT_END_NAMESPACE #include "moc_qthreadpool.cpp" - -#endif diff --git a/src/corelib/thread/qthreadpool.h b/src/corelib/thread/qthreadpool.h index 606e1927684..cd27b7c08a2 100644 --- a/src/corelib/thread/qthreadpool.h +++ b/src/corelib/thread/qthreadpool.h @@ -45,7 +45,7 @@ #include #include -#ifndef QT_NO_THREAD +QT_REQUIRE_CONFIG(thread); QT_BEGIN_NAMESPACE @@ -97,6 +97,4 @@ public: QT_END_NAMESPACE -#endif // QT_NO_THREAD - #endif diff --git a/src/corelib/thread/qthreadpool_p.h b/src/corelib/thread/qthreadpool_p.h index d03ba9d77f2..0e6a00d243f 100644 --- a/src/corelib/thread/qthreadpool_p.h +++ b/src/corelib/thread/qthreadpool_p.h @@ -59,7 +59,7 @@ #include "QtCore/qqueue.h" #include "private/qobject_p.h" -#ifndef QT_NO_THREAD +QT_REQUIRE_CONFIG(thread); QT_BEGIN_NAMESPACE @@ -184,5 +184,4 @@ public: QT_END_NAMESPACE -#endif // QT_NO_THREAD #endif diff --git a/src/corelib/thread/qthreadstorage.cpp b/src/corelib/thread/qthreadstorage.cpp index c0b523a4313..8b82118a5cb 100644 --- a/src/corelib/thread/qthreadstorage.cpp +++ b/src/corelib/thread/qthreadstorage.cpp @@ -39,7 +39,6 @@ #include "qthreadstorage.h" -#ifndef QT_NO_THREAD #include "qthread.h" #include "qthread_p.h" #include "qmutex.h" @@ -323,6 +322,4 @@ void QThreadStorageData::finish(void **p) \sa localData(), hasLocalData() */ -#endif // QT_NO_THREAD - QT_END_NAMESPACE diff --git a/src/corelib/thread/qthreadstorage.h b/src/corelib/thread/qthreadstorage.h index 9a91883de8d..d556e33c577 100644 --- a/src/corelib/thread/qthreadstorage.h +++ b/src/corelib/thread/qthreadstorage.h @@ -42,7 +42,7 @@ #include -#ifndef QT_NO_THREAD +#if QT_CONFIG(thread) QT_BEGIN_NAMESPACE @@ -152,7 +152,7 @@ public: QT_END_NAMESPACE -#else // !QT_NO_THREAD +#else // !QT_CONFIG(thread) #include @@ -227,6 +227,6 @@ public: } }; -#endif // QT_NO_THREAD +#endif // QT_CONFIG(thread) #endif // QTHREADSTORAGE_H diff --git a/src/corelib/thread/qwaitcondition.h b/src/corelib/thread/qwaitcondition.h index e42efbdfca4..11520e4cfe6 100644 --- a/src/corelib/thread/qwaitcondition.h +++ b/src/corelib/thread/qwaitcondition.h @@ -46,8 +46,7 @@ QT_BEGIN_NAMESPACE - -#ifndef QT_NO_THREAD +#if QT_CONFIG(thread) class QDeadlineTimer; class QWaitConditionPrivate; @@ -98,7 +97,7 @@ public: void wakeAll() {} }; -#endif // QT_NO_THREAD +#endif // QT_CONFIG(thread) QT_END_NAMESPACE diff --git a/src/corelib/thread/qwaitcondition_unix.cpp b/src/corelib/thread/qwaitcondition_unix.cpp index 9706be15044..c93328b4bc3 100644 --- a/src/corelib/thread/qwaitcondition_unix.cpp +++ b/src/corelib/thread/qwaitcondition_unix.cpp @@ -56,8 +56,6 @@ #include #include -#ifndef QT_NO_THREAD - QT_BEGIN_NAMESPACE #ifdef Q_OS_ANDROID @@ -264,5 +262,3 @@ bool QWaitCondition::wait(QReadWriteLock *readWriteLock, QDeadlineTimer deadline } QT_END_NAMESPACE - -#endif // QT_NO_THREAD diff --git a/src/corelib/thread/qwaitcondition_win.cpp b/src/corelib/thread/qwaitcondition_win.cpp index 61e4c2bcb17..534456a935c 100644 --- a/src/corelib/thread/qwaitcondition_win.cpp +++ b/src/corelib/thread/qwaitcondition_win.cpp @@ -45,8 +45,6 @@ #include "qlist.h" #include "qalgorithms.h" -#ifndef QT_NO_THREAD - #define Q_MUTEX_T void* #include #include @@ -247,4 +245,3 @@ void QWaitCondition::wakeAll() } QT_END_NAMESPACE -#endif // QT_NO_THREAD diff --git a/src/corelib/thread/thread.pri b/src/corelib/thread/thread.pri index dae72564b42..22f0de05231 100644 --- a/src/corelib/thread/thread.pri +++ b/src/corelib/thread/thread.pri @@ -1,38 +1,66 @@ # Qt core thread module -# public headers -HEADERS += thread/qmutex.h \ - thread/qrunnable.h \ - thread/qreadwritelock.h \ - thread/qsemaphore.h \ - thread/qthread.h \ - thread/qthreadpool.h \ - thread/qthreadstorage.h \ - thread/qwaitcondition.h \ - thread/qatomic.h \ - thread/qatomic_bootstrap.h \ - thread/qatomic_cxx11.h \ - thread/qbasicatomic.h \ - thread/qgenericatomic.h +HEADERS += \ + thread/qmutex.h \ + thread/qreadwritelock.h \ + thread/qrunnable.h \ + thread/qthread.h \ + thread/qthreadstorage.h \ + thread/qwaitcondition.h -# private headers -HEADERS += thread/qmutex_p.h \ - thread/qmutexpool_p.h \ - thread/qfutex_p.h \ - thread/qorderedmutexlocker_p.h \ - thread/qreadwritelock_p.h \ - thread/qthread_p.h \ - thread/qthreadpool_p.h +SOURCES += \ + thread/qrunnable.cpp \ + thread/qthread.cpp -SOURCES += thread/qatomic.cpp \ - thread/qmutex.cpp \ - thread/qreadwritelock.cpp \ - thread/qrunnable.cpp \ - thread/qmutexpool.cpp \ - thread/qsemaphore.cpp \ - thread/qthread.cpp \ - thread/qthreadpool.cpp \ - thread/qthreadstorage.cpp +win32 { + HEADERS += thread/qatomic_msvc.h + + SOURCES += thread/qthread_win.cpp +} else { + SOURCES += thread/qthread_unix.cpp +} + +qtConfig(thread) { + HEADERS += \ + thread/qatomic.h \ + thread/qatomic_bootstrap.h \ + thread/qatomic_cxx11.h \ + thread/qbasicatomic.h \ + thread/qfutex_p.h \ + thread/qgenericatomic.h \ + thread/qmutexpool_p.h \ + thread/qmutex_p.h \ + thread/qorderedmutexlocker_p.h \ + thread/qreadwritelock_p.h \ + thread/qsemaphore.h \ + thread/qthreadpool.h \ + thread/qthreadpool_p.h \ + thread/qthread_p.h + + SOURCES += \ + thread/qatomic.cpp \ + thread/qmutex.cpp \ + thread/qmutexpool.cpp \ + thread/qreadwritelock.cpp \ + thread/qsemaphore.cpp \ + thread/qthreadpool.cpp \ + thread/qthreadstorage.cpp + + win32 { + SOURCES += \ + thread/qmutex_win.cpp \ + thread/qwaitcondition_win.cpp + } else { + darwin { + SOURCES += thread/qmutex_mac.cpp + } else: linux { + SOURCES += thread/qmutex_linux.cpp + } else { + SOURCES += thread/qmutex_unix.cpp + } + SOURCES += thread/qwaitcondition_unix.cpp + } +} qtConfig(future) { HEADERS += \ @@ -52,24 +80,4 @@ qtConfig(future) { thread/qresultstore.cpp } -win32 { - HEADERS += thread/qatomic_msvc.h - - SOURCES += \ - thread/qmutex_win.cpp \ - thread/qthread_win.cpp \ - thread/qwaitcondition_win.cpp -} else { - darwin { - SOURCES += thread/qmutex_mac.cpp - } else: linux { - SOURCES += thread/qmutex_linux.cpp - } else { - SOURCES += thread/qmutex_unix.cpp - } - SOURCES += \ - thread/qthread_unix.cpp \ - thread/qwaitcondition_unix.cpp -} - qtConfig(std-atomic64): QMAKE_USE += libatomic diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index 288c7963d95..58755c94bbd 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -2339,7 +2339,7 @@ static bool qt_localtime(qint64 msecsSinceEpoch, QDate *localDate, QTime *localT // localtime_r() does not have this requirement, so make an explicit call. // The explicit call should also request the timezone info be re-parsed. qt_tzset(); -#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) +#if QT_CONFIG(thread) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) // Use the reentrant version of localtime() where available // as is thread-safe and doesn't use a shared static data area tm *res = 0; diff --git a/src/dbus/qdbus_symbols.cpp b/src/dbus/qdbus_symbols.cpp index 5e06c337f2a..f22696639d1 100644 --- a/src/dbus/qdbus_symbols.cpp +++ b/src/dbus/qdbus_symbols.cpp @@ -79,10 +79,8 @@ bool qdbus_loadLibDBus() #endif static bool triedToLoadLibrary = false; -#ifndef QT_NO_THREAD static QBasicMutex mutex; QMutexLocker locker(&mutex); -#endif QLibrary *&lib = qdbus_libdbus; if (triedToLoadLibrary) diff --git a/src/gui/configure.json b/src/gui/configure.json index 506caf6794a..8e6569c069c 100644 --- a/src/gui/configure.json +++ b/src/gui/configure.json @@ -979,7 +979,7 @@ }, "evdev": { "label": "evdev", - "condition": "tests.evdev", + "condition": "features.thread && tests.evdev", "output": [ "privateFeature" ] }, "freetype": { @@ -1170,7 +1170,7 @@ }, "egl_x11": { "label": "EGL on X11", - "condition": "features.egl && tests.egl-x11", + "condition": "features.thread && features.egl && tests.egl-x11", "output": [ "privateFeature" ] }, "eglfs": { @@ -1300,7 +1300,7 @@ "section": "Platform plugins", "autoDetect": "!config.darwin", "enable": "input.xcb == 'system' || input.xcb == 'qt' || input.xcb == 'yes'", - "condition": "libs.xcb", + "condition": "features.thread && libs.xcb", "output": [ "privateFeature" ] }, "system-xcb": { diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index f7462b65c83..580a09427c1 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -2703,18 +2703,6 @@ static const int slow_timeout = 300000; // 5m const uint QFontCache::min_cost = 4*1024; // 4mb -#ifdef QT_NO_THREAD -Q_GLOBAL_STATIC(QFontCache, theFontCache) - -QFontCache *QFontCache::instance() -{ - return theFontCache(); -} - -void QFontCache::cleanup() -{ -} -#else Q_GLOBAL_STATIC(QThreadStorage, theFontCache) QFontCache *QFontCache::instance() @@ -2736,7 +2724,6 @@ void QFontCache::cleanup() if (cache && cache->hasLocalData()) cache->setLocalData(0); } -#endif // QT_NO_THREAD QBasicAtomicInt font_cache_id = Q_BASIC_ATOMIC_INITIALIZER(1); diff --git a/src/network/configure.json b/src/network/configure.json index 0215ad73c52..32fcfb499f3 100644 --- a/src/network/configure.json +++ b/src/network/configure.json @@ -263,6 +263,7 @@ "label": "HTTP", "purpose": "Provides support for the Hypertext Transfer Protocol in QNetworkAccessManager.", "section": "Networking", + "condition": "features.thread", "output": [ "publicFeature", "feature" ] }, "udpsocket": { @@ -301,7 +302,7 @@ "label": "Bearer management", "purpose": "Provides bearer management for the network stack.", "section": "Networking", - "condition": "features.library && features.networkinterface && features.properties", + "condition": "features.thread && features.library && features.networkinterface && features.properties", "output": [ "publicFeature", "feature" ] }, "localserver": { diff --git a/src/network/ssl/qsslsocket_openssl_symbols.cpp b/src/network/ssl/qsslsocket_openssl_symbols.cpp index 8812912c18e..63cb276d54f 100644 --- a/src/network/ssl/qsslsocket_openssl_symbols.cpp +++ b/src/network/ssl/qsslsocket_openssl_symbols.cpp @@ -903,12 +903,10 @@ bool q_resolveOpenSslSymbols() { static bool symbolsResolved = false; static bool triedToResolveSymbols = false; -#ifndef QT_NO_THREAD #if QT_CONFIG(opensslv11) QMutexLocker locker(QMutexPool::globalInstanceGet((void *)&q_OPENSSL_init_ssl)); #else QMutexLocker locker(QMutexPool::globalInstanceGet((void *)&q_SSL_library_init)); -#endif #endif if (symbolsResolved) return true; diff --git a/src/platformsupport/eventdispatchers/qunixeventdispatcher.cpp b/src/platformsupport/eventdispatchers/qunixeventdispatcher.cpp index 7438ab65c1e..44258538ec7 100644 --- a/src/platformsupport/eventdispatchers/qunixeventdispatcher.cpp +++ b/src/platformsupport/eventdispatchers/qunixeventdispatcher.cpp @@ -43,14 +43,9 @@ #include "private/qguiapplication_p.h" #include -#include -#include -#include #include -#include - QT_BEGIN_NAMESPACE QT_USE_NAMESPACE diff --git a/src/platformsupport/fontdatabases/freetype/qfontengine_ft.cpp b/src/platformsupport/fontdatabases/freetype/qfontengine_ft.cpp index dabe2bc09ed..7b4f6aa1074 100644 --- a/src/platformsupport/fontdatabases/freetype/qfontengine_ft.cpp +++ b/src/platformsupport/fontdatabases/freetype/qfontengine_ft.cpp @@ -139,14 +139,6 @@ QtFreetypeData::~QtFreetypeData() library = 0; } -#ifdef QT_NO_THREAD -Q_GLOBAL_STATIC(QtFreetypeData, theFreetypeData) - -QtFreetypeData *qt_getFreetypeData() -{ - return theFreetypeData(); -} -#else Q_GLOBAL_STATIC(QThreadStorage, theFreetypeData) QtFreetypeData *qt_getFreetypeData() @@ -169,7 +161,6 @@ QtFreetypeData *qt_getFreetypeData() } return freetypeData; } -#endif FT_Library qt_getFreetype() { diff --git a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp index 8df8da1a38f..953e2bf6be6 100644 --- a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp +++ b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp @@ -1231,7 +1231,6 @@ void QWindowsFontDatabase::populateFontDatabase() typedef QSharedPointer QWindowsFontEngineDataPtr; -#ifndef QT_NO_THREAD typedef QThreadStorage FontEngineThreadLocalData; Q_GLOBAL_STATIC(FontEngineThreadLocalData, fontEngineThreadLocalData) @@ -1243,17 +1242,6 @@ QSharedPointer sharedFontData() data->setLocalData(QSharedPointer::create()); return data->localData(); } -#else // !QT_NO_THREAD -Q_GLOBAL_STATIC(QWindowsFontEngineDataPtr, fontEngineData) - -QWindowsFontEngineDataPtr sharedFontData() -{ - QWindowsFontEngineDataPtr *data = fontEngineData(); - if (data->isNull()) - *data = QWindowsFontEngineDataPtr::create(); - return *data; -} -#endif // QT_NO_THREAD QWindowsFontDatabase::QWindowsFontDatabase() { diff --git a/src/plugins/platforms/windows/qwindowsthreadpoolrunner.h b/src/plugins/platforms/windows/qwindowsthreadpoolrunner.h index 99705927af9..731e4b54320 100644 --- a/src/plugins/platforms/windows/qwindowsthreadpoolrunner.h +++ b/src/plugins/platforms/windows/qwindowsthreadpoolrunner.h @@ -61,7 +61,7 @@ class QWindowsThreadPoolRunner { Q_DISABLE_COPY(QWindowsThreadPoolRunner) -#ifndef QT_NO_THREAD +#if QT_CONFIG(thread) template // nested class implementing QRunnable to execute a function. class Runnable : public QRunnable { @@ -104,7 +104,7 @@ public: private: QMutex m_mutex; QWaitCondition m_condition; -#else // !QT_NO_THREAD +#else // QT_CONFIG(thread) public: QWindowsThreadPoolRunner() {} @@ -114,7 +114,7 @@ public: f(); return true; } -#endif // QT_NO_THREAD +#endif // QT_CONFIG(thread) }; QT_END_NAMESPACE diff --git a/src/plugins/sqldrivers/mysql/qsql_mysql.cpp b/src/plugins/sqldrivers/mysql/qsql_mysql.cpp index a1636302b74..e2455f87fb4 100644 --- a/src/plugins/sqldrivers/mysql/qsql_mysql.cpp +++ b/src/plugins/sqldrivers/mysql/qsql_mysql.cpp @@ -1454,7 +1454,7 @@ bool QMYSQLDriver::open(const QString& db, d->preparedQuerysEnabled = false; #endif -#ifndef QT_NO_THREAD +#if QT_CONFIG(thread) mysql_thread_init(); #endif @@ -1468,7 +1468,7 @@ void QMYSQLDriver::close() { Q_D(QMYSQLDriver); if (isOpen()) { -#ifndef QT_NO_THREAD +#if QT_CONFIG(thread) mysql_thread_end(); #endif mysql_close(d->mysql); diff --git a/src/printsupport/dialogs/qprintpreviewdialog.cpp b/src/printsupport/dialogs/qprintpreviewdialog.cpp index a4f721fbc8f..418bc47a598 100644 --- a/src/printsupport/dialogs/qprintpreviewdialog.cpp +++ b/src/printsupport/dialogs/qprintpreviewdialog.cpp @@ -573,8 +573,11 @@ void QPrintPreviewDialogPrivate::_q_print() if (printer->outputFormat() != QPrinter::NativeFormat) { QString title = QCoreApplication::translate("QPrintPreviewDialog", "Export to PDF"); QString suffix = QLatin1String(".pdf"); - QString fileName = QFileDialog::getSaveFileName(q, title, printer->outputFileName(), + QString fileName; +#if QT_CONFIG(filedialog) + fileName = QFileDialog::getSaveFileName(q, title, printer->outputFileName(), QLatin1Char('*') + suffix); +#endif if (!fileName.isEmpty()) { if (QFileInfo(fileName).suffix().isEmpty()) fileName.append(suffix); diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index d9fbfcffa84..32facaf12b7 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -346,7 +346,9 @@ namespace QTest static int keyDelay = -1; static int mouseDelay = -1; static int eventDelay = -1; +#if QT_CONFIG(thread) static int timeout = -1; +#endif static bool noCrashHandler = false; /*! \internal @@ -397,7 +399,7 @@ int Q_TESTLIB_EXPORT defaultKeyDelay() } return keyDelay; } - +#if QT_CONFIG(thread) static int defaultTimeout() { if (timeout == -1) { @@ -409,6 +411,7 @@ static int defaultTimeout() } return timeout; } +#endif Q_TESTLIB_EXPORT bool printAvailableFunctions = false; Q_TESTLIB_EXPORT QStringList testFunctions; @@ -975,6 +978,8 @@ void TestMethods::invokeTestOnData(int index) const } } +#if QT_CONFIG(thread) + class WatchDog : public QThread { public: @@ -1026,6 +1031,17 @@ private: QWaitCondition waitCondition; }; +#else // !QT_CONFIG(thread) + +class WatchDog : public QObject +{ +public: + void beginTest() {}; + void testFinished() {}; +}; + +#endif + /*! \internal diff --git a/src/widgets/configure.json b/src/widgets/configure.json index b3a5227d269..0015c9160a6 100644 --- a/src/widgets/configure.json +++ b/src/widgets/configure.json @@ -81,7 +81,7 @@ "label": "QFileSystemModel", "purpose": "Provides a data model for the local filesystem.", "section": "File I/O", - "condition": "features.itemmodel", + "condition": "features.itemmodel && features.thread", "output": [ "publicFeature", "feature" ] }, "itemviews": { diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 0a4efc980cb..23d8d32b0d4 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -1138,7 +1138,7 @@ void QWidgetPrivate::init(QWidget *parentWidget, Qt::WindowFlags f) q->data = &data; -#ifndef QT_NO_THREAD +#if QT_CONFIG(thread) if (!parent) { Q_ASSERT_X(q->thread() == qApp->thread(), "QWidget", "Widgets must be created in the GUI thread."); diff --git a/src/widgets/util/qcompleter.cpp b/src/widgets/util/qcompleter.cpp index 96dde64cccf..c50d0dc9e00 100644 --- a/src/widgets/util/qcompleter.cpp +++ b/src/widgets/util/qcompleter.cpp @@ -144,6 +144,7 @@ #include "qcompleter_p.h" #include "QtWidgets/qscrollbar.h" +#include "QtCore/qdir.h" #include "QtCore/qstringlistmodel.h" #if QT_CONFIG(dirmodel) #include "QtWidgets/qdirmodel.h" diff --git a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp index 5e9dbdd226a..a53501b9dd6 100644 --- a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp +++ b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp @@ -415,7 +415,7 @@ void tst_QCoreApplication::removePostedEvents() expected.clear(); } -#ifndef QT_NO_THREAD +#if QT_CONFIG(thread) class DeliverInDefinedOrderThread : public QThread { Q_OBJECT @@ -532,7 +532,7 @@ void tst_QCoreApplication::deliverInDefinedOrder() QObject::connect(&obj, SIGNAL(done()), &app, SLOT(quit())); app.exec(); } -#endif // QT_NO_QTHREAD +#endif // QT_CONFIG(thread) void tst_QCoreApplication::applicationPid() { diff --git a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.h b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.h index b6c20a915fe..105cca51742 100644 --- a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.h +++ b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.h @@ -43,7 +43,7 @@ private slots: void argc(); void postEvent(); void removePostedEvents(); -#ifndef QT_NO_THREAD +#if QT_CONFIG(thread) void deliverInDefinedOrder(); #endif void applicationPid(); diff --git a/tests/auto/corelib/thread/qthreadonce/qthreadonce.cpp b/tests/auto/corelib/thread/qthreadonce/qthreadonce.cpp index 91797502187..d27884197a0 100644 --- a/tests/auto/corelib/thread/qthreadonce/qthreadonce.cpp +++ b/tests/auto/corelib/thread/qthreadonce/qthreadonce.cpp @@ -30,7 +30,6 @@ #include "qplatformdefs.h" #include "qthreadonce.h" -#ifndef QT_NO_THREAD #include "qmutex.h" Q_GLOBAL_STATIC_WITH_ARGS(QMutex, onceInitializationMutex, (QMutex::Recursive)) @@ -104,5 +103,3 @@ void QOnceControl::done() { extra &= ~MustRunCode; } - -#endif // QT_NO_THREAD diff --git a/tests/auto/corelib/thread/qthreadonce/qthreadonce.h b/tests/auto/corelib/thread/qthreadonce/qthreadonce.h index 71e830ca162..e5918b8fa5c 100644 --- a/tests/auto/corelib/thread/qthreadonce/qthreadonce.h +++ b/tests/auto/corelib/thread/qthreadonce/qthreadonce.h @@ -34,8 +34,6 @@ #include -#ifndef QT_NO_THREAD - class QOnceControl { public: @@ -91,6 +89,4 @@ public: inline operator T*() { return value(); } }; -#endif // QT_NO_THREAD - #endif diff --git a/tests/auto/corelib/thread/thread.pro b/tests/auto/corelib/thread/thread.pro index d3c669859bd..dc60e5a7f5a 100644 --- a/tests/auto/corelib/thread/thread.pro +++ b/tests/auto/corelib/thread/thread.pro @@ -1,22 +1,25 @@ TEMPLATE=subdirs -SUBDIRS=\ - qatomicint \ - qatomicinteger \ - qatomicpointer \ - qresultstore \ - qfuture \ - qfuturesynchronizer \ - qmutex \ - qmutexlocker \ - qreadlocker \ - qreadwritelock \ - qsemaphore \ - qthread \ - qthreadonce \ - qthreadpool \ - qthreadstorage \ - qwaitcondition \ - qwritelocker + +qtHaveFeature(thread) { + SUBDIRS=\ + qatomicint \ + qatomicinteger \ + qatomicpointer \ + qresultstore \ + qfuture \ + qfuturesynchronizer \ + qmutex \ + qmutexlocker \ + qreadlocker \ + qreadwritelock \ + qsemaphore \ + qthread \ + qthreadonce \ + qthreadpool \ + qthreadstorage \ + qwaitcondition \ + qwritelocker +} qtHaveModule(concurrent) { SUBDIRS += \