summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp2
-rw-r--r--src/corelib/kernel/qeventdispatcher_winrt.cpp33
-rw-r--r--src/corelib/kernel/qmetatype.h12
-rw-r--r--src/corelib/kernel/qobject.h12
-rw-r--r--src/corelib/kernel/qpointer.h2
-rw-r--r--src/corelib/kernel/qtimer.h8
-rw-r--r--src/corelib/kernel/qvariant.cpp1
-rw-r--r--src/corelib/kernel/qvariant_p.h12
8 files changed, 47 insertions, 35 deletions
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index a4a4e50f10..3796df5614 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -2048,7 +2048,7 @@ QString QCoreApplication::translate(const char *context, const char *sourceText,
return ret;
}
-#endif //QT_NO_TRANSLATE
+#endif //QT_NO_TRANSLATION
// Makes it possible to point QCoreApplication to a custom location to ensure
// the directory is added to the patch, and qt.conf and deployed plugins are
diff --git a/src/corelib/kernel/qeventdispatcher_winrt.cpp b/src/corelib/kernel/qeventdispatcher_winrt.cpp
index 3b2321aa49..ff397fc750 100644
--- a/src/corelib/kernel/qeventdispatcher_winrt.cpp
+++ b/src/corelib/kernel/qeventdispatcher_winrt.cpp
@@ -42,6 +42,7 @@
#include <QtCore/QCoreApplication>
#include <QtCore/QThread>
#include <QtCore/QHash>
+#include <QtCore/QMutex>
#include <QtCore/qfunctions_winrt.h>
#include <private/qabstracteventdispatcher_p.h>
#include <private/qcoreapplication_p.h>
@@ -151,6 +152,7 @@ public:
private:
QHash<int, QObject *> timerIdToObject;
QVector<WinRTTimerInfo> timerInfos;
+ mutable QMutex timerInfoLock;
QHash<HANDLE, int> timerHandleToId;
QHash<int, HANDLE> timerIdToHandle;
QHash<int, HANDLE> timerIdToCancelHandle;
@@ -167,6 +169,7 @@ private:
timerIdToObject.insert(id, obj);
const quint64 targetTime = qt_msectime() + interval;
const WinRTTimerInfo info(id, interval, type, obj, targetTime);
+ QMutexLocker locker(&timerInfoLock);
if (id >= timerInfos.size())
timerInfos.resize(id + 1);
timerInfos[id] = info;
@@ -175,6 +178,7 @@ private:
bool removeTimer(int id)
{
+ QMutexLocker locker(&timerInfoLock);
if (id >= timerInfos.size())
return false;
@@ -312,14 +316,18 @@ bool QEventDispatcherWinRT::processEvents(QEventLoop::ProcessEventsFlags flags)
if (timerId == INTERRUPT_HANDLE)
break;
- WinRTTimerInfo &info = d->timerInfos[timerId];
- Q_ASSERT(info.timerId != INVALID_TIMER_ID);
+ {
+ QMutexLocker locker(&d->timerInfoLock);
- QCoreApplication::postEvent(this, new QTimerEvent(timerId));
+ WinRTTimerInfo &info = d->timerInfos[timerId];
+ Q_ASSERT(info.timerId != INVALID_TIMER_ID);
- // Update timer's targetTime
- const quint64 targetTime = qt_msectime() + info.interval;
- info.targetTime = targetTime;
+ QCoreApplication::postEvent(this, new QTimerEvent(timerId));
+
+ // Update timer's targetTime
+ const quint64 targetTime = qt_msectime() + info.interval;
+ info.targetTime = targetTime;
+ }
waitResult = WaitForMultipleObjectsEx(timerHandles.count(), timerHandles.constData(), FALSE, 0, TRUE);
}
emit awake();
@@ -487,6 +495,7 @@ QList<QAbstractEventDispatcher::TimerInfo> QEventDispatcherWinRT::registeredTime
}
Q_D(const QEventDispatcherWinRT);
+ QMutexLocker locker(&d->timerInfoLock);
QList<TimerInfo> timerInfos;
for (const WinRTTimerInfo &info : d->timerInfos) {
if (info.object == object && info.timerId != INVALID_TIMER_ID)
@@ -518,6 +527,7 @@ int QEventDispatcherWinRT::remainingTime(int timerId)
}
Q_D(QEventDispatcherWinRT);
+ QMutexLocker locker(&d->timerInfoLock);
const WinRTTimerInfo timerInfo = d->timerInfos.at(timerId);
if (timerInfo.timerId == INVALID_TIMER_ID) {
#ifndef QT_NO_DEBUG
@@ -566,6 +576,9 @@ bool QEventDispatcherWinRT::event(QEvent *e)
case QEvent::Timer: {
QTimerEvent *timerEvent = static_cast<QTimerEvent *>(e);
const int id = timerEvent->timerId();
+
+ QMutexLocker locker(&d->timerInfoLock);
+
Q_ASSERT(id < d->timerInfos.size());
WinRTTimerInfo &info = d->timerInfos[id];
Q_ASSERT(info.timerId != INVALID_TIMER_ID);
@@ -574,17 +587,17 @@ bool QEventDispatcherWinRT::event(QEvent *e)
break;
info.inEvent = true;
+ locker.unlock();
+
QTimerEvent te(id);
QCoreApplication::sendEvent(d->timerIdToObject.value(id), &te);
+ locker.relock();
+
// The timer might have been removed in the meanwhile
if (id >= d->timerInfos.size())
break;
- info = d->timerInfos[id];
- if (info.timerId == INVALID_TIMER_ID)
- break;
-
if (info.interval == 0 && info.inEvent) {
// post the next zero timer event as long as the timer was not restarted
QCoreApplication::postEvent(this, new QTimerEvent(id));
diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h
index 9e2a5bf75d..e64812b3ae 100644
--- a/src/corelib/kernel/qmetatype.h
+++ b/src/corelib/kernel/qmetatype.h
@@ -45,8 +45,6 @@
#include <QtCore/qatomic.h>
#include <QtCore/qbytearray.h>
#include <QtCore/qvarlengtharray.h>
-#include <QtCore/qisenum.h>
-#include <QtCore/qtypetraits.h>
#ifndef QT_NO_QOBJECT
#include <QtCore/qobjectdefs.h>
#endif
@@ -887,7 +885,7 @@ private:
// is void* to avoid overloads conflicts. We do it by injecting unaccessible Dummy
// type as part of the overload signature.
struct Dummy {};
- typedef typename QtPrivate::if_<QtPrivate::is_same<value_type, void*>::value, Dummy, value_type>::type value_type_OR_Dummy;
+ typedef typename std::conditional<std::is_same<value_type, void*>::value, Dummy, value_type>::type value_type_OR_Dummy;
public:
static void assign(void **ptr, const value_type_OR_Dummy *iterator )
{
@@ -1092,7 +1090,7 @@ struct QSequentialIterableConvertFunctor
}
namespace QtMetaTypePrivate {
-template<typename T, bool = QtPrivate::is_same<typename T::const_iterator::value_type, typename T::mapped_type>::value>
+template<typename T, bool = std::is_same<typename T::const_iterator::value_type, typename T::mapped_type>::value>
struct AssociativeContainerAccessor
{
static const typename T::key_type& getKey(const typename T::const_iterator &it)
@@ -1106,7 +1104,7 @@ struct AssociativeContainerAccessor
}
};
-template<typename T, bool = QtPrivate::is_same<typename T::const_iterator::value_type, std::pair<const typename T::key_type, typename T::mapped_type> >::value>
+template<typename T, bool = std::is_same<typename T::const_iterator::value_type, std::pair<const typename T::key_type, typename T::mapped_type> >::value>
struct StlStyleAssociativeContainerAccessor;
template<typename T>
@@ -1636,7 +1634,7 @@ namespace QtPrivate {
| (IsSharedPointerToTypeDerivedFromQObject<T>::Value ? QMetaType::SharedPointerToQObject : 0)
| (IsWeakPointerToTypeDerivedFromQObject<T>::Value ? QMetaType::WeakPointerToQObject : 0)
| (IsTrackingPointerToTypeDerivedFromQObject<T>::Value ? QMetaType::TrackingPointerToQObject : 0)
- | (Q_IS_ENUM(T) ? QMetaType::IsEnumeration : 0)
+ | (std::is_enum<T>::value ? QMetaType::IsEnumeration : 0)
| (IsGadgetHelper<T>::Value ? QMetaType::IsGadget : 0)
};
};
@@ -1787,7 +1785,7 @@ template <typename T>
struct QMetaTypeIdQObject<T, QMetaType::IsGadget>
{
enum {
- Defined = QtPrivate::is_default_constructible<T>::value
+ Defined = std::is_default_constructible<T>::value
};
static int qt_metatype_id()
diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h
index 75a7f63fbf..25acdefeaf 100644
--- a/src/corelib/kernel/qobject.h
+++ b/src/corelib/kernel/qobject.h
@@ -155,14 +155,14 @@ public:
template<typename T>
inline T findChild(const QString &aName = QString(), Qt::FindChildOptions options = Qt::FindChildrenRecursively) const
{
- typedef typename QtPrivate::remove_cv<typename QtPrivate::remove_pointer<T>::type>::type ObjType;
+ typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type ObjType;
return static_cast<T>(qt_qFindChild_helper(this, aName, ObjType::staticMetaObject, options));
}
template<typename T>
inline QList<T> findChildren(const QString &aName = QString(), Qt::FindChildOptions options = Qt::FindChildrenRecursively) const
{
- typedef typename QtPrivate::remove_cv<typename QtPrivate::remove_pointer<T>::type>::type ObjType;
+ typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type ObjType;
QList<T> list;
qt_qFindChildren_helper(this, aName, ObjType::staticMetaObject,
reinterpret_cast<QList<void *> *>(&list), options);
@@ -173,7 +173,7 @@ public:
template<typename T>
inline QList<T> findChildren(const QRegExp &re, Qt::FindChildOptions options = Qt::FindChildrenRecursively) const
{
- typedef typename QtPrivate::remove_cv<typename QtPrivate::remove_pointer<T>::type>::type ObjType;
+ typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type ObjType;
QList<T> list;
qt_qFindChildren_helper(this, re, ObjType::staticMetaObject,
reinterpret_cast<QList<void *> *>(&list), options);
@@ -185,7 +185,7 @@ public:
template<typename T>
inline QList<T> findChildren(const QRegularExpression &re, Qt::FindChildOptions options = Qt::FindChildrenRecursively) const
{
- typedef typename QtPrivate::remove_cv<typename QtPrivate::remove_pointer<T>::type>::type ObjType;
+ typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type ObjType;
QList<T> list;
qt_qFindChildren_helper(this, re, ObjType::staticMetaObject,
reinterpret_cast<QList<void *> *>(&list), options);
@@ -497,7 +497,7 @@ inline QT_DEPRECATED QList<T> qFindChildren(const QObject *o, const QRegExp &re)
template <class T>
inline T qobject_cast(QObject *object)
{
- typedef typename QtPrivate::remove_cv<typename QtPrivate::remove_pointer<T>::type>::type ObjType;
+ typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type ObjType;
Q_STATIC_ASSERT_X(QtPrivate::HasQ_OBJECT_Macro<ObjType>::Value,
"qobject_cast requires the type to have a Q_OBJECT macro");
return static_cast<T>(ObjType::staticMetaObject.cast(object));
@@ -506,7 +506,7 @@ inline T qobject_cast(QObject *object)
template <class T>
inline T qobject_cast(const QObject *object)
{
- typedef typename QtPrivate::remove_cv<typename QtPrivate::remove_pointer<T>::type>::type ObjType;
+ typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type ObjType;
Q_STATIC_ASSERT_X(QtPrivate::HasQ_OBJECT_Macro<ObjType>::Value,
"qobject_cast requires the type to have a Q_OBJECT macro");
return static_cast<T>(ObjType::staticMetaObject.cast(object));
diff --git a/src/corelib/kernel/qpointer.h b/src/corelib/kernel/qpointer.h
index b5c17ad394..b2b3cda4ab 100644
--- a/src/corelib/kernel/qpointer.h
+++ b/src/corelib/kernel/qpointer.h
@@ -52,7 +52,7 @@ class QVariant;
template <class T>
class QPointer
{
- Q_STATIC_ASSERT_X(!QtPrivate::is_pointer<T>::value, "QPointer's template type must not be a pointer type");
+ Q_STATIC_ASSERT_X(!std::is_pointer<T>::value, "QPointer's template type must not be a pointer type");
template<typename U>
struct TypeSelector
diff --git a/src/corelib/kernel/qtimer.h b/src/corelib/kernel/qtimer.h
index 4f934d0367..96c7efd8f5 100644
--- a/src/corelib/kernel/qtimer.h
+++ b/src/corelib/kernel/qtimer.h
@@ -119,14 +119,14 @@ public:
// singleShot to a functor or function pointer (without context)
template <typename Duration, typename Func1>
static inline typename QtPrivate::QEnableIf<!QtPrivate::FunctionPointer<Func1>::IsPointerToMemberFunction &&
- !QtPrivate::is_same<const char*, Func1>::value, void>::Type
+ !std::is_same<const char*, Func1>::value, void>::Type
singleShot(Duration interval, Func1 slot)
{
singleShot(interval, defaultTypeFor(interval), nullptr, slot);
}
template <typename Duration, typename Func1>
static inline typename QtPrivate::QEnableIf<!QtPrivate::FunctionPointer<Func1>::IsPointerToMemberFunction &&
- !QtPrivate::is_same<const char*, Func1>::value, void>::Type
+ !std::is_same<const char*, Func1>::value, void>::Type
singleShot(Duration interval, Qt::TimerType timerType, Func1 slot)
{
singleShot(interval, timerType, nullptr, slot);
@@ -134,14 +134,14 @@ public:
// singleShot to a functor or function pointer (with context)
template <typename Duration, typename Func1>
static inline typename QtPrivate::QEnableIf<!QtPrivate::FunctionPointer<Func1>::IsPointerToMemberFunction &&
- !QtPrivate::is_same<const char*, Func1>::value, void>::Type
+ !std::is_same<const char*, Func1>::value, void>::Type
singleShot(Duration interval, QObject *context, Func1 slot)
{
singleShot(interval, defaultTypeFor(interval), context, slot);
}
template <typename Duration, typename Func1>
static inline typename QtPrivate::QEnableIf<!QtPrivate::FunctionPointer<Func1>::IsPointerToMemberFunction &&
- !QtPrivate::is_same<const char*, Func1>::value, void>::Type
+ !std::is_same<const char*, Func1>::value, void>::Type
singleShot(Duration interval, Qt::TimerType timerType, QObject *context, Func1 slot)
{
//compilation error if the slot has arguments.
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp
index 72ae3b063f..ccfa7d0d38 100644
--- a/src/corelib/kernel/qvariant.cpp
+++ b/src/corelib/kernel/qvariant.cpp
@@ -3085,6 +3085,7 @@ bool QVariant::canConvert(int targetTypeId) const
if (currentType == QMetaType::QJsonValue) {
switch (targetTypeId) {
+ case QMetaType::Nullptr:
case QMetaType::QString:
case QMetaType::Bool:
case QMetaType::Int:
diff --git a/src/corelib/kernel/qvariant_p.h b/src/corelib/kernel/qvariant_p.h
index d01f386032..bf88def438 100644
--- a/src/corelib/kernel/qvariant_p.h
+++ b/src/corelib/kernel/qvariant_p.h
@@ -65,8 +65,8 @@ template<typename T>
struct QVariantIntegrator
{
static const bool CanUseInternalSpace = sizeof(T) <= sizeof(QVariant::Private::Data)
- && ((QTypeInfoQuery<T>::isRelocatable) || Q_IS_ENUM(T));
- typedef QtPrivate::integral_constant<bool, CanUseInternalSpace> CanUseInternalSpace_t;
+ && ((QTypeInfoQuery<T>::isRelocatable) || std::is_enum<T>::value);
+ typedef std::integral_constant<bool, CanUseInternalSpace> CanUseInternalSpace_t;
};
Q_STATIC_ASSERT(QVariantIntegrator<double>::CanUseInternalSpace);
Q_STATIC_ASSERT(QVariantIntegrator<long int>::CanUseInternalSpace);
@@ -118,28 +118,28 @@ private:
};
template <class T>
-inline void v_construct_helper(QVariant::Private *x, const T &t, QtPrivate::true_type)
+inline void v_construct_helper(QVariant::Private *x, const T &t, std::true_type)
{
new (&x->data) T(t);
x->is_shared = false;
}
template <class T>
-inline void v_construct_helper(QVariant::Private *x, const T &t, QtPrivate::false_type)
+inline void v_construct_helper(QVariant::Private *x, const T &t, std::false_type)
{
x->data.shared = new QVariantPrivateSharedEx<T>(t);
x->is_shared = true;
}
template <class T>
-inline void v_construct_helper(QVariant::Private *x, QtPrivate::true_type)
+inline void v_construct_helper(QVariant::Private *x, std::true_type)
{
new (&x->data) T();
x->is_shared = false;
}
template <class T>
-inline void v_construct_helper(QVariant::Private *x, QtPrivate::false_type)
+inline void v_construct_helper(QVariant::Private *x, std::false_type)
{
x->data.shared = new QVariantPrivateSharedEx<T>;
x->is_shared = true;