summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2017-02-16 21:46:20 +0100
committerLiang Qi <liang.qi@qt.io>2017-02-16 21:51:11 +0100
commitc577f6edafef7c40a5f78092ec4fcd78bb820b2c (patch)
tree9ca3819e5cca9b7e61f305a874b682e5a2085e83 /src
parent99ce1d3d97c0423c3ee63ccf58deed964db0770e (diff)
parentde225ccdf95efb57866d62bc80872c1a2ab99703 (diff)
Merge remote-tracking branch 'origin/5.8' into 5.9
Conflicts: src/corelib/plugin/qlibrary_unix.cpp src/plugins/platforms/xcb/qxcbconnection.cpp tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp Change-Id: I632c400d909f8c204f55743aadc7886af2f15dfb
Diffstat (limited to 'src')
-rw-r--r--src/android/jar/src/org/qtproject/qt5/android/QtNative.java21
-rw-r--r--src/corelib/configure.json4
-rw-r--r--src/corelib/doc/snippets/events/events.cpp16
-rw-r--r--src/corelib/global/qnamespace.qdoc2
-rw-r--r--src/corelib/kernel/qjnihelpers.cpp49
-rw-r--r--src/corelib/kernel/qmetatype.cpp39
-rw-r--r--src/corelib/kernel/qobject.cpp2
-rw-r--r--src/corelib/plugin/qlibrary_unix.cpp30
-rw-r--r--src/corelib/thread/qmutex_linux.cpp2
-rw-r--r--src/corelib/thread/qreadwritelock_p.h2
-rw-r--r--src/corelib/thread/qthread.cpp2
-rw-r--r--src/corelib/thread/qthread_p.h2
-rw-r--r--src/corelib/thread/qthread_unix.cpp24
-rw-r--r--src/corelib/thread/qthread_win.cpp4
-rw-r--r--src/gui/doc/snippets/code/src_gui_text_qsyntaxhighlighter.cpp43
-rw-r--r--src/gui/text/qcssparser_p.h4
-rw-r--r--src/gui/text/qsyntaxhighlighter.cpp39
-rw-r--r--src/network/bearer/qnetworksession.cpp8
-rw-r--r--src/plugins/platforms/windows/qwindowsglcontext.h3
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.cpp3
-rw-r--r--src/testlib/qtestsystem.h6
-rw-r--r--src/tools/uic/cpp/cppwriteinitialization.cpp1
-rw-r--r--src/widgets/dialogs/qfiledialog.cpp2
23 files changed, 132 insertions, 176 deletions
diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtNative.java b/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
index a4341a5a48..b6dbd82597 100644
--- a/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
+++ b/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
@@ -243,13 +243,24 @@ public class QtNative
}
}
- private static void runPendingCppRunnablesOnUiThread()
+ private static void runPendingCppRunnablesOnAndroidThread()
{
synchronized (m_mainActivityMutex) {
- if (!m_activityPaused && m_activity != null)
- m_activity.runOnUiThread(runPendingCppRunnablesRunnable);
- else
- runAction(runPendingCppRunnablesRunnable);
+ if (m_activity != null) {
+ if (!m_activityPaused)
+ m_activity.runOnUiThread(runPendingCppRunnablesRunnable);
+ else
+ runAction(runPendingCppRunnablesRunnable);
+ } else {
+ final Looper mainLooper = Looper.getMainLooper();
+ final Thread looperThread = mainLooper.getThread();
+ if (looperThread.equals(Thread.currentThread())) {
+ runPendingCppRunnablesRunnable.run();
+ } else {
+ final Handler handler = new Handler(mainLooper);
+ handler.post(runPendingCppRunnablesRunnable);
+ }
+ }
}
}
diff --git a/src/corelib/configure.json b/src/corelib/configure.json
index 60248e9cd2..58b902c7ca 100644
--- a/src/corelib/configure.json
+++ b/src/corelib/configure.json
@@ -211,8 +211,7 @@
},
"dlopen": {
"label": "dlopen()",
- "condition": "tests.dlopen || libs.libdl",
- "output": [ { "type": "define", "negative": true, "name": "QT_NO_DYNAMIC_LIBRARY" } ]
+ "condition": "tests.dlopen || libs.libdl"
},
"libdl": {
"label": "dlopen() in libdl",
@@ -463,6 +462,7 @@
"label": "QLibrary",
"purpose": "Provides a wrapper for dynamically loaded libraries.",
"section": "File I/O",
+ "condition": "config.win32 || config.hpux || (!config.nacl && features.dlopen)",
"output": [ "publicFeature", "feature" ]
},
"settings": {
diff --git a/src/corelib/doc/snippets/events/events.cpp b/src/corelib/doc/snippets/events/events.cpp
index b029296bc2..9606b0c2ee 100644
--- a/src/corelib/doc/snippets/events/events.cpp
+++ b/src/corelib/doc/snippets/events/events.cpp
@@ -87,15 +87,15 @@ public:
bool MyWidget::event(QEvent *event)
{
if (event->type() == QEvent::KeyPress) {
- QKeyEvent *ke = static_cast<QKeyEvent *>(event);
- if (ke->key() == Qt::Key_Tab) {
- // special tab handling here
- return true;
- }
+ QKeyEvent *ke = static_cast<QKeyEvent *>(event);
+ if (ke->key() == Qt::Key_Tab) {
+ // special tab handling here
+ return true;
+ }
} else if (event->type() == MyCustomEventType) {
- MyCustomEvent *myEvent = static_cast<MyCustomEvent *>(event);
- // custom event handling here
- return true;
+ MyCustomEvent *myEvent = static_cast<MyCustomEvent *>(event);
+ // custom event handling here
+ return true;
}
return QWidget::event(event);
diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc
index af485a1832..8da06f71f7 100644
--- a/src/corelib/global/qnamespace.qdoc
+++ b/src/corelib/global/qnamespace.qdoc
@@ -2105,7 +2105,7 @@
On \macos, tool windows correspond to the
\l{http://developer.apple.com/documentation/Carbon/Conceptual/HandlingWindowsControls/hitb-wind_cont_concept/chapter_2_section_2.html}{Floating}
class of windows. This means that the window lives on a
- level above normal windows; it impossible to put a normal
+ level above normal windows making it impossible to put a normal
window on top of it. By default, tool windows will disappear
when the application is inactive. This can be controlled by
the Qt::WA_MacAlwaysShowToolWindow attribute.
diff --git a/src/corelib/kernel/qjnihelpers.cpp b/src/corelib/kernel/qjnihelpers.cpp
index 091280400e..93bc477e7d 100644
--- a/src/corelib/kernel/qjnihelpers.cpp
+++ b/src/corelib/kernel/qjnihelpers.cpp
@@ -73,7 +73,7 @@ static jclass g_jNativeClass = Q_NULLPTR;
static jmethodID g_runPendingCppRunnablesMethodID = Q_NULLPTR;
static jmethodID g_hideSplashScreenMethodID = Q_NULLPTR;
Q_GLOBAL_STATIC(std::deque<QtAndroidPrivate::Runnable>, g_pendingRunnables);
-Q_GLOBAL_STATIC(QMutex, g_pendingRunnablesMutex);
+static QBasicMutex g_pendingRunnablesMutex;
class PermissionsResultClass : public QObject
{
@@ -88,21 +88,24 @@ private:
typedef QHash<int, QSharedPointer<PermissionsResultClass>> PendingPermissionRequestsHash;
Q_GLOBAL_STATIC(PendingPermissionRequestsHash, g_pendingPermissionRequests);
-Q_GLOBAL_STATIC(QMutex, g_pendingPermissionRequestsMutex);
-Q_GLOBAL_STATIC(QAtomicInt, g_requestPermissionsRequestCode);
+static QBasicMutex g_pendingPermissionRequestsMutex;
+static int nextRequestCode()
+{
+ static QBasicAtomicInt counter = Q_BASIC_ATOMIC_INITIALIZER(0);
+ return counter.fetchAndAddRelaxed(1);
+}
// function called from Java from Android UI thread
static void runPendingCppRunnables(JNIEnv */*env*/, jobject /*obj*/)
{
for (;;) { // run all posted runnables
- g_pendingRunnablesMutex->lock();
+ QMutexLocker locker(&g_pendingRunnablesMutex);
if (g_pendingRunnables->empty()) {
- g_pendingRunnablesMutex->unlock();
break;
}
QtAndroidPrivate::Runnable runnable(std::move(g_pendingRunnables->front()));
g_pendingRunnables->pop_front();
- g_pendingRunnablesMutex->unlock();
+ locker.unlock();
runnable(); // run it outside the sync block!
}
}
@@ -122,16 +125,17 @@ Q_GLOBAL_STATIC(GenericMotionEventListeners, g_genericMotionEventListeners)
static void sendRequestPermissionsResult(JNIEnv *env, jobject /*obj*/, jint requestCode,
jobjectArray permissions, jintArray grantResults)
{
- g_pendingPermissionRequestsMutex->lock();
+ QMutexLocker locker(&g_pendingPermissionRequestsMutex);
auto it = g_pendingPermissionRequests->find(requestCode);
if (it == g_pendingPermissionRequests->end()) {
- g_pendingPermissionRequestsMutex->unlock();
// show an error or something ?
return;
}
- g_pendingPermissionRequestsMutex->unlock();
+ auto request = std::move(*it);
+ g_pendingPermissionRequests->erase(it);
+ locker.unlock();
- Qt::ConnectionType connection = QThread::currentThread() == it.value()->thread() ? Qt::DirectConnection : Qt::BlockingQueuedConnection;
+ Qt::ConnectionType connection = QThread::currentThread() == request->thread() ? Qt::DirectConnection : Qt::BlockingQueuedConnection;
QtAndroidPrivate::PermissionsHash hash;
const int size = env->GetArrayLength(permissions);
std::unique_ptr<jint[]> results(new jint[size]);
@@ -143,10 +147,7 @@ static void sendRequestPermissionsResult(JNIEnv *env, jobject /*obj*/, jint requ
QtAndroidPrivate::PermissionsResult::Denied;
hash[permission] = value;
}
- QMetaObject::invokeMethod(it.value().data(), "sendResult", connection, Q_ARG(QtAndroidPrivate::PermissionsHash, hash));
- g_pendingPermissionRequestsMutex->lock();
- g_pendingPermissionRequests->erase(it);
- g_pendingPermissionRequestsMutex->unlock();
+ QMetaObject::invokeMethod(request.data(), "sendResult", connection, Q_ARG(QtAndroidPrivate::PermissionsHash, hash));
}
static jboolean dispatchGenericMotionEvent(JNIEnv *, jclass, jobject event)
@@ -403,7 +404,7 @@ jint QtAndroidPrivate::initJNI(JavaVM *vm, JNIEnv *env)
return JNI_ERR;
g_runPendingCppRunnablesMethodID = env->GetStaticMethodID(jQtNative,
- "runPendingCppRunnablesOnUiThread",
+ "runPendingCppRunnablesOnAndroidThread",
"()V");
g_hideSplashScreenMethodID = env->GetStaticMethodID(jQtNative, "hideSplashScreen", "()V");
g_jNativeClass = static_cast<jclass>(env->NewGlobalRef(jQtNative));
@@ -459,10 +460,10 @@ void QtAndroidPrivate::runOnUiThread(QRunnable *runnable, JNIEnv *env)
void QtAndroidPrivate::runOnAndroidThread(const QtAndroidPrivate::Runnable &runnable, JNIEnv *env)
{
- g_pendingRunnablesMutex->lock();
+ QMutexLocker locker(&g_pendingRunnablesMutex);
const bool triggerRun = g_pendingRunnables->empty();
g_pendingRunnables->push_back(runnable);
- g_pendingRunnablesMutex->unlock();
+ locker.unlock();
if (triggerRun)
env->CallStaticVoidMethod(g_jNativeClass, g_runPendingCppRunnablesMethodID);
}
@@ -487,18 +488,16 @@ void QtAndroidPrivate::requestPermissions(JNIEnv *env, const QStringList &permis
return;
}
// Check API 23+ permissions
- const int requestCode = (*g_requestPermissionsRequestCode)++;
+ const int requestCode = nextRequestCode();
if (!directCall) {
- g_pendingPermissionRequestsMutex->lock();
+ QMutexLocker locker(&g_pendingPermissionRequestsMutex);
(*g_pendingPermissionRequests)[requestCode] = QSharedPointer<PermissionsResultClass>::create(callbackFunc);
- g_pendingPermissionRequestsMutex->unlock();
}
runOnAndroidThread([permissions, callbackFunc, requestCode, directCall] {
if (directCall) {
- g_pendingPermissionRequestsMutex->lock();
+ QMutexLocker locker(&g_pendingPermissionRequestsMutex);
(*g_pendingPermissionRequests)[requestCode] = QSharedPointer<PermissionsResultClass>::create(callbackFunc);
- g_pendingPermissionRequestsMutex->unlock();
}
QJNIEnvironmentPrivate env;
@@ -519,8 +518,10 @@ QHash<QString, QtAndroidPrivate::PermissionsResult> QtAndroidPrivate::requestPer
*res = result;
sem->release();
}, true);
- sem->tryAcquire(1, timeoutMs);
- return *res;
+ if (sem->tryAcquire(1, timeoutMs))
+ return std::move(*res);
+ else // mustn't touch *res
+ return QHash<QString, QtAndroidPrivate::PermissionsResult>();
}
QtAndroidPrivate::PermissionsResult QtAndroidPrivate::checkPermission(const QString &permission)
diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp
index 5623b085b8..1764c8116e 100644
--- a/src/corelib/kernel/qmetatype.cpp
+++ b/src/corelib/kernel/qmetatype.cpp
@@ -834,38 +834,27 @@ void QMetaType::registerStreamOperators(int idx, SaveOperator saveOp,
const char *QMetaType::typeName(int typeId)
{
const uint type = typeId;
- // In theory it can be filled during compilation time, but for some reason template code
- // that is able to do it causes GCC 4.6 to generate additional 3K of executable code. Probably
- // it is not worth of it.
- static const char *namesCache[QMetaType::HighestInternalId + 1];
-
- const char *result;
- if (type <= QMetaType::HighestInternalId && ((result = namesCache[type])))
- return result;
-
#define QT_METATYPE_TYPEID_TYPENAME_CONVERTER(MetaTypeName, TypeId, RealName) \
- case QMetaType::MetaTypeName: result = #RealName; break;
+ case QMetaType::MetaTypeName: return #RealName; break;
switch (QMetaType::Type(type)) {
QT_FOR_EACH_STATIC_TYPE(QT_METATYPE_TYPEID_TYPENAME_CONVERTER)
-
- default: {
- if (Q_UNLIKELY(type < QMetaType::User)) {
- return 0; // It can happen when someone cast int to QVariant::Type, we should not crash...
- } else {
- const QVector<QCustomTypeInfo> * const ct = customTypes();
- QReadLocker locker(customTypesLock());
- return ct && uint(ct->count()) > type - QMetaType::User && !ct->at(type - QMetaType::User).typeName.isEmpty()
- ? ct->at(type - QMetaType::User).typeName.constData()
- : 0;
- }
+ case QMetaType::UnknownType:
+ case QMetaType::User:
+ break;
}
+
+ if (Q_UNLIKELY(type < QMetaType::User)) {
+ return nullptr; // It can happen when someone cast int to QVariant::Type, we should not crash...
}
-#undef QT_METATYPE_TYPEID_TYPENAME_CONVERTER
- Q_ASSERT(type <= QMetaType::HighestInternalId);
- namesCache[type] = result;
- return result;
+ const QVector<QCustomTypeInfo> * const ct = customTypes();
+ QReadLocker locker(customTypesLock());
+ return ct && uint(ct->count()) > type - QMetaType::User && !ct->at(type - QMetaType::User).typeName.isEmpty()
+ ? ct->at(type - QMetaType::User).typeName.constData()
+ : nullptr;
+
+#undef QT_METATYPE_TYPEID_TYPENAME_CONVERTER
}
/*
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index 8088b18ef4..8e906b278d 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -3708,7 +3708,7 @@ void QMetaObject::activate(QObject *sender, int signalOffset, int local_signal_i
continue;
QObject * const receiver = c->receiver;
- const bool receiverInSameThread = currentThreadId == receiver->d_func()->threadData->threadId;
+ const bool receiverInSameThread = currentThreadId == receiver->d_func()->threadData->threadId.load();
// determine if this connection should be sent immediately or
// put into the event queue
diff --git a/src/corelib/plugin/qlibrary_unix.cpp b/src/corelib/plugin/qlibrary_unix.cpp
index bb7874071e..3553763bcd 100644
--- a/src/corelib/plugin/qlibrary_unix.cpp
+++ b/src/corelib/plugin/qlibrary_unix.cpp
@@ -50,13 +50,9 @@
# include <private/qcore_mac_p.h>
#endif
-#if (defined(Q_OS_VXWORKS) && !defined(VXWORKS_RTP)) || defined (Q_OS_NACL)
-#define QT_NO_DYNAMIC_LIBRARY
-#endif
-
QT_BEGIN_NAMESPACE
-#if !defined(QT_HPUX_LD) && !defined(QT_NO_DYNAMIC_LIBRARY)
+#if !defined(QT_HPUX_LD)
QT_BEGIN_INCLUDE_NAMESPACE
#include <dlfcn.h>
QT_END_INCLUDE_NAMESPACE
@@ -64,9 +60,7 @@ QT_END_INCLUDE_NAMESPACE
static QString qdlerror()
{
-#if defined(QT_NO_DYNAMIC_LIBRARY)
- const char *err = "This platform does not support dynamic libraries.";
-#elif !defined(QT_HPUX_LD)
+#if !defined(QT_HPUX_LD)
const char *err = dlerror();
#else
const char *err = strerror(errno);
@@ -131,7 +125,6 @@ QStringList QLibraryPrivate::prefixes_sys()
bool QLibraryPrivate::load_sys()
{
QString attempt;
-#if !defined(QT_NO_DYNAMIC_LIBRARY)
QFileSystemEntry fsEntry(fileName);
QString path = fsEntry.path();
@@ -250,7 +243,6 @@ bool QLibraryPrivate::load_sys()
}
}
#endif
-#endif // QT_NO_DYNAMIC_LIBRARY
if (!pHnd) {
errorString = QLibrary::tr("Cannot load library %1: %2").arg(fileName, qdlerror());
}
@@ -263,29 +255,27 @@ bool QLibraryPrivate::load_sys()
bool QLibraryPrivate::unload_sys()
{
-#if !defined(QT_NO_DYNAMIC_LIBRARY)
-# if defined(QT_HPUX_LD)
+#if defined(QT_HPUX_LD)
if (shl_unload((shl_t)pHnd)) {
-# else
+#else
if (dlclose(pHnd)) {
-# endif
-# if defined (Q_OS_QNX) // Workaround until fixed in QNX; fixes crash in
+#endif
+#if defined (Q_OS_QNX) // Workaround until fixed in QNX; fixes crash in
char *error = dlerror(); // QtDeclarative auto test "qqmlenginecleanup" for instance
if (!qstrcmp(error, "Shared objects still referenced")) // On QNX that's only "informative"
return true;
errorString = QLibrary::tr("Cannot unload library %1: %2").arg(fileName,
QLatin1String(error));
-# else
+#else
errorString = QLibrary::tr("Cannot unload library %1: %2").arg(fileName, qdlerror());
-# endif
+#endif
return false;
}
-#endif
errorString.clear();
return true;
}
-#if defined(Q_OS_LINUX) && !defined(QT_NO_DYNAMIC_LIBRARY)
+#if defined(Q_OS_LINUX)
Q_CORE_EXPORT QFunctionPointer qt_linux_find_symbol_sys(const char *symbol)
{
return QFunctionPointer(dlsym(RTLD_DEFAULT, symbol));
@@ -305,8 +295,6 @@ QFunctionPointer QLibraryPrivate::resolve_sys(const char* symbol)
QFunctionPointer address = 0;
if (shl_findsym((shl_t*)&pHnd, symbol, TYPE_UNDEFINED, &address) < 0)
address = 0;
-#elif defined (QT_NO_DYNAMIC_LIBRARY)
- QFunctionPointer address = 0;
#else
QFunctionPointer address = QFunctionPointer(dlsym(pHnd, symbol));
#endif
diff --git a/src/corelib/thread/qmutex_linux.cpp b/src/corelib/thread/qmutex_linux.cpp
index 17072f44d4..5f6e74ac6f 100644
--- a/src/corelib/thread/qmutex_linux.cpp
+++ b/src/corelib/thread/qmutex_linux.cpp
@@ -107,8 +107,6 @@ QT_BEGIN_NAMESPACE
* waiting in the past. We then set the mutex to 0x0 and perform a FUTEX_WAKE.
*/
-static QBasicAtomicInt futexFlagSupport = Q_BASIC_ATOMIC_INITIALIZER(-1);
-
static inline int _q_futex(void *addr, int op, int val, const struct timespec *timeout) Q_DECL_NOTHROW
{
volatile int *int_addr = reinterpret_cast<volatile int *>(addr);
diff --git a/src/corelib/thread/qreadwritelock_p.h b/src/corelib/thread/qreadwritelock_p.h
index bb58dfab56..04dd45a2e1 100644
--- a/src/corelib/thread/qreadwritelock_p.h
+++ b/src/corelib/thread/qreadwritelock_p.h
@@ -74,7 +74,7 @@ public:
int writerCount;
int waitingReaders;
int waitingWriters;
- bool recursive;
+ const bool recursive;
//Called with the mutex locked
bool lockForWrite(int timeout);
diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp
index c8777cac82..0828400733 100644
--- a/src/corelib/thread/qthread.cpp
+++ b/src/corelib/thread/qthread.cpp
@@ -56,7 +56,7 @@ QT_BEGIN_NAMESPACE
*/
QThreadData::QThreadData(int initialRefCount)
- : _ref(initialRefCount), loopLevel(0), scopeLevel(0), thread(0), threadId(0),
+ : _ref(initialRefCount), loopLevel(0), scopeLevel(0),
eventDispatcher(0),
quitNow(false), canWait(true), isAdopted(false), requiresCoreApplication(true)
{
diff --git a/src/corelib/thread/qthread_p.h b/src/corelib/thread/qthread_p.h
index 37eca9c612..885b4c0c1e 100644
--- a/src/corelib/thread/qthread_p.h
+++ b/src/corelib/thread/qthread_p.h
@@ -284,7 +284,7 @@ public:
QStack<QEventLoop *> eventLoops;
QPostEventList postEventList;
QAtomicPointer<QThread> thread;
- Qt::HANDLE threadId;
+ QAtomicPointer<void> threadId;
QAtomicPointer<QAbstractEventDispatcher> eventDispatcher;
QVector<void *> tls;
FlaggedDebugSignatures flaggedSignatures;
diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp
index c60742631b..f359d25a73 100644
--- a/src/corelib/thread/qthread_unix.cpp
+++ b/src/corelib/thread/qthread_unix.cpp
@@ -255,7 +255,7 @@ QThreadData *QThreadData::current(bool createIfNecessary)
}
data->deref();
data->isAdopted = true;
- data->threadId = to_HANDLE(pthread_self());
+ data->threadId.store(to_HANDLE(pthread_self()));
if (!QCoreApplicationPrivate::theMainThread)
QCoreApplicationPrivate::theMainThread = data->thread.load();
}
@@ -335,7 +335,7 @@ void *QThreadPrivate::start(void *arg)
thr->d_func()->setPriority(QThread::Priority(thr->d_func()->priority & ~ThreadPriorityResetFlag));
}
- data->threadId = to_HANDLE(pthread_self());
+ data->threadId.store(to_HANDLE(pthread_self()));
set_thread_data(data);
data->ref();
@@ -352,7 +352,7 @@ void *QThreadPrivate::start(void *arg)
// sets the name of the current thread.
QString objectName = thr->objectName();
- pthread_t thread_id = from_HANDLE<pthread_t>(data->threadId);
+ pthread_t thread_id = from_HANDLE<pthread_t>(data->threadId.load());
if (Q_LIKELY(objectName.isEmpty()))
setCurrentThreadName(thread_id, thr->metaObject()->className());
else
@@ -651,7 +651,7 @@ void QThread::start(Priority priority)
#endif
code = pthread_create(&threadId, &attr, QThreadPrivate::start, this);
}
- d->data->threadId = to_HANDLE(threadId);
+ d->data->threadId.store(to_HANDLE(threadId));
pthread_attr_destroy(&attr);
@@ -660,7 +660,7 @@ void QThread::start(Priority priority)
d->running = false;
d->finished = false;
- d->data->threadId = 0;
+ d->data->threadId.store(nullptr);
}
}
@@ -670,10 +670,10 @@ void QThread::terminate()
Q_D(QThread);
QMutexLocker locker(&d->mutex);
- if (!d->data->threadId)
+ if (!d->data->threadId.load())
return;
- int code = pthread_cancel(from_HANDLE<pthread_t>(d->data->threadId));
+ int code = pthread_cancel(from_HANDLE<pthread_t>(d->data->threadId.load()));
if (code) {
qWarning("QThread::start: Thread termination error: %s",
qPrintable(qt_error_string((code))));
@@ -686,7 +686,7 @@ bool QThread::wait(unsigned long time)
Q_D(QThread);
QMutexLocker locker(&d->mutex);
- if (from_HANDLE<pthread_t>(d->data->threadId) == pthread_self()) {
+ if (from_HANDLE<pthread_t>(d->data->threadId.load()) == pthread_self()) {
qWarning("QThread::wait: Thread tried to wait on itself");
return false;
}
@@ -728,7 +728,7 @@ void QThreadPrivate::setPriority(QThread::Priority threadPriority)
int sched_policy;
sched_param param;
- if (pthread_getschedparam(from_HANDLE<pthread_t>(data->threadId), &sched_policy, &param) != 0) {
+ if (pthread_getschedparam(from_HANDLE<pthread_t>(data->threadId.load()), &sched_policy, &param) != 0) {
// failed to get the scheduling policy, don't bother setting
// the priority
qWarning("QThread::setPriority: Cannot get scheduler parameters");
@@ -744,15 +744,15 @@ void QThreadPrivate::setPriority(QThread::Priority threadPriority)
}
param.sched_priority = prio;
- int status = pthread_setschedparam(from_HANDLE<pthread_t>(data->threadId), sched_policy, &param);
+ int status = pthread_setschedparam(from_HANDLE<pthread_t>(data->threadId.load()), sched_policy, &param);
# ifdef SCHED_IDLE
// were we trying to set to idle priority and failed?
if (status == -1 && sched_policy == SCHED_IDLE && errno == EINVAL) {
// reset to lowest priority possible
- pthread_getschedparam(from_HANDLE<pthread_t>(data->threadId), &sched_policy, &param);
+ pthread_getschedparam(from_HANDLE<pthread_t>(data->threadId.load()), &sched_policy, &param);
param.sched_priority = sched_get_priority_min(sched_policy);
- pthread_setschedparam(from_HANDLE<pthread_t>(data->threadId), sched_policy, &param);
+ pthread_setschedparam(from_HANDLE<pthread_t>(data->threadId.load()), sched_policy, &param);
}
# else
Q_UNUSED(status);
diff --git a/src/corelib/thread/qthread_win.cpp b/src/corelib/thread/qthread_win.cpp
index e6c70ecb55..ef7bfc511d 100644
--- a/src/corelib/thread/qthread_win.cpp
+++ b/src/corelib/thread/qthread_win.cpp
@@ -137,7 +137,7 @@ QThreadData *QThreadData::current(bool createIfNecessary)
}
threadData->deref();
threadData->isAdopted = true;
- threadData->threadId = reinterpret_cast<Qt::HANDLE>(quintptr(GetCurrentThreadId()));
+ threadData->threadId.store(reinterpret_cast<Qt::HANDLE>(quintptr(GetCurrentThreadId())));
if (!QCoreApplicationPrivate::theMainThread) {
QCoreApplicationPrivate::theMainThread = threadData->thread.load();
@@ -351,7 +351,7 @@ unsigned int __stdcall QT_ENSURE_STACK_ALIGNED_FOR_SSE QThreadPrivate::start(voi
qt_create_tls();
TlsSetValue(qt_current_thread_data_tls_index, data);
- data->threadId = reinterpret_cast<Qt::HANDLE>(quintptr(GetCurrentThreadId()));
+ data->threadId.store(reinterpret_cast<Qt::HANDLE>(quintptr(GetCurrentThreadId())));
QThread::setTerminationEnabled(false);
diff --git a/src/gui/doc/snippets/code/src_gui_text_qsyntaxhighlighter.cpp b/src/gui/doc/snippets/code/src_gui_text_qsyntaxhighlighter.cpp
index da960088b7..bb27eb9612 100644
--- a/src/gui/doc/snippets/code/src_gui_text_qsyntaxhighlighter.cpp
+++ b/src/gui/doc/snippets/code/src_gui_text_qsyntaxhighlighter.cpp
@@ -60,14 +60,13 @@ void MyHighlighter::highlightBlock(const QString &text)
QTextCharFormat myClassFormat;
myClassFormat.setFontWeight(QFont::Bold);
myClassFormat.setForeground(Qt::darkMagenta);
- QString pattern = "\\bMy[A-Za-z]+\\b";
- QRegExp expression(pattern);
- int index = text.indexOf(expression);
- while (index >= 0) {
- int length = expression.matchedLength();
- setFormat(index, length, myClassFormat);
- index = text.indexOf(expression, index + length);
+ QRegularExpression expression("\\bMy[A-Za-z]+\\b");
+ QRegularExpressionMatchIterator i = expression.globalMatch(text);
+ while (i.hasNext())
+ {
+ QRegularExpressionMatch match = i.next();
+ setFormat(match.capturedStart(), match.capturedLength(), myClassFormat);
}
}
//! [1]
@@ -77,8 +76,8 @@ void MyHighlighter::highlightBlock(const QString &text)
QTextCharFormat multiLineCommentFormat;
multiLineCommentFormat.setForeground(Qt::red);
-QRegExp startExpression("/\\*");
-QRegExp endExpression("\\*/");
+QRegularExpression startExpression("/\\*");
+QRegularExpression endExpression("\\*/");
setCurrentBlockState(0);
@@ -87,14 +86,15 @@ if (previousBlockState() != 1)
startIndex = text.indexOf(startExpression);
while (startIndex >= 0) {
- int endIndex = text.indexOf(endExpression, startIndex);
+ QRegularExpressionMatch endMatch;
+ int endIndex = text.indexOf(endExpression, startIndex, &endMatch);
int commentLength;
if (endIndex == -1) {
setCurrentBlockState(1);
commentLength = text.length() - startIndex;
} else {
commentLength = endIndex - startIndex
- + endExpression.matchedLength();
+ + endMatch.capturedLength();
}
setFormat(startIndex, commentLength, multiLineCommentFormat);
startIndex = text.indexOf(startExpression,
@@ -104,25 +104,6 @@ while (startIndex >= 0) {
//! [3]
-void MyHighlighter::highlightBlock(const QString &text)
-{
- QTextCharFormat myClassFormat;
- myClassFormat.setFontWeight(QFont::Bold);
- myClassFormat.setForeground(Qt::darkMagenta);
- QString pattern = "\\bMy[A-Za-z]+\\b";
-
- QRegExp expression(pattern);
- int index = text.indexOf(expression);
- while (index >= 0) {
- int length = expression.matchedLength();
- setFormat(index, length, myClassFormat);
- index = text.indexOf(expression, index + length);
- }
- }
-//! [3]
-
-
-//! [4]
struct ParenthesisInfo
{
QChar char;
@@ -133,4 +114,4 @@ struct BlockData : public QTextBlockUserData
{
QVector<ParenthesisInfo> parentheses;
};
-//! [4]
+//! [3]
diff --git a/src/gui/text/qcssparser_p.h b/src/gui/text/qcssparser_p.h
index 9f79e9934e..c1594531ea 100644
--- a/src/gui/text/qcssparser_p.h
+++ b/src/gui/text/qcssparser_p.h
@@ -75,6 +75,10 @@ QT_END_NAMESPACE
#if defined(Q_OS_INTEGRITY)
# undef Value
#endif
+// Hurd has #define TILDE 0x00080000 from <sys/ioctl.h>
+#if defined(TILDE)
+# undef TILDE
+#endif
#define QT_CSS_DECLARE_TYPEINFO(Class, Type) \
} /* namespace QCss */ \
diff --git a/src/gui/text/qsyntaxhighlighter.cpp b/src/gui/text/qsyntaxhighlighter.cpp
index d5541b0df1..8834afc80e 100644
--- a/src/gui/text/qsyntaxhighlighter.cpp
+++ b/src/gui/text/qsyntaxhighlighter.cpp
@@ -243,6 +243,8 @@ void QSyntaxHighlighterPrivate::reformatBlock(const QTextBlock &block)
\snippet code/src_gui_text_qsyntaxhighlighter.cpp 1
+ \target QSyntaxHighlighter multiblock
+
Some syntaxes can have constructs that span several text
blocks. For example, a C++ syntax highlighter should be able to
cope with \c{/}\c{*...*}\c{/} multiline comments. To deal with
@@ -267,12 +269,12 @@ void QSyntaxHighlighterPrivate::reformatBlock(const QTextBlock &block)
\snippet code/src_gui_text_qsyntaxhighlighter.cpp 2
In the example above, we first set the current block state to
- 0. Then, if the previous block ended within a comment, we higlight
+ 0. Then, if the previous block ended within a comment, we highlight
from the beginning of the current block (\c {startIndex =
0}). Otherwise, we search for the given start expression. If the
specified end expression cannot be found in the text block, we
change the current block state by calling setCurrentBlockState(),
- and make sure that the rest of the block is higlighted.
+ and make sure that the rest of the block is highlighted.
In addition you can query the current formatting and user data
using the format() and currentBlockUserData() functions
@@ -411,33 +413,12 @@ void QSyntaxHighlighter::rehighlightBlock(const QTextBlock &block)
setFormat() as often as necessary to apply any font and color
changes that you require. For example:
- \snippet code/src_gui_text_qsyntaxhighlighter.cpp 3
-
- Some syntaxes can have constructs that span several text
- blocks. For example, a C++ syntax highlighter should be able to
- cope with \c{/}\c{*...*}\c{/} multiline comments. To deal with
- these cases it is necessary to know the end state of the previous
- text block (e.g. "in comment").
-
- Inside your highlightBlock() implementation you can query the end
- state of the previous text block using the previousBlockState()
- function. After parsing the block you can save the last state
- using setCurrentBlockState().
-
- The currentBlockState() and previousBlockState() functions return
- an int value. If no state is set, the returned value is -1. You
- can designate any other value to identify any given state using
- the setCurrentBlockState() function. Once the state is set the
- QTextBlock keeps that value until it is set set again or until the
- corresponding paragraph of text gets deleted.
+ \snippet code/src_gui_text_qsyntaxhighlighter.cpp 1
- For example, if you're writing a simple C++ syntax highlighter,
- you might designate 1 to signify "in comment". For a text block
- that ended in the middle of a comment you'd set 1 using
- setCurrentBlockState, and for other paragraphs you'd set 0.
- In your parsing code if the return value of previousBlockState()
- is 1, you would highlight the text as a C++ comment until you
- reached the closing \c{*}\c{/}.
+ See the \l{QSyntaxHighlighter multiblock}{Detailed Description} for
+ examples of using setCurrentBlockState(), currentBlockState()
+ and previousBlockState() to handle syntaxes with constructs that
+ span several text blocks
\sa previousBlockState(), setFormat(), setCurrentBlockState()
*/
@@ -581,7 +562,7 @@ void QSyntaxHighlighter::setCurrentBlockState(int newState)
and store their relative position and the actual QChar in a simple
class derived from QTextBlockUserData:
- \snippet code/src_gui_text_qsyntaxhighlighter.cpp 4
+ \snippet code/src_gui_text_qsyntaxhighlighter.cpp 3
During cursor navigation in the associated editor, you can ask the
current QTextBlock (retrieved using the QTextCursor::block()
diff --git a/src/network/bearer/qnetworksession.cpp b/src/network/bearer/qnetworksession.cpp
index 2ad46918b2..bbcd191041 100644
--- a/src/network/bearer/qnetworksession.cpp
+++ b/src/network/bearer/qnetworksession.cpp
@@ -252,6 +252,10 @@ QT_BEGIN_NAMESPACE
QNetworkSession::QNetworkSession(const QNetworkConfiguration &connectionConfig, QObject *parent)
: QObject(parent), d(0)
{
+ qRegisterMetaType<QNetworkSession::State>();
+ qRegisterMetaType<QNetworkSession::SessionError>();
+ qRegisterMetaType<QNetworkSession::UsagePolicies>();
+
// invalid configuration
if (!connectionConfig.identifier().isEmpty()) {
const auto engines = qNetworkConfigurationManagerPrivate()->engines();
@@ -277,10 +281,6 @@ QNetworkSession::QNetworkSession(const QNetworkConfiguration &connectionConfig,
}
}
}
-
- qRegisterMetaType<QNetworkSession::State>();
- qRegisterMetaType<QNetworkSession::SessionError>();
- qRegisterMetaType<QNetworkSession::UsagePolicies>();
}
/*!
diff --git a/src/plugins/platforms/windows/qwindowsglcontext.h b/src/plugins/platforms/windows/qwindowsglcontext.h
index 23d2fd0d09..dfaa428520 100644
--- a/src/plugins/platforms/windows/qwindowsglcontext.h
+++ b/src/plugins/platforms/windows/qwindowsglcontext.h
@@ -48,6 +48,7 @@
#include <vector>
QT_BEGIN_NAMESPACE
+#ifndef QT_NO_OPENGL
class QDebug;
@@ -227,7 +228,7 @@ private:
GLenum (APIENTRY * m_getGraphicsResetStatus)();
bool m_lost;
};
-
+#endif
QT_END_NAMESPACE
#endif // QWINDOWSGLCONTEXT_H
diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp
index 3444b21654..8c5f8cae08 100644
--- a/src/plugins/platforms/xcb/qxcbconnection.cpp
+++ b/src/plugins/platforms/xcb/qxcbconnection.cpp
@@ -605,7 +605,8 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGra
initializeXRender();
#if defined(XCB_USE_XINPUT2)
- initializeXInput2();
+ if (!qEnvironmentVariableIsSet("QT_XCB_NO_XI2"))
+ initializeXInput2();
#endif
initializeXShape();
initializeXKB();
diff --git a/src/testlib/qtestsystem.h b/src/testlib/qtestsystem.h
index b39fa17a34..4c611aab6b 100644
--- a/src/testlib/qtestsystem.h
+++ b/src/testlib/qtestsystem.h
@@ -58,7 +58,7 @@ namespace QTest
{
Q_ASSERT(QCoreApplication::instance());
- QDeadlineTimer timer(ms);
+ QDeadlineTimer timer(ms, Qt::PreciseTimer);
int remaining = ms;
do {
QCoreApplication::processEvents(QEventLoop::AllEvents, remaining);
@@ -74,7 +74,7 @@ namespace QTest
#ifdef QT_GUI_LIB
inline static bool qWaitForWindowActive(QWindow *window, int timeout = 5000)
{
- QDeadlineTimer timer(timeout);
+ QDeadlineTimer timer(timeout, Qt::PreciseTimer);
int remaining = timeout;
while (!window->isActive() && remaining > 0) {
QCoreApplication::processEvents(QEventLoop::AllEvents, remaining);
@@ -101,7 +101,7 @@ namespace QTest
inline static bool qWaitForWindowExposed(QWindow *window, int timeout = 5000)
{
- QDeadlineTimer timer(timeout);
+ QDeadlineTimer timer(timeout, Qt::PreciseTimer);
int remaining = timeout;
while (!window->isExposed() && remaining > 0) {
QCoreApplication::processEvents(QEventLoop::AllEvents, remaining);
diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp
index 65d6367d1d..2b0d70eac6 100644
--- a/src/tools/uic/cpp/cppwriteinitialization.cpp
+++ b/src/tools/uic/cpp/cppwriteinitialization.cpp
@@ -1153,6 +1153,7 @@ void WriteInitialization::writeProperties(const QString &varName,
DomPropertyMap properties = propertyMap(lst);
if (properties.contains(QLatin1String("control"))) {
DomProperty *p = properties.value(QLatin1String("control"));
+ Q_ASSERT( p );
m_output << m_indent << varName << "->setControl("
<< writeString(toString(p->elementString()), m_dindent) << ");\n";
}
diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp
index 5bfb7553a5..5c07279821 100644
--- a/src/widgets/dialogs/qfiledialog.cpp
+++ b/src/widgets/dialogs/qfiledialog.cpp
@@ -656,7 +656,7 @@ void QFileDialogPrivate::retranslateStrings()
/* WIDGETS */
if (options->useDefaultNameFilters())
q->setNameFilter(QFileDialogOptions::defaultNameFilterString());
- if (nativeDialogInUse)
+ if (!usingWidgets())
return;
QList<QAction*> actions = qFileDialogUi->treeView->header()->actions();