diff options
Diffstat (limited to 'src/corelib/kernel')
37 files changed, 273 insertions, 150 deletions
diff --git a/src/corelib/kernel/qabstracteventdispatcher.h b/src/corelib/kernel/qabstracteventdispatcher.h index c80f7d3d08..eb357cefe5 100644 --- a/src/corelib/kernel/qabstracteventdispatcher.h +++ b/src/corelib/kernel/qabstracteventdispatcher.h @@ -64,10 +64,10 @@ public: { } }; - explicit QAbstractEventDispatcher(QObject *parent = 0); + explicit QAbstractEventDispatcher(QObject *parent = Q_NULLPTR); ~QAbstractEventDispatcher(); - static QAbstractEventDispatcher *instance(QThread *thread = 0); + static QAbstractEventDispatcher *instance(QThread *thread = Q_NULLPTR); virtual bool processEvents(QEventLoop::ProcessEventsFlags flags) = 0; virtual bool hasPendingEvents() = 0; // ### Qt6: remove, mark final or make protected diff --git a/src/corelib/kernel/qcore_mac_objc.mm b/src/corelib/kernel/qcore_mac_objc.mm index a215557aed..14c0f803b9 100644 --- a/src/corelib/kernel/qcore_mac_objc.mm +++ b/src/corelib/kernel/qcore_mac_objc.mm @@ -131,5 +131,22 @@ QAppleOperatingSystemVersion qt_apple_os_version() return v; } +// ------------------------------------------------------------------------- + +QMacAutoReleasePool::QMacAutoReleasePool() + : pool([[NSAutoreleasePool alloc] init]) +{ +} + +QMacAutoReleasePool::~QMacAutoReleasePool() +{ + // Drain behaves the same as release, with the advantage that + // if we're ever used in a garbage-collected environment, the + // drain acts as a hint to the garbage collector to collect. + [pool drain]; +} + +// ------------------------------------------------------------------------- + QT_END_NAMESPACE diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 8489afe5a7..66481d4c87 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -45,7 +45,6 @@ #include <qdir.h> #include <qfile.h> #include <qfileinfo.h> -#include <qhash.h> #include <qmutex.h> #include <private/qloggingregistry_p.h> #include <qstandardpaths.h> diff --git a/src/corelib/kernel/qcoreapplication.h b/src/corelib/kernel/qcoreapplication.h index 1cd835daae..1009fe8439 100644 --- a/src/corelib/kernel/qcoreapplication.h +++ b/src/corelib/kernel/qcoreapplication.h @@ -117,7 +117,7 @@ public: static bool sendEvent(QObject *receiver, QEvent *event); static void postEvent(QObject *receiver, QEvent *event, int priority = Qt::NormalEventPriority); - static void sendPostedEvents(QObject *receiver = 0, int event_type = 0); + static void sendPostedEvents(QObject *receiver = Q_NULLPTR, int event_type = 0); static void removePostedEvents(QObject *receiver, int eventType = 0); #if QT_DEPRECATED_SINCE(5, 3) QT_DEPRECATED static bool hasPendingEvents(); @@ -149,7 +149,7 @@ public: static QString translate(const char * context, const char * key, - const char * disambiguation = 0, + const char * disambiguation = Q_NULLPTR, int n = -1); #if QT_DEPRECATED_SINCE(5, 0) enum Encoding { UnicodeUTF8, Latin1, DefaultCodec = UnicodeUTF8, CodecForTr = UnicodeUTF8 }; @@ -231,13 +231,13 @@ inline bool QCoreApplication::sendSpontaneousEvent(QObject *receiver, QEvent *ev # define QT_DECLARE_DEPRECATED_TR_FUNCTIONS(context) #else # define QT_DECLARE_DEPRECATED_TR_FUNCTIONS(context) \ - QT_DEPRECATED static inline QString trUtf8(const char *sourceText, const char *disambiguation = 0, int n = -1) \ + QT_DEPRECATED static inline QString trUtf8(const char *sourceText, const char *disambiguation = Q_NULLPTR, int n = -1) \ { return QCoreApplication::translate(#context, sourceText, disambiguation, n); } #endif #define Q_DECLARE_TR_FUNCTIONS(context) \ public: \ - static inline QString tr(const char *sourceText, const char *disambiguation = 0, int n = -1) \ + static inline QString tr(const char *sourceText, const char *disambiguation = Q_NULLPTR, int n = -1) \ { return QCoreApplication::translate(#context, sourceText, disambiguation, n); } \ QT_DECLARE_DEPRECATED_TR_FUNCTIONS(context) \ private: diff --git a/src/corelib/kernel/qcoreevent.cpp b/src/corelib/kernel/qcoreevent.cpp index e9ae355d70..98514c56af 100644 --- a/src/corelib/kernel/qcoreevent.cpp +++ b/src/corelib/kernel/qcoreevent.cpp @@ -150,7 +150,7 @@ QT_BEGIN_NAMESPACE \value HoverLeave The mouse cursor leaves a hover widget (QHoverEvent). \value HoverMove The mouse cursor moves inside a hover widget (QHoverEvent). \value IconDrag The main icon of a window has been dragged away (QIconDragEvent). - \value IconTextChange Widget's icon text has been changed. + \value IconTextChange Widget's icon text has been changed. (Deprecated) \value InputMethod An input method is being used (QInputMethodEvent). \value InputMethodQuery A input method query event (QInputMethodQueryEvent) \value KeyboardLayoutChange The keyboard layout has changed. diff --git a/src/corelib/kernel/qcoreevent.h b/src/corelib/kernel/qcoreevent.h index c208eb1180..53da4a849b 100644 --- a/src/corelib/kernel/qcoreevent.h +++ b/src/corelib/kernel/qcoreevent.h @@ -133,7 +133,7 @@ public: EnabledChange = 98, // enabled state has changed ActivationChange = 99, // window activation has changed StyleChange = 100, // style has changed - IconTextChange = 101, // icon text has changed + IconTextChange = 101, // icon text has changed. Deprecated. ModifiedChange = 102, // modified state has changed MouseTrackingChange = 109, // mouse tracking state has changed diff --git a/src/corelib/kernel/qeventdispatcher_glib.cpp b/src/corelib/kernel/qeventdispatcher_glib.cpp index 876825b5f0..d9bbd4d5f2 100644 --- a/src/corelib/kernel/qeventdispatcher_glib.cpp +++ b/src/corelib/kernel/qeventdispatcher_glib.cpp @@ -39,7 +39,6 @@ #include "qcoreapplication.h" #include "qsocketnotifier.h" -#include <QtCore/qhash.h> #include <QtCore/qlist.h> #include <QtCore/qpair.h> diff --git a/src/corelib/kernel/qeventdispatcher_glib_p.h b/src/corelib/kernel/qeventdispatcher_glib_p.h index afdb6b9317..2cb919df07 100644 --- a/src/corelib/kernel/qeventdispatcher_glib_p.h +++ b/src/corelib/kernel/qeventdispatcher_glib_p.h @@ -48,8 +48,6 @@ #include "qabstracteventdispatcher.h" #include "qabstracteventdispatcher_p.h" -#include <QtCore/qhash.h> - typedef struct _GMainContext GMainContext; QT_BEGIN_NAMESPACE diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp index b55679f3d5..ccb8341d0a 100644 --- a/src/corelib/kernel/qeventdispatcher_win.cpp +++ b/src/corelib/kernel/qeventdispatcher_win.cpp @@ -34,7 +34,6 @@ #include "qeventdispatcher_win_p.h" #include "qcoreapplication.h" -#include "qhash.h" #include <private/qsystemlibrary_p.h> #include "qpair.h" #include "qset.h" @@ -1076,11 +1075,10 @@ void QEventDispatcherWin32::activateEventNotifiers() for (int i=0; i<d->winEventNotifierList.count(); i++) { #if !defined(Q_OS_WINCE) if (WaitForSingleObjectEx(d->winEventNotifierList.at(i)->handle(), 0, TRUE) == WAIT_OBJECT_0) - d->activateEventNotifier(d->winEventNotifierList.at(i)); #else if (WaitForSingleObject(d->winEventNotifierList.at(i)->handle(), 0) == WAIT_OBJECT_0) - d->activateEventNotifier(d->winEventNotifierList.at(i)); #endif + d->activateEventNotifier(d->winEventNotifierList.at(i)); } } diff --git a/src/corelib/kernel/qeventloop.h b/src/corelib/kernel/qeventloop.h index 99c0cd50ff..375a63abdd 100644 --- a/src/corelib/kernel/qeventloop.h +++ b/src/corelib/kernel/qeventloop.h @@ -47,7 +47,7 @@ class Q_CORE_EXPORT QEventLoop : public QObject Q_DECLARE_PRIVATE(QEventLoop) public: - explicit QEventLoop(QObject *parent = 0); + explicit QEventLoop(QObject *parent = Q_NULLPTR); ~QEventLoop(); enum ProcessEventsFlag { diff --git a/src/corelib/kernel/qjni.cpp b/src/corelib/kernel/qjni.cpp index 2640ecaaaf..108a01aab7 100644 --- a/src/corelib/kernel/qjni.cpp +++ b/src/corelib/kernel/qjni.cpp @@ -225,6 +225,15 @@ static jfieldID getCachedFieldID(JNIEnv *env, } } +void QJNILocalRefDeleter::cleanup(jobject obj) +{ + if (obj == 0) + return; + + QJNIEnvironmentPrivate env; + env->DeleteLocalRef(obj); +} + class QJNIEnvironmentPrivateTLS { public: @@ -2371,4 +2380,3 @@ bool QJNIObjectPrivate::isSameObject(const QJNIObjectPrivate &other) const } QT_END_NAMESPACE - diff --git a/src/corelib/kernel/qjni_p.h b/src/corelib/kernel/qjni_p.h index a32d656ebf..1c23f2ab76 100644 --- a/src/corelib/kernel/qjni_p.h +++ b/src/corelib/kernel/qjni_p.h @@ -51,6 +51,14 @@ QT_BEGIN_NAMESPACE +struct Q_CORE_EXPORT QJNILocalRefDeleter +{ + static void cleanup(jobject obj); +}; + +// To simplify this we only define it for jobjects. +typedef QScopedPointer<_jobject, QJNILocalRefDeleter> QJNIScopedLocalRef; + class Q_CORE_EXPORT QJNIEnvironmentPrivate { public: diff --git a/src/corelib/kernel/qjnihelpers.cpp b/src/corelib/kernel/qjnihelpers.cpp index dad2d5dc1e..f77fc4220c 100644 --- a/src/corelib/kernel/qjnihelpers.cpp +++ b/src/corelib/kernel/qjnihelpers.cpp @@ -122,6 +122,45 @@ void QtAndroidPrivate::handleNewIntent(JNIEnv *env, jobject intent) } } +namespace { + class ResumePauseListeners + { + public: + QMutex mutex; + QList<QtAndroidPrivate::ResumePauseListener *> listeners; + }; +} + +Q_GLOBAL_STATIC(ResumePauseListeners, g_resumePauseListeners) + +void QtAndroidPrivate::registerResumePauseListener(ResumePauseListener *listener) +{ + QMutexLocker locker(&g_resumePauseListeners()->mutex); + g_resumePauseListeners()->listeners.append(listener); +} + +void QtAndroidPrivate::unregisterResumePauseListener(ResumePauseListener *listener) +{ + QMutexLocker locker(&g_resumePauseListeners()->mutex); + g_resumePauseListeners()->listeners.removeAll(listener); +} + +void QtAndroidPrivate::handlePause() +{ + QMutexLocker locker(&g_resumePauseListeners()->mutex); + const QList<QtAndroidPrivate::ResumePauseListener *> &listeners = g_resumePauseListeners()->listeners; + for (int i=0; i<listeners.size(); ++i) + listeners.at(i)->handlePause(); +} + +void QtAndroidPrivate::handleResume() +{ + QMutexLocker locker(&g_resumePauseListeners()->mutex); + const QList<QtAndroidPrivate::ResumePauseListener *> &listeners = g_resumePauseListeners()->listeners; + for (int i=0; i<listeners.size(); ++i) + listeners.at(i)->handleResume(); +} + static inline bool exceptionCheck(JNIEnv *env) { if (env->ExceptionCheck()) { diff --git a/src/corelib/kernel/qjnihelpers_p.h b/src/corelib/kernel/qjnihelpers_p.h index 3ed8338b18..883b08ef60 100644 --- a/src/corelib/kernel/qjnihelpers_p.h +++ b/src/corelib/kernel/qjnihelpers_p.h @@ -68,6 +68,14 @@ namespace QtAndroidPrivate virtual bool handleNewIntent(JNIEnv *env, jobject intent) = 0; }; + class Q_CORE_EXPORT ResumePauseListener + { + public: + virtual ~ResumePauseListener() {} + virtual void handlePause() {}; + virtual void handleResume() {}; + }; + Q_CORE_EXPORT jobject activity(); Q_CORE_EXPORT JavaVM *javaVM(); Q_CORE_EXPORT jint initJNI(JavaVM *vm, JNIEnv *env); @@ -82,6 +90,11 @@ namespace QtAndroidPrivate Q_CORE_EXPORT void handleNewIntent(JNIEnv *env, jobject intent); Q_CORE_EXPORT void registerNewIntentListener(NewIntentListener *listener); Q_CORE_EXPORT void unregisterNewIntentListener(NewIntentListener *listener); + + Q_CORE_EXPORT void handlePause(); + Q_CORE_EXPORT void handleResume(); + Q_CORE_EXPORT void registerResumePauseListener(ResumePauseListener *listener); + Q_CORE_EXPORT void unregisterResumePauseListener(ResumePauseListener *listener); } QT_END_NAMESPACE diff --git a/src/corelib/kernel/qmath.h b/src/corelib/kernel/qmath.h index 5cc3ec586e..e60561c05f 100644 --- a/src/corelib/kernel/qmath.h +++ b/src/corelib/kernel/qmath.h @@ -40,8 +40,18 @@ #include <QtCore/qglobal.h> +#ifndef _USE_MATH_DEFINES +# define _USE_MATH_DEFINES +# define undef_USE_MATH_DEFINES +#endif + #include <cmath> +#ifdef undef_USE_MATH_DEFINES +# undef _USE_MATH_DEFINES +# undef undef_USE_MATH_DEFINES +#endif + QT_BEGIN_NAMESPACE #define QT_SINE_TABLE_SIZE 256 diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index e89b914227..60cd3ab94a 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -43,7 +43,6 @@ #include <qstringlist.h> #include <qthread.h> #include <qvariant.h> -#include <qhash.h> #include <qdebug.h> #include <qsemaphore.h> diff --git a/src/corelib/kernel/qmetaobject.h b/src/corelib/kernel/qmetaobject.h index b522a211bb..1a282d3261 100644 --- a/src/corelib/kernel/qmetaobject.h +++ b/src/corelib/kernel/qmetaobject.h @@ -48,7 +48,7 @@ template <typename T> class QList; class Q_CORE_EXPORT QMetaMethod { public: - Q_DECL_CONSTEXPR inline QMetaMethod() : mobj(0),handle(0) {} + Q_DECL_CONSTEXPR inline QMetaMethod() : mobj(Q_NULLPTR), handle(0) {} QByteArray methodSignature() const; QByteArray name() const; @@ -74,7 +74,7 @@ public: bool invoke(QObject *object, Qt::ConnectionType connectionType, QGenericReturnArgument returnValue, - QGenericArgument val0 = QGenericArgument(0), + QGenericArgument val0 = QGenericArgument(Q_NULLPTR), QGenericArgument val1 = QGenericArgument(), QGenericArgument val2 = QGenericArgument(), QGenericArgument val3 = QGenericArgument(), @@ -86,7 +86,7 @@ public: QGenericArgument val9 = QGenericArgument()) const; inline bool invoke(QObject *object, QGenericReturnArgument returnValue, - QGenericArgument val0 = QGenericArgument(0), + QGenericArgument val0 = QGenericArgument(Q_NULLPTR), QGenericArgument val1 = QGenericArgument(), QGenericArgument val2 = QGenericArgument(), QGenericArgument val3 = QGenericArgument(), @@ -102,7 +102,7 @@ public: } inline bool invoke(QObject *object, Qt::ConnectionType connectionType, - QGenericArgument val0 = QGenericArgument(0), + QGenericArgument val0 = QGenericArgument(Q_NULLPTR), QGenericArgument val1 = QGenericArgument(), QGenericArgument val2 = QGenericArgument(), QGenericArgument val3 = QGenericArgument(), @@ -117,7 +117,7 @@ public: val0, val1, val2, val3, val4, val5, val6, val7, val8, val9); } inline bool invoke(QObject *object, - QGenericArgument val0 = QGenericArgument(0), + QGenericArgument val0 = QGenericArgument(Q_NULLPTR), QGenericArgument val1 = QGenericArgument(), QGenericArgument val2 = QGenericArgument(), QGenericArgument val3 = QGenericArgument(), @@ -134,7 +134,7 @@ public: bool invokeOnGadget(void *gadget, QGenericReturnArgument returnValue, - QGenericArgument val0 = QGenericArgument(0), + QGenericArgument val0 = QGenericArgument(Q_NULLPTR), QGenericArgument val1 = QGenericArgument(), QGenericArgument val2 = QGenericArgument(), QGenericArgument val3 = QGenericArgument(), @@ -145,7 +145,7 @@ public: QGenericArgument val8 = QGenericArgument(), QGenericArgument val9 = QGenericArgument()) const; inline bool invokeOnGadget(void *gadget, - QGenericArgument val0 = QGenericArgument(0), + QGenericArgument val0 = QGenericArgument(Q_NULLPTR), QGenericArgument val1 = QGenericArgument(), QGenericArgument val2 = QGenericArgument(), QGenericArgument val3 = QGenericArgument(), @@ -160,7 +160,7 @@ public: val0, val1, val2, val3, val4, val5, val6, val7, val8, val9); } - inline bool isValid() const { return mobj != 0; } + inline bool isValid() const { return mobj != Q_NULLPTR; } #ifdef Q_QDOC static QMetaMethod fromSignal(PointerToMemberFunction signal); @@ -204,7 +204,7 @@ inline bool operator!=(const QMetaMethod &m1, const QMetaMethod &m2) class Q_CORE_EXPORT QMetaEnum { public: - Q_DECL_CONSTEXPR inline QMetaEnum() : mobj(0),handle(0) {} + Q_DECL_CONSTEXPR inline QMetaEnum() : mobj(Q_NULLPTR), handle(0) {} const char *name() const; bool isFlag() const; @@ -215,14 +215,14 @@ public: const char *scope() const; - int keyToValue(const char *key, bool *ok = 0) const; + int keyToValue(const char *key, bool *ok = Q_NULLPTR) const; const char* valueToKey(int value) const; - int keysToValue(const char * keys, bool *ok = 0) const; + int keysToValue(const char * keys, bool *ok = Q_NULLPTR) const; QByteArray valueToKeys(int value) const; inline const QMetaObject *enclosingMetaObject() const { return mobj; } - inline bool isValid() const { return name() != 0; } + inline bool isValid() const { return name() != Q_NULLPTR; } template<typename T> static QMetaEnum fromType() { Q_STATIC_ASSERT_X(QtPrivate::IsQEnumHelper<T>::Value, @@ -253,11 +253,11 @@ public: bool isReadable() const; bool isWritable() const; bool isResettable() const; - bool isDesignable(const QObject *obj = 0) const; - bool isScriptable(const QObject *obj = 0) const; - bool isStored(const QObject *obj = 0) const; - bool isEditable(const QObject *obj = 0) const; - bool isUser(const QObject *obj = 0) const; + bool isDesignable(const QObject *obj = Q_NULLPTR) const; + bool isScriptable(const QObject *obj = Q_NULLPTR) const; + bool isStored(const QObject *obj = Q_NULLPTR) const; + bool isEditable(const QObject *obj = Q_NULLPTR) const; + bool isUser(const QObject *obj = Q_NULLPTR) const; bool isConstant() const; bool isFinal() const; @@ -297,7 +297,7 @@ private: class Q_CORE_EXPORT QMetaClassInfo { public: - Q_DECL_CONSTEXPR inline QMetaClassInfo() : mobj(0),handle(0) {} + Q_DECL_CONSTEXPR inline QMetaClassInfo() : mobj(Q_NULLPTR), handle(0) {} const char *name() const; const char *value() const; inline const QMetaObject *enclosingMetaObject() const { return mobj; } diff --git a/src/corelib/kernel/qmetaobjectbuilder.cpp b/src/corelib/kernel/qmetaobjectbuilder.cpp index a1b8125121..021e137273 100644 --- a/src/corelib/kernel/qmetaobjectbuilder.cpp +++ b/src/corelib/kernel/qmetaobjectbuilder.cpp @@ -88,6 +88,7 @@ static inline Q_DECL_UNUSED const QMetaObjectPrivate *priv(const uint* data) class QMetaMethodBuilderPrivate { public: + QMetaMethodBuilderPrivate() {} // for QVector, don't use QMetaMethodBuilderPrivate (QMetaMethod::MethodType _methodType, const QByteArray& _signature, @@ -139,10 +140,12 @@ public: return signature.left(qMax(signature.indexOf('('), 0)); } }; +Q_DECLARE_TYPEINFO(QMetaMethodBuilderPrivate, Q_MOVABLE_TYPE); class QMetaPropertyBuilderPrivate { public: + QMetaPropertyBuilderPrivate() {} // for QVector, don't use QMetaPropertyBuilderPrivate (const QByteArray& _name, const QByteArray& _type, int notifierIdx=-1, int _revision = 0) @@ -176,10 +179,12 @@ public: flags &= ~f; } }; +Q_DECLARE_TYPEINFO(QMetaPropertyBuilderPrivate, Q_MOVABLE_TYPE); class QMetaEnumBuilderPrivate { public: + QMetaEnumBuilderPrivate() {} // for QVector, don't use QMetaEnumBuilderPrivate(const QByteArray& _name) : name(_name), isFlag(false) { @@ -188,8 +193,9 @@ public: QByteArray name; bool isFlag; QList<QByteArray> keys; - QList<int> values; + QVector<int> values; }; +Q_DECLARE_TYPEINFO(QMetaEnumBuilderPrivate, Q_MOVABLE_TYPE); class QMetaObjectBuilderPrivate { @@ -207,12 +213,12 @@ public: QByteArray className; const QMetaObject *superClass; QMetaObjectBuilder::StaticMetacallFunction staticMetacallFunction; - QList<QMetaMethodBuilderPrivate> methods; - QList<QMetaMethodBuilderPrivate> constructors; - QList<QMetaPropertyBuilderPrivate> properties; + QVector<QMetaMethodBuilderPrivate> methods; + QVector<QMetaMethodBuilderPrivate> constructors; + QVector<QMetaPropertyBuilderPrivate> properties; QList<QByteArray> classInfoNames; QList<QByteArray> classInfoValues; - QList<QMetaEnumBuilderPrivate> enumerators; + QVector<QMetaEnumBuilderPrivate> enumerators; QList<const QMetaObject *> relatedMetaObjects; int flags; }; @@ -1149,7 +1155,7 @@ void QMetaStringTable::writeBlob(char *out) const // Returns the sum of all parameters (including return type) for the given // \a methods. This is needed for calculating the size of the methods' // parameter type/name meta-data. -static int aggregateParameterCount(const QList<QMetaMethodBuilderPrivate> &methods) +static int aggregateParameterCount(const QVector<QMetaMethodBuilderPrivate> &methods) { int sum = 0; for (int i = 0; i < methods.size(); ++i) @@ -1330,7 +1336,7 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf, Q_ASSERT(!buf || dataIndex == pmeta->methodData + d->methods.size() * 5 + (hasRevisionedMethods ? d->methods.size() : 0)); for (int x = 0; x < 2; ++x) { - QList<QMetaMethodBuilderPrivate> &methods = (x == 0) ? d->methods : d->constructors; + QVector<QMetaMethodBuilderPrivate> &methods = (x == 0) ? d->methods : d->constructors; for (index = 0; index < methods.size(); ++index) { QMetaMethodBuilderPrivate *method = &(methods[index]); QList<QByteArray> paramTypeNames = method->parameterTypes(); diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index 1b214e9f74..988630d90f 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -229,7 +229,7 @@ struct AbstractDebugStreamFunction { typedef void (*Stream)(const AbstractDebugStreamFunction *, QDebug&, const void *); typedef void (*Destroy)(AbstractDebugStreamFunction *); - explicit AbstractDebugStreamFunction(Stream s = 0, Destroy d = 0) + explicit AbstractDebugStreamFunction(Stream s = Q_NULLPTR, Destroy d = Q_NULLPTR) : stream(s), destroy(d) {} Q_DISABLE_COPY(AbstractDebugStreamFunction) Stream stream; @@ -259,7 +259,7 @@ struct AbstractComparatorFunction typedef bool (*LessThan)(const AbstractComparatorFunction *, const void *, const void *); typedef bool (*Equals)(const AbstractComparatorFunction *, const void *, const void *); typedef void (*Destroy)(AbstractComparatorFunction *); - explicit AbstractComparatorFunction(LessThan lt = 0, Equals e = 0, Destroy d = 0) + explicit AbstractComparatorFunction(LessThan lt = Q_NULLPTR, Equals e = Q_NULLPTR, Destroy d = Q_NULLPTR) : lessThan(lt), equals(e), destroy(d) {} Q_DISABLE_COPY(AbstractComparatorFunction) LessThan lessThan; @@ -296,7 +296,7 @@ template<typename T> struct BuiltInEqualsComparatorFunction : public AbstractComparatorFunction { BuiltInEqualsComparatorFunction() - : AbstractComparatorFunction(0, equals, destroy) {} + : AbstractComparatorFunction(Q_NULLPTR, equals, destroy) {} static bool equals(const AbstractComparatorFunction *, const void *l, const void *r) { const T *lhs = static_cast<const T *>(l); @@ -313,7 +313,7 @@ struct BuiltInEqualsComparatorFunction : public AbstractComparatorFunction struct AbstractConverterFunction { typedef bool (*Converter)(const AbstractConverterFunction *, const void *, void*); - explicit AbstractConverterFunction(Converter c = 0) + explicit AbstractConverterFunction(Converter c = Q_NULLPTR) : convert(c) {} Q_DISABLE_COPY(AbstractConverterFunction) Converter convert; @@ -510,9 +510,9 @@ public: static TypeFlags typeFlags(int type); static const QMetaObject *metaObjectForType(int type); static bool isRegistered(int type); - static void *create(int type, const void *copy = 0); + static void *create(int type, const void *copy = Q_NULLPTR); #if QT_DEPRECATED_SINCE(5, 0) - QT_DEPRECATED static void *construct(int type, const void *copy = 0) + QT_DEPRECATED static void *construct(int type, const void *copy = Q_NULLPTR) { return create(type, copy); } #endif static void destroy(int type, void *data); @@ -533,9 +533,9 @@ public: inline TypeFlags flags() const; inline const QMetaObject *metaObject() const; - inline void *create(const void *copy = 0) const; + inline void *create(const void *copy = Q_NULLPTR) const; inline void destroy(void *data) const; - inline void *construct(void *where, const void *copy = 0) const; + inline void *construct(void *where, const void *copy = Q_NULLPTR) const; inline void destruct(void *data) const; public: @@ -611,7 +611,7 @@ public: return registerConverterFunction(&f, fromTypeId, toTypeId); } - // member function as in "double QString::toDouble(bool *ok = 0) const" + // member function as in "double QString::toDouble(bool *ok = Q_NULLPTR) const" template<typename From, typename To> static bool registerConverter(To(From::*function)(bool*) const) { @@ -674,9 +674,9 @@ private: uint sizeExtended() const; QMetaType::TypeFlags flagsExtended() const; const QMetaObject *metaObjectExtended() const; - void *createExtended(const void *copy = 0) const; + void *createExtended(const void *copy = Q_NULLPTR) const; void destroyExtended(void *data) const; - void *constructExtended(void *where, const void *copy = 0) const; + void *constructExtended(void *where, const void *copy = Q_NULLPTR) const; void destructExtended(void *data) const; static bool registerComparatorFunction(const QtPrivate::AbstractComparatorFunction *f, int type); @@ -771,7 +771,7 @@ struct QMetaTypeFunctionHelper { template <typename T> struct QMetaTypeFunctionHelper<T, /* Accepted */ false> { static void Destruct(void *) {} - static void *Construct(void *, const void *) { return 0; } + static void *Construct(void *, const void *) { return Q_NULLPTR; } #ifndef QT_NO_DATASTREAM static void Save(QDataStream &, const void *) {} static void Load(QDataStream &, void *) {} @@ -1009,7 +1009,7 @@ public: public: template<class T> QSequentialIterableImpl(const T*p) : _iterable(p) - , _iterator(0) + , _iterator(Q_NULLPTR) , _metaType_id(qMetaTypeId<typename T::value_type>()) , _metaType_flags(QTypeInfo<typename T::value_type>::isPointer) , _iteratorCapabilities(ContainerAPI<T>::IteratorCapabilities) @@ -1026,20 +1026,20 @@ public: } QSequentialIterableImpl() - : _iterable(0) - , _iterator(0) + : _iterable(Q_NULLPTR) + , _iterator(Q_NULLPTR) , _metaType_id(QMetaType::UnknownType) , _metaType_flags(0) , _iteratorCapabilities(0) - , _size(0) - , _at(0) - , _moveToBegin(0) - , _moveToEnd(0) - , _advance(0) - , _get(0) - , _destroyIter(0) - , _equalIter(0) - , _copyIter(0) + , _size(Q_NULLPTR) + , _at(Q_NULLPTR) + , _moveToBegin(Q_NULLPTR) + , _moveToEnd(Q_NULLPTR) + , _advance(Q_NULLPTR) + , _get(Q_NULLPTR) + , _destroyIter(Q_NULLPTR) + , _equalIter(Q_NULLPTR) + , _copyIter(Q_NULLPTR) { } @@ -1195,21 +1195,21 @@ public: } QAssociativeIterableImpl() - : _iterable(0) + : _iterable(Q_NULLPTR) , _metaType_id_key(QMetaType::UnknownType) , _metaType_flags_key(0) , _metaType_id_value(QMetaType::UnknownType) , _metaType_flags_value(0) - , _size(0) - , _find(0) - , _begin(0) - , _end(0) - , _advance(0) - , _getKey(0) - , _getValue(0) - , _destroyIter(0) - , _equalIter(0) - , _copyIter(0) + , _size(Q_NULLPTR) + , _find(Q_NULLPTR) + , _begin(Q_NULLPTR) + , _end(Q_NULLPTR) + , _advance(Q_NULLPTR) + , _getKey(Q_NULLPTR) + , _getValue(Q_NULLPTR) + , _destroyIter(Q_NULLPTR) + , _equalIter(Q_NULLPTR) + , _copyIter(Q_NULLPTR) { } @@ -1277,9 +1277,9 @@ public: } QPairVariantInterfaceImpl() - : _pair(0) - , _getFirst(0) - , _getSecond(0) + : _pair(Q_NULLPTR) + , _getFirst(Q_NULLPTR) + , _getSecond(Q_NULLPTR) { } @@ -1354,7 +1354,7 @@ namespace QtPrivate #endif static no_type checkType(...); Q_STATIC_ASSERT_X(sizeof(T), "Type argument of Q_DECLARE_METATYPE(T*) must be fully defined"); - enum { Value = sizeof(checkType(static_cast<T*>(0))) == sizeof(yes_type) }; + enum { Value = sizeof(checkType(static_cast<T*>(Q_NULLPTR))) == sizeof(yes_type) }; }; template<typename T, typename Enable = void> @@ -1391,7 +1391,7 @@ QT_WARNING_POP template<typename T, typename Enable = void> struct MetaObjectForType { - static inline const QMetaObject *value() { return 0; } + static inline const QMetaObject *value() { return Q_NULLPTR; } }; template<> struct MetaObjectForType<void> @@ -1692,7 +1692,7 @@ int qRegisterNormalizedMetaType(const QT_PREPEND_NAMESPACE(QByteArray) &normaliz template <typename T> int qRegisterMetaType(const char *typeName #ifndef Q_QDOC - , T * dummy = 0 + , T * dummy = Q_NULLPTR , typename QtPrivate::MetaTypeDefinedHelper<T, QMetaTypeId2<T>::Defined && !QMetaTypeId2<T>::IsBuiltIn>::DefinedType defined = QtPrivate::MetaTypeDefinedHelper<T, QMetaTypeId2<T>::Defined && !QMetaTypeId2<T>::IsBuiltIn>::Defined #endif ) @@ -1709,7 +1709,7 @@ int qRegisterMetaType(const char *typeName template <typename T> void qRegisterMetaTypeStreamOperators(const char *typeName #ifndef Q_QDOC - , T * /* dummy */ = 0 + , T * /* dummy */ = Q_NULLPTR #endif ) { @@ -2095,7 +2095,7 @@ inline QMetaType::QMetaType(const ExtensionFlag extensionFlags, const QMetaTypeI , m_loadOp(loadOp) , m_constructor(constructor) , m_destructor(destructor) - , m_extension(0) + , m_extension(Q_NULLPTR) , m_size(size) , m_typeFlags(theTypeFlags) , m_extensionFlags(extensionFlags) diff --git a/src/corelib/kernel/qmimedata.cpp b/src/corelib/kernel/qmimedata.cpp index 3e9cdac966..93788afeae 100644 --- a/src/corelib/kernel/qmimedata.cpp +++ b/src/corelib/kernel/qmimedata.cpp @@ -354,7 +354,9 @@ void QMimeData::setUrls(const QList<QUrl> &urls) { Q_D(QMimeData); QList<QVariant> list; - for (int i = 0; i < urls.size(); ++i) + const int numUrls = urls.size(); + list.reserve(numUrls); + for (int i = 0; i < numUrls; ++i) list.append(urls.at(i)); d->setData(QLatin1String("text/uri-list"), list); diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 676a529dfe..c63dd79f02 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -47,7 +47,6 @@ #include <qthread.h> #include <private/qthread_p.h> #include <qdebug.h> -#include <qhash.h> #include <qpair.h> #include <qvarlengtharray.h> #include <qset.h> @@ -66,6 +65,16 @@ QT_BEGIN_NAMESPACE static int DIRECT_CONNECTION_ONLY = 0; + +QDynamicMetaObjectData::~QDynamicMetaObjectData() +{ +} + +QAbstractDynamicMetaObject::~QAbstractDynamicMetaObject() +{ +} + + struct QSlotObjectBaseDeleter { // for use with QScopedPointer<QSlotObjectBase,...> static void cleanup(QtPrivate::QSlotObjectBase *slot) { if (slot) slot->destroyIfLastRef(); diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h index 5f61dd984f..64c5b58fd4 100644 --- a/src/corelib/kernel/qobject.h +++ b/src/corelib/kernel/qobject.h @@ -110,23 +110,23 @@ class Q_CORE_EXPORT QObject Q_DECLARE_PRIVATE(QObject) public: - Q_INVOKABLE explicit QObject(QObject *parent=0); + Q_INVOKABLE explicit QObject(QObject *parent=Q_NULLPTR); virtual ~QObject(); virtual bool event(QEvent *); virtual bool eventFilter(QObject *, QEvent *); #ifdef Q_QDOC - static QString tr(const char *sourceText, const char *comment = 0, int n = -1); - static QString trUtf8(const char *sourceText, const char *comment = 0, int n = -1); + static QString tr(const char *sourceText, const char *comment = Q_NULLPTR, int n = -1); + static QString trUtf8(const char *sourceText, const char *comment = Q_NULLPTR, int n = -1); virtual const QMetaObject *metaObject() const; static const QMetaObject staticMetaObject; #endif #ifdef QT_NO_TRANSLATION - static QString tr(const char *sourceText, const char * = 0, int = -1) + static QString tr(const char *sourceText, const char * = Q_NULLPTR, int = -1) { return QString::fromUtf8(sourceText); } #if QT_DEPRECATED_SINCE(5, 0) - QT_DEPRECATED static QString trUtf8(const char *sourceText, const char * = 0, int = -1) + QT_DEPRECATED static QString trUtf8(const char *sourceText, const char * = Q_NULLPTR, int = -1) { return QString::fromUtf8(sourceText); } #endif #endif //QT_NO_TRANSLATION @@ -228,7 +228,7 @@ public: Q_STATIC_ASSERT_X((QtPrivate::AreArgumentsCompatible<typename SlotType::ReturnType, typename SignalType::ReturnType>::value), "Return type of the slot is not compatible with the return type of the signal."); - const int *types = 0; + const int *types = Q_NULLPTR; if (type == Qt::QueuedConnection || type == Qt::BlockingQueuedConnection) types = QtPrivate::ConnectionTypes<typename SignalType::Arguments>::types(); @@ -268,11 +268,11 @@ public: Q_STATIC_ASSERT_X((QtPrivate::AreArgumentsCompatible<typename SlotType::ReturnType, typename SignalType::ReturnType>::value), "Return type of the slot is not compatible with the return type of the signal."); - const int *types = 0; + const int *types = Q_NULLPTR; if (type == Qt::QueuedConnection || type == Qt::BlockingQueuedConnection) types = QtPrivate::ConnectionTypes<typename SignalType::Arguments>::types(); - return connectImpl(sender, reinterpret_cast<void **>(&signal), context, 0, + return connectImpl(sender, reinterpret_cast<void **>(&signal), context, Q_NULLPTR, new QtPrivate::QStaticSlotObject<Func2, typename QtPrivate::List_Left<typename SignalType::Arguments, SlotType::ArgumentCount>::Value, typename SignalType::ReturnType>(slot), @@ -338,11 +338,11 @@ public: Q_STATIC_ASSERT_X(QtPrivate::HasQ_OBJECT_Macro<typename SignalType::Object>::Value, "No Q_OBJECT in the class with the signal"); - const int *types = 0; + const int *types = Q_NULLPTR; if (type == Qt::QueuedConnection || type == Qt::BlockingQueuedConnection) types = QtPrivate::ConnectionTypes<typename SignalType::Arguments>::types(); - return connectImpl(sender, reinterpret_cast<void **>(&signal), context, 0, + return connectImpl(sender, reinterpret_cast<void **>(&signal), context, Q_NULLPTR, new QtPrivate::QFunctorSlotObject<Func2, SlotArgumentCount, typename QtPrivate::List_Left<typename SignalType::Arguments, SlotArgumentCount>::Value, typename SignalType::ReturnType>(slot), @@ -354,11 +354,11 @@ public: const QObject *receiver, const char *member); static bool disconnect(const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member); - inline bool disconnect(const char *signal = 0, - const QObject *receiver = 0, const char *member = 0) const + inline bool disconnect(const char *signal = Q_NULLPTR, + const QObject *receiver = Q_NULLPTR, const char *member = Q_NULLPTR) const { return disconnect(this, signal, receiver, member); } - inline bool disconnect(const QObject *receiver, const char *member = 0) const - { return disconnect(this, 0, receiver, member); } + inline bool disconnect(const QObject *receiver, const char *member = Q_NULLPTR) const + { return disconnect(this, Q_NULLPTR, receiver, member); } static bool disconnect(const QMetaObject::Connection &); #ifdef Q_QDOC @@ -385,7 +385,7 @@ public: static inline bool disconnect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, const QObject *receiver, void **zero) { - // This is the overload for when one wish to disconnect a signal from any slot. (slot=0) + // This is the overload for when one wish to disconnect a signal from any slot. (slot=Q_NULLPTR) // Since the function template parameter cannot be deduced from '0', we use a // dummy void ** parameter that must be equal to 0 Q_ASSERT(!zero); @@ -412,14 +412,14 @@ public: #endif // QT_NO_USERDATA Q_SIGNALS: - void destroyed(QObject * = 0); + void destroyed(QObject * = Q_NULLPTR); void objectNameChanged(const QString &objectName, QPrivateSignal); public: inline QObject *parent() const { return d_ptr->parent; } inline bool inherits(const char *classname) const - { return const_cast<QObject *>(this)->qt_metacast(classname) != 0; } + { return const_cast<QObject *>(this)->qt_metacast(classname) != Q_NULLPTR; } public Q_SLOTS: void deleteLater(); @@ -438,7 +438,7 @@ protected: virtual void disconnectNotify(const QMetaMethod &signal); protected: - QObject(QObjectPrivate &dd, QObject *parent = 0); + QObject(QObjectPrivate &dd, QObject *parent = Q_NULLPTR); protected: QScopedPointer<QObjectData> d_ptr; @@ -529,16 +529,16 @@ inline T qobject_cast(const QObject *object) template <class T> inline const char * qobject_interface_iid() -{ return 0; } +{ return Q_NULLPTR; } #ifndef Q_MOC_RUN # define Q_DECLARE_INTERFACE(IFace, IId) \ template <> inline const char *qobject_interface_iid<IFace *>() \ { return IId; } \ template <> inline IFace *qobject_cast<IFace *>(QObject *object) \ - { return reinterpret_cast<IFace *>((object ? object->qt_metacast(IId) : 0)); } \ + { return reinterpret_cast<IFace *>((object ? object->qt_metacast(IId) : Q_NULLPTR)); } \ template <> inline IFace *qobject_cast<IFace *>(const QObject *object) \ - { return reinterpret_cast<IFace *>((object ? const_cast<QObject *>(object)->qt_metacast(IId) : 0)); } + { return reinterpret_cast<IFace *>((object ? const_cast<QObject *>(object)->qt_metacast(IId) : Q_NULLPTR)); } #endif // Q_MOC_RUN #ifndef QT_NO_DEBUG_STREAM @@ -584,7 +584,7 @@ QSignalBlocker::QSignalBlocker(QSignalBlocker &&other) Q_DECL_NOTHROW m_blocked(other.m_blocked), m_inhibited(other.m_inhibited) { - other.m_o = 0; + other.m_o = Q_NULLPTR; } QSignalBlocker &QSignalBlocker::operator=(QSignalBlocker &&other) Q_DECL_NOTHROW @@ -598,7 +598,7 @@ QSignalBlocker &QSignalBlocker::operator=(QSignalBlocker &&other) Q_DECL_NOTHROW m_blocked = other.m_blocked; m_inhibited = other.m_inhibited; // disable other: - other.m_o = 0; + other.m_o = Q_NULLPTR; } return *this; } diff --git a/src/corelib/kernel/qobject_impl.h b/src/corelib/kernel/qobject_impl.h index 4d9e42ba76..09d52584c4 100644 --- a/src/corelib/kernel/qobject_impl.h +++ b/src/corelib/kernel/qobject_impl.h @@ -90,9 +90,9 @@ namespace QtPrivate { { enum { Value = QMetaTypeId2<Arg>::Defined && TypesAreDeclaredMetaType<List<Tail...>>::Value }; }; template <typename ArgList, bool Declared = TypesAreDeclaredMetaType<ArgList>::Value > struct ConnectionTypes - { static const int *types() { return 0; } }; + { static const int *types() { return Q_NULLPTR; } }; template <> struct ConnectionTypes<List<>, true> - { static const int *types() { return 0; } }; + { static const int *types() { return Q_NULLPTR; } }; template <typename... Args> struct ConnectionTypes<List<Args...>, true> { static const int *types() { static const int t[sizeof...(Args) + 1] = { (QtPrivate::QMetaTypeIdHelper<Args>::qt_metatype_id())..., 0 }; return t; } }; #endif @@ -118,10 +118,10 @@ namespace QtPrivate { inline int ref() Q_DECL_NOTHROW { return m_ref.ref(); } inline void destroyIfLastRef() Q_DECL_NOTHROW - { if (!m_ref.deref()) m_impl(Destroy, this, 0, 0, 0); } + { if (!m_ref.deref()) m_impl(Destroy, this, Q_NULLPTR, Q_NULLPTR, Q_NULLPTR); } - inline bool compare(void **a) { bool ret; m_impl(Compare, this, 0, a, &ret); return ret; } - inline void call(QObject *r, void **a) { m_impl(Call, this, r, a, 0); } + inline bool compare(void **a) { bool ret; m_impl(Compare, this, Q_NULLPTR, a, &ret); return ret; } + inline void call(QObject *r, void **a) { m_impl(Call, this, r, a, Q_NULLPTR); } protected: ~QSlotObjectBase() {} private: diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index 1b64103e40..bd5ee006bf 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -406,7 +406,7 @@ void Q_CORE_EXPORT qDeleteInEventHandler(QObject *o); struct QAbstractDynamicMetaObject; struct Q_CORE_EXPORT QDynamicMetaObjectData { - virtual ~QDynamicMetaObjectData() {} + virtual ~QDynamicMetaObjectData(); virtual void objectDestroyed(QObject *) { delete this; } virtual QAbstractDynamicMetaObject *toDynamicMetaObject(QObject *) = 0; @@ -415,6 +415,8 @@ struct Q_CORE_EXPORT QDynamicMetaObjectData struct Q_CORE_EXPORT QAbstractDynamicMetaObject : public QDynamicMetaObjectData, public QMetaObject { + ~QAbstractDynamicMetaObject(); + virtual QAbstractDynamicMetaObject *toDynamicMetaObject(QObject *) Q_DECL_OVERRIDE { return this; } virtual int createProperty(const char *, const char *) { return -1; } virtual int metaCall(QObject *, QMetaObject::Call c, int _id, void **a) Q_DECL_OVERRIDE diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h index 6484507a12..b1ed971eba 100644 --- a/src/corelib/kernel/qobjectdefs.h +++ b/src/corelib/kernel/qobjectdefs.h @@ -78,7 +78,11 @@ class QString; #define Q_CLASSINFO(name, value) #define Q_PLUGIN_METADATA(x) #define Q_INTERFACES(x) +#ifdef Q_COMPILER_VARIADIC_MACROS +#define Q_PROPERTY(...) +#else #define Q_PROPERTY(text) +#endif #define Q_PRIVATE_PROPERTY(d, text) #define Q_REVISION(v) #define Q_OVERRIDE(text) @@ -254,7 +258,7 @@ class QMetaClassInfo; class Q_CORE_EXPORT QGenericArgument { public: - inline QGenericArgument(const char *aName = 0, const void *aData = 0) + inline QGenericArgument(const char *aName = Q_NULLPTR, const void *aData = Q_NULLPTR) : _data(aData), _name(aName) {} inline void *data() const { return const_cast<void *>(_data); } inline const char *name() const { return _name; } @@ -267,7 +271,7 @@ private: class Q_CORE_EXPORT QGenericReturnArgument: public QGenericArgument { public: - inline QGenericReturnArgument(const char *aName = 0, void *aData = 0) + inline QGenericReturnArgument(const char *aName = Q_NULLPTR, void *aData = Q_NULLPTR) : QGenericArgument(aName, aData) {} }; @@ -347,7 +351,7 @@ struct Q_CORE_EXPORT QMetaObject // internal index-based connect static Connection connect(const QObject *sender, int signal_index, const QObject *receiver, int method_index, - int type = 0, int *types = 0); + int type = 0, int *types = Q_NULLPTR); // internal index-based disconnect static bool disconnect(const QObject *sender, int signal_index, const QObject *receiver, int method_index); @@ -364,7 +368,7 @@ struct Q_CORE_EXPORT QMetaObject static bool invokeMethod(QObject *obj, const char *member, Qt::ConnectionType, QGenericReturnArgument ret, - QGenericArgument val0 = QGenericArgument(0), + QGenericArgument val0 = QGenericArgument(Q_NULLPTR), QGenericArgument val1 = QGenericArgument(), QGenericArgument val2 = QGenericArgument(), QGenericArgument val3 = QGenericArgument(), @@ -377,7 +381,7 @@ struct Q_CORE_EXPORT QMetaObject static inline bool invokeMethod(QObject *obj, const char *member, QGenericReturnArgument ret, - QGenericArgument val0 = QGenericArgument(0), + QGenericArgument val0 = QGenericArgument(Q_NULLPTR), QGenericArgument val1 = QGenericArgument(), QGenericArgument val2 = QGenericArgument(), QGenericArgument val3 = QGenericArgument(), @@ -394,7 +398,7 @@ struct Q_CORE_EXPORT QMetaObject static inline bool invokeMethod(QObject *obj, const char *member, Qt::ConnectionType type, - QGenericArgument val0 = QGenericArgument(0), + QGenericArgument val0 = QGenericArgument(Q_NULLPTR), QGenericArgument val1 = QGenericArgument(), QGenericArgument val2 = QGenericArgument(), QGenericArgument val3 = QGenericArgument(), @@ -410,7 +414,7 @@ struct Q_CORE_EXPORT QMetaObject } static inline bool invokeMethod(QObject *obj, const char *member, - QGenericArgument val0 = QGenericArgument(0), + QGenericArgument val0 = QGenericArgument(Q_NULLPTR), QGenericArgument val1 = QGenericArgument(), QGenericArgument val2 = QGenericArgument(), QGenericArgument val3 = QGenericArgument(), @@ -425,7 +429,7 @@ struct Q_CORE_EXPORT QMetaObject val1, val2, val3, val4, val5, val6, val7, val8, val9); } - QObject *newInstance(QGenericArgument val0 = QGenericArgument(0), + QObject *newInstance(QGenericArgument val0 = QGenericArgument(Q_NULLPTR), QGenericArgument val1 = QGenericArgument(), QGenericArgument val2 = QGenericArgument(), QGenericArgument val3 = QGenericArgument(), @@ -482,11 +486,11 @@ public: operator bool() const; #else typedef void *Connection::*RestrictedBool; - operator RestrictedBool() const { return d_ptr && isConnected_helper() ? &Connection::d_ptr : 0; } + operator RestrictedBool() const { return d_ptr && isConnected_helper() ? &Connection::d_ptr : Q_NULLPTR; } #endif #ifdef Q_COMPILER_RVALUE_REFS - inline Connection(Connection &&o) : d_ptr(o.d_ptr) { o.d_ptr = 0; } + inline Connection(Connection &&o) : d_ptr(o.d_ptr) { o.d_ptr = Q_NULLPTR; } inline Connection &operator=(Connection &&other) { qSwap(d_ptr, other.d_ptr); return *this; } #endif diff --git a/src/corelib/kernel/qpointer.cpp b/src/corelib/kernel/qpointer.cpp index 2c872716d1..39cc17f7dd 100644 --- a/src/corelib/kernel/qpointer.cpp +++ b/src/corelib/kernel/qpointer.cpp @@ -128,6 +128,14 @@ */ /*! + \fn void QPointer::swap(QPointer<T> &other) + \since 5.6 + + Swaps the contents of this QPointer with the contents of \a other. + This operation is very fast and never fails. +*/ + +/*! \fn QPointer<T> & QPointer::operator=(T* p) Assignment operator. This guarded pointer will now point to the diff --git a/src/corelib/kernel/qpointer.h b/src/corelib/kernel/qpointer.h index af7c11e4d7..a3e922ccc9 100644 --- a/src/corelib/kernel/qpointer.h +++ b/src/corelib/kernel/qpointer.h @@ -35,6 +35,7 @@ #define QPOINTER_H #include <QtCore/qsharedpointer.h> +#include <QtCore/qtypeinfo.h> #ifndef QT_NO_QOBJECT @@ -45,6 +46,8 @@ 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"); + template<typename U> struct TypeSelector { @@ -63,6 +66,8 @@ public: // compiler-generated copy/move ctor/assignment operators are fine! inline ~QPointer() { } + inline void swap(QPointer &other) { wp.swap(other.wp); } + inline QPointer<T> &operator=(T* p) { wp.assign(static_cast<QObjectType*>(p)); return *this; } diff --git a/src/corelib/kernel/qsharedmemory.h b/src/corelib/kernel/qsharedmemory.h index c192910dc7..67558e3348 100644 --- a/src/corelib/kernel/qsharedmemory.h +++ b/src/corelib/kernel/qsharedmemory.h @@ -68,8 +68,8 @@ public: UnknownError }; - QSharedMemory(QObject *parent = 0); - QSharedMemory(const QString &key, QObject *parent = 0); + QSharedMemory(QObject *parent = Q_NULLPTR); + QSharedMemory(const QString &key, QObject *parent = Q_NULLPTR); ~QSharedMemory(); void setKey(const QString &key); diff --git a/src/corelib/kernel/qsignalmapper.h b/src/corelib/kernel/qsignalmapper.h index df2a0a52ea..7aaef6affc 100644 --- a/src/corelib/kernel/qsignalmapper.h +++ b/src/corelib/kernel/qsignalmapper.h @@ -45,7 +45,7 @@ class Q_CORE_EXPORT QSignalMapper : public QObject Q_OBJECT Q_DECLARE_PRIVATE(QSignalMapper) public: - explicit QSignalMapper(QObject *parent = 0); + explicit QSignalMapper(QObject *parent = Q_NULLPTR); ~QSignalMapper(); void setMapping(QObject *sender, int id); diff --git a/src/corelib/kernel/qsocketnotifier.h b/src/corelib/kernel/qsocketnotifier.h index 4bafbfa69f..8a7af6ebbc 100644 --- a/src/corelib/kernel/qsocketnotifier.h +++ b/src/corelib/kernel/qsocketnotifier.h @@ -47,7 +47,7 @@ class Q_CORE_EXPORT QSocketNotifier : public QObject public: enum Type { Read, Write, Exception }; - QSocketNotifier(qintptr socket, Type, QObject *parent = 0); + QSocketNotifier(qintptr socket, Type, QObject *parent = Q_NULLPTR); ~QSocketNotifier(); qintptr socket() const; diff --git a/src/corelib/kernel/qsystemerror.cpp b/src/corelib/kernel/qsystemerror.cpp index 19d84c2b3e..e333104add 100644 --- a/src/corelib/kernel/qsystemerror.cpp +++ b/src/corelib/kernel/qsystemerror.cpp @@ -145,7 +145,7 @@ static QString standardLibraryErrorString(int errorCode) return ret.trimmed(); } -QString QSystemError::toString() +QString QSystemError::toString() const { switch(errorScope) { case NativeError: diff --git a/src/corelib/kernel/qsystemerror_p.h b/src/corelib/kernel/qsystemerror_p.h index e7efb9bbf3..29e9e440e4 100644 --- a/src/corelib/kernel/qsystemerror_p.h +++ b/src/corelib/kernel/qsystemerror_p.h @@ -62,9 +62,9 @@ public: inline QSystemError(int error, ErrorScope scope); inline QSystemError(); - QString toString(); - inline ErrorScope scope(); - inline int error(); + QString toString() const; + inline ErrorScope scope() const; + inline int error() const; //data members int errorCode; @@ -83,12 +83,12 @@ QSystemError::QSystemError() } -QSystemError::ErrorScope QSystemError::scope() +QSystemError::ErrorScope QSystemError::scope() const { return errorScope; } -int QSystemError::error() +int QSystemError::error() const { return errorCode; } diff --git a/src/corelib/kernel/qsystemsemaphore_win.cpp b/src/corelib/kernel/qsystemsemaphore_win.cpp index ca55025c2a..89b8a87f2a 100644 --- a/src/corelib/kernel/qsystemsemaphore_win.cpp +++ b/src/corelib/kernel/qsystemsemaphore_win.cpp @@ -115,7 +115,7 @@ bool QSystemSemaphorePrivate::modifySemaphore(int count) return false; } } else { -#if defined(Q_OS_WINRT) +#if !defined(Q_OS_WINCE) if (WAIT_OBJECT_0 != WaitForSingleObjectEx(semaphore, INFINITE, FALSE)) { #else if (WAIT_OBJECT_0 != WaitForSingleObject(semaphore, INFINITE)) { diff --git a/src/corelib/kernel/qtimer.h b/src/corelib/kernel/qtimer.h index 163ef75291..56f8a1a177 100644 --- a/src/corelib/kernel/qtimer.h +++ b/src/corelib/kernel/qtimer.h @@ -53,7 +53,7 @@ class Q_CORE_EXPORT QTimer : public QObject Q_PROPERTY(Qt::TimerType timerType READ timerType WRITE setTimerType) Q_PROPERTY(bool active READ isActive) public: - explicit QTimer(QObject *parent = 0); + explicit QTimer(QObject *parent = Q_NULLPTR); ~QTimer(); inline bool isActive() const { return id >= 0; } diff --git a/src/corelib/kernel/qtranslator.cpp b/src/corelib/kernel/qtranslator.cpp index a405df567f..ef74b4bdd1 100644 --- a/src/corelib/kernel/qtranslator.cpp +++ b/src/corelib/kernel/qtranslator.cpp @@ -46,7 +46,6 @@ #include "qfile.h" #include "qmap.h" #include "qalgorithms.h" -#include "qhash.h" #include "qtranslator_p.h" #include "qlocale.h" #include "qendian.h" diff --git a/src/corelib/kernel/qtranslator.h b/src/corelib/kernel/qtranslator.h index 1552bbde35..78f714c5c6 100644 --- a/src/corelib/kernel/qtranslator.h +++ b/src/corelib/kernel/qtranslator.h @@ -49,11 +49,11 @@ class Q_CORE_EXPORT QTranslator : public QObject { Q_OBJECT public: - explicit QTranslator(QObject *parent = 0); + explicit QTranslator(QObject *parent = Q_NULLPTR); ~QTranslator(); virtual QString translate(const char *context, const char *sourceText, - const char *disambiguation = 0, int n = -1) const; + const char *disambiguation = Q_NULLPTR, int n = -1) const; virtual bool isEmpty() const; diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h index 58dfc3aab0..bb996af121 100644 --- a/src/corelib/kernel/qvariant.h +++ b/src/corelib/kernel/qvariant.h @@ -278,14 +278,14 @@ class Q_CORE_EXPORT QVariant void detach(); inline bool isDetached() const; - int toInt(bool *ok = 0) const; - uint toUInt(bool *ok = 0) const; - qlonglong toLongLong(bool *ok = 0) const; - qulonglong toULongLong(bool *ok = 0) const; + int toInt(bool *ok = Q_NULLPTR) const; + uint toUInt(bool *ok = Q_NULLPTR) const; + qlonglong toLongLong(bool *ok = Q_NULLPTR) const; + qulonglong toULongLong(bool *ok = Q_NULLPTR) const; bool toBool() const; - double toDouble(bool *ok = 0) const; - float toFloat(bool *ok = 0) const; - qreal toReal(bool *ok = 0) const; + double toDouble(bool *ok = Q_NULLPTR) const; + float toFloat(bool *ok = Q_NULLPTR) const; + qreal toReal(bool *ok = Q_NULLPTR) const; QByteArray toByteArray() const; QBitArray toBitArray() const; QString toString() const; @@ -364,7 +364,7 @@ class Q_CORE_EXPORT QVariant struct Private { inline Private() Q_DECL_NOTHROW : type(Invalid), is_shared(false), is_null(true) - { data.ptr = 0; } + { data.ptr = Q_NULLPTR; } // Internal constructor for initialized variants. explicit inline Private(uint variantType) Q_DECL_NOTHROW |