diff options
Diffstat (limited to 'src/corelib')
175 files changed, 1462 insertions, 1194 deletions
diff --git a/src/corelib/animation/qabstractanimation.h b/src/corelib/animation/qabstractanimation.h index 727b4e7777..0ff6bc5176 100644 --- a/src/corelib/animation/qabstractanimation.h +++ b/src/corelib/animation/qabstractanimation.h @@ -82,7 +82,7 @@ public: DeleteWhenStopped }; - QAbstractAnimation(QObject *parent = Q_NULLPTR); + QAbstractAnimation(QObject *parent = nullptr); virtual ~QAbstractAnimation(); State state() const; @@ -117,8 +117,8 @@ public Q_SLOTS: void setCurrentTime(int msecs); protected: - QAbstractAnimation(QAbstractAnimationPrivate &dd, QObject *parent = Q_NULLPTR); - bool event(QEvent *event) Q_DECL_OVERRIDE; + QAbstractAnimation(QAbstractAnimationPrivate &dd, QObject *parent = nullptr); + bool event(QEvent *event) override; virtual void updateCurrentTime(int currentTime) = 0; virtual void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState); @@ -136,7 +136,7 @@ class Q_CORE_EXPORT QAnimationDriver : public QObject Q_DECLARE_PRIVATE(QAnimationDriver) public: - QAnimationDriver(QObject *parent = Q_NULLPTR); + QAnimationDriver(QObject *parent = nullptr); ~QAnimationDriver(); virtual void advance(); @@ -162,7 +162,7 @@ protected: virtual void start(); virtual void stop(); - QAnimationDriver(QAnimationDriverPrivate &dd, QObject *parent = Q_NULLPTR); + QAnimationDriver(QAnimationDriverPrivate &dd, QObject *parent = nullptr); private: friend class QUnifiedTimer; diff --git a/src/corelib/animation/qabstractanimation_p.h b/src/corelib/animation/qabstractanimation_p.h index 3b901c4426..5593046e48 100644 --- a/src/corelib/animation/qabstractanimation_p.h +++ b/src/corelib/animation/qabstractanimation_p.h @@ -116,7 +116,7 @@ class QDefaultAnimationDriver : public QAnimationDriver Q_OBJECT public: QDefaultAnimationDriver(QUnifiedTimer *timer); - void timerEvent(QTimerEvent *e) Q_DECL_OVERRIDE; + void timerEvent(QTimerEvent *e) override; private Q_SLOTS: void startTimer(); @@ -196,7 +196,7 @@ public: qint64 elapsed() const; protected: - void timerEvent(QTimerEvent *) Q_DECL_OVERRIDE; + void timerEvent(QTimerEvent *) override; private Q_SLOTS: void startTimers(); @@ -265,11 +265,11 @@ public: */ static void updateAnimationTimer(); - void restartAnimationTimer() Q_DECL_OVERRIDE; - void updateAnimationsTime(qint64 delta) Q_DECL_OVERRIDE; + void restartAnimationTimer() override; + void updateAnimationsTime(qint64 delta) override; //useful for profiling/debugging - int runningAnimationCount() Q_DECL_OVERRIDE { return animations.count(); } + int runningAnimationCount() override { return animations.count(); } private Q_SLOTS: void startAnimations(); diff --git a/src/corelib/animation/qanimationgroup.h b/src/corelib/animation/qanimationgroup.h index 20be0c0dd4..136ad3ca9f 100644 --- a/src/corelib/animation/qanimationgroup.h +++ b/src/corelib/animation/qanimationgroup.h @@ -53,7 +53,7 @@ class Q_CORE_EXPORT QAnimationGroup : public QAbstractAnimation Q_OBJECT public: - QAnimationGroup(QObject *parent = Q_NULLPTR); + QAnimationGroup(QObject *parent = nullptr); ~QAnimationGroup(); QAbstractAnimation *animationAt(int index) const; @@ -67,7 +67,7 @@ public: protected: QAnimationGroup(QAnimationGroupPrivate &dd, QObject *parent); - bool event(QEvent *event) Q_DECL_OVERRIDE; + bool event(QEvent *event) override; private: Q_DISABLE_COPY(QAnimationGroup) diff --git a/src/corelib/animation/qparallelanimationgroup.h b/src/corelib/animation/qparallelanimationgroup.h index 3a00e9fd12..09a439ef24 100644 --- a/src/corelib/animation/qparallelanimationgroup.h +++ b/src/corelib/animation/qparallelanimationgroup.h @@ -53,18 +53,18 @@ class Q_CORE_EXPORT QParallelAnimationGroup : public QAnimationGroup Q_OBJECT public: - QParallelAnimationGroup(QObject *parent = Q_NULLPTR); + QParallelAnimationGroup(QObject *parent = nullptr); ~QParallelAnimationGroup(); - int duration() const Q_DECL_OVERRIDE; + int duration() const override; protected: QParallelAnimationGroup(QParallelAnimationGroupPrivate &dd, QObject *parent); - bool event(QEvent *event) Q_DECL_OVERRIDE; + bool event(QEvent *event) override; - void updateCurrentTime(int currentTime) Q_DECL_OVERRIDE; - void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState) Q_DECL_OVERRIDE; - void updateDirection(QAbstractAnimation::Direction direction) Q_DECL_OVERRIDE; + void updateCurrentTime(int currentTime) override; + void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState) override; + void updateDirection(QAbstractAnimation::Direction direction) override; private: Q_DISABLE_COPY(QParallelAnimationGroup) diff --git a/src/corelib/animation/qparallelanimationgroup_p.h b/src/corelib/animation/qparallelanimationgroup_p.h index 069ba8e51a..1c9c3072f7 100644 --- a/src/corelib/animation/qparallelanimationgroup_p.h +++ b/src/corelib/animation/qparallelanimationgroup_p.h @@ -78,7 +78,7 @@ public: void connectUncontrolledAnimations(); void disconnectUncontrolledAnimations(); - void animationRemoved(int index, QAbstractAnimation *) Q_DECL_OVERRIDE; + void animationRemoved(int index, QAbstractAnimation *) override; // private slot void _q_uncontrolledAnimationFinished(); diff --git a/src/corelib/animation/qpauseanimation.h b/src/corelib/animation/qpauseanimation.h index c077164beb..e2095a39d6 100644 --- a/src/corelib/animation/qpauseanimation.h +++ b/src/corelib/animation/qpauseanimation.h @@ -54,16 +54,16 @@ class Q_CORE_EXPORT QPauseAnimation : public QAbstractAnimation Q_OBJECT Q_PROPERTY(int duration READ duration WRITE setDuration) public: - QPauseAnimation(QObject *parent = Q_NULLPTR); - QPauseAnimation(int msecs, QObject *parent = Q_NULLPTR); + QPauseAnimation(QObject *parent = nullptr); + QPauseAnimation(int msecs, QObject *parent = nullptr); ~QPauseAnimation(); - int duration() const Q_DECL_OVERRIDE; + int duration() const override; void setDuration(int msecs); protected: - bool event(QEvent *e) Q_DECL_OVERRIDE; - void updateCurrentTime(int) Q_DECL_OVERRIDE; + bool event(QEvent *e) override; + void updateCurrentTime(int) override; private: Q_DISABLE_COPY(QPauseAnimation) diff --git a/src/corelib/animation/qpropertyanimation.h b/src/corelib/animation/qpropertyanimation.h index ecc7524884..3270591d1d 100644 --- a/src/corelib/animation/qpropertyanimation.h +++ b/src/corelib/animation/qpropertyanimation.h @@ -55,8 +55,8 @@ class Q_CORE_EXPORT QPropertyAnimation : public QVariantAnimation Q_PROPERTY(QObject* targetObject READ targetObject WRITE setTargetObject) public: - QPropertyAnimation(QObject *parent = Q_NULLPTR); - QPropertyAnimation(QObject *target, const QByteArray &propertyName, QObject *parent = Q_NULLPTR); + QPropertyAnimation(QObject *parent = nullptr); + QPropertyAnimation(QObject *target, const QByteArray &propertyName, QObject *parent = nullptr); ~QPropertyAnimation(); QObject *targetObject() const; @@ -66,9 +66,9 @@ public: void setPropertyName(const QByteArray &propertyName); protected: - bool event(QEvent *event) Q_DECL_OVERRIDE; - void updateCurrentValue(const QVariant &value) Q_DECL_OVERRIDE; - void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState) Q_DECL_OVERRIDE; + bool event(QEvent *event) override; + void updateCurrentValue(const QVariant &value) override; + void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState) override; private: Q_DISABLE_COPY(QPropertyAnimation) diff --git a/src/corelib/animation/qsequentialanimationgroup.h b/src/corelib/animation/qsequentialanimationgroup.h index 3caf93b054..1c8e67d256 100644 --- a/src/corelib/animation/qsequentialanimationgroup.h +++ b/src/corelib/animation/qsequentialanimationgroup.h @@ -56,25 +56,25 @@ class Q_CORE_EXPORT QSequentialAnimationGroup : public QAnimationGroup Q_PROPERTY(QAbstractAnimation* currentAnimation READ currentAnimation NOTIFY currentAnimationChanged) public: - QSequentialAnimationGroup(QObject *parent = Q_NULLPTR); + QSequentialAnimationGroup(QObject *parent = nullptr); ~QSequentialAnimationGroup(); QPauseAnimation *addPause(int msecs); QPauseAnimation *insertPause(int index, int msecs); QAbstractAnimation *currentAnimation() const; - int duration() const Q_DECL_OVERRIDE; + int duration() const override; Q_SIGNALS: void currentAnimationChanged(QAbstractAnimation *current); protected: QSequentialAnimationGroup(QSequentialAnimationGroupPrivate &dd, QObject *parent); - bool event(QEvent *event) Q_DECL_OVERRIDE; + bool event(QEvent *event) override; - void updateCurrentTime(int) Q_DECL_OVERRIDE; - void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState) Q_DECL_OVERRIDE; - void updateDirection(QAbstractAnimation::Direction direction) Q_DECL_OVERRIDE; + void updateCurrentTime(int) override; + void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState) override; + void updateDirection(QAbstractAnimation::Direction direction) override; private: Q_DISABLE_COPY(QSequentialAnimationGroup) diff --git a/src/corelib/animation/qsequentialanimationgroup_p.h b/src/corelib/animation/qsequentialanimationgroup_p.h index 1b07e1330a..e4f3d9c96a 100644 --- a/src/corelib/animation/qsequentialanimationgroup_p.h +++ b/src/corelib/animation/qsequentialanimationgroup_p.h @@ -82,8 +82,8 @@ public: void setCurrentAnimation(int index, bool intermediate = false); void activateCurrentAnimation(bool intermediate = false); - void animationInsertedAt(int index) Q_DECL_OVERRIDE; - void animationRemoved(int index, QAbstractAnimation *anim) Q_DECL_OVERRIDE; + void animationInsertedAt(int index) override; + void animationRemoved(int index, QAbstractAnimation *anim) override; bool atEnd() const; diff --git a/src/corelib/animation/qvariantanimation.h b/src/corelib/animation/qvariantanimation.h index f21832b256..ed38979ad0 100644 --- a/src/corelib/animation/qvariantanimation.h +++ b/src/corelib/animation/qvariantanimation.h @@ -65,7 +65,7 @@ public: typedef QPair<qreal, QVariant> KeyValue; typedef QVector<KeyValue> KeyValues; - QVariantAnimation(QObject *parent = Q_NULLPTR); + QVariantAnimation(QObject *parent = nullptr); ~QVariantAnimation(); QVariant startValue() const; @@ -82,7 +82,7 @@ public: QVariant currentValue() const; - int duration() const Q_DECL_OVERRIDE; + int duration() const override; void setDuration(int msecs); QEasingCurve easingCurve() const; @@ -94,11 +94,11 @@ Q_SIGNALS: void valueChanged(const QVariant &value); protected: - QVariantAnimation(QVariantAnimationPrivate &dd, QObject *parent = Q_NULLPTR); - bool event(QEvent *event) Q_DECL_OVERRIDE; + QVariantAnimation(QVariantAnimationPrivate &dd, QObject *parent = nullptr); + bool event(QEvent *event) override; - void updateCurrentTime(int) Q_DECL_OVERRIDE; - void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState) Q_DECL_OVERRIDE; + void updateCurrentTime(int) override; + void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState) override; virtual void updateCurrentValue(const QVariant &value); virtual QVariant interpolated(const QVariant &from, const QVariant &to, qreal progress) const; diff --git a/src/corelib/arch/qatomic_cxx11.h b/src/corelib/arch/qatomic_cxx11.h index 1404849382..2fc0bf5419 100644 --- a/src/corelib/arch/qatomic_cxx11.h +++ b/src/corelib/arch/qatomic_cxx11.h @@ -276,7 +276,7 @@ template <typename X> struct QAtomicOps static inline Q_DECL_CONSTEXPR bool isTestAndSetWaitFree() Q_DECL_NOTHROW { return false; } template <typename T> - static bool testAndSetRelaxed(std::atomic<T> &_q_value, T expectedValue, T newValue, T *currentValue = Q_NULLPTR) Q_DECL_NOTHROW + static bool testAndSetRelaxed(std::atomic<T> &_q_value, T expectedValue, T newValue, T *currentValue = nullptr) Q_DECL_NOTHROW { bool tmp = _q_value.compare_exchange_strong(expectedValue, newValue, std::memory_order_relaxed, std::memory_order_relaxed); if (currentValue) @@ -285,7 +285,7 @@ template <typename X> struct QAtomicOps } template <typename T> - static bool testAndSetAcquire(std::atomic<T> &_q_value, T expectedValue, T newValue, T *currentValue = Q_NULLPTR) Q_DECL_NOTHROW + static bool testAndSetAcquire(std::atomic<T> &_q_value, T expectedValue, T newValue, T *currentValue = nullptr) Q_DECL_NOTHROW { bool tmp = _q_value.compare_exchange_strong(expectedValue, newValue, std::memory_order_acquire, std::memory_order_acquire); if (currentValue) @@ -294,7 +294,7 @@ template <typename X> struct QAtomicOps } template <typename T> - static bool testAndSetRelease(std::atomic<T> &_q_value, T expectedValue, T newValue, T *currentValue = Q_NULLPTR) Q_DECL_NOTHROW + static bool testAndSetRelease(std::atomic<T> &_q_value, T expectedValue, T newValue, T *currentValue = nullptr) Q_DECL_NOTHROW { bool tmp = _q_value.compare_exchange_strong(expectedValue, newValue, std::memory_order_release, std::memory_order_relaxed); if (currentValue) @@ -303,7 +303,7 @@ template <typename X> struct QAtomicOps } template <typename T> - static bool testAndSetOrdered(std::atomic<T> &_q_value, T expectedValue, T newValue, T *currentValue = Q_NULLPTR) Q_DECL_NOTHROW + static bool testAndSetOrdered(std::atomic<T> &_q_value, T expectedValue, T newValue, T *currentValue = nullptr) Q_DECL_NOTHROW { bool tmp = _q_value.compare_exchange_strong(expectedValue, newValue, std::memory_order_acq_rel, std::memory_order_acquire); if (currentValue) diff --git a/src/corelib/codecs/qiconvcodec.cpp b/src/corelib/codecs/qiconvcodec.cpp index d6362b6fbc..330eb7c038 100644 --- a/src/corelib/codecs/qiconvcodec.cpp +++ b/src/corelib/codecs/qiconvcodec.cpp @@ -53,7 +53,7 @@ QT_REQUIRE_CONFIG(iconv); // unistd.h is needed for the _XOPEN_UNIX macro #include <unistd.h> -#if defined(_XOPEN_UNIX) && !defined(Q_OS_QNX) && !defined(Q_OS_OSF) +#if defined(_XOPEN_UNIX) && !defined(Q_OS_QNX) # include <langinfo.h> #endif @@ -447,7 +447,7 @@ iconv_t QIconvCodec::createIconv_t(const char *to, const char *from) const char *codeset = 0; #endif -#if defined(_XOPEN_UNIX) && !defined(Q_OS_QNX) && !defined(Q_OS_OSF) +#if defined(_XOPEN_UNIX) && !defined(Q_OS_QNX) if (cd == (iconv_t) -1) { codeset = nl_langinfo(CODESET); if (codeset) diff --git a/src/corelib/codecs/qicucodec_p.h b/src/corelib/codecs/qicucodec_p.h index 3a373ce5b3..0c2dbe17d6 100644 --- a/src/corelib/codecs/qicucodec_p.h +++ b/src/corelib/codecs/qicucodec_p.h @@ -74,12 +74,12 @@ public: static QTextCodec *codecForNameUnlocked(const char *name); static QTextCodec *codecForMibUnlocked(int mib); - QString convertToUnicode(const char *, int, ConverterState *) const Q_DECL_OVERRIDE; - QByteArray convertFromUnicode(const QChar *, int, ConverterState *) const Q_DECL_OVERRIDE; + QString convertToUnicode(const char *, int, ConverterState *) const override; + QByteArray convertFromUnicode(const QChar *, int, ConverterState *) const override; - QByteArray name() const Q_DECL_OVERRIDE; - QList<QByteArray> aliases() const Q_DECL_OVERRIDE; - int mibEnum() const Q_DECL_OVERRIDE; + QByteArray name() const override; + QList<QByteArray> aliases() const override; + int mibEnum() const override; private: QIcuCodec(const char *name); diff --git a/src/corelib/codecs/qisciicodec_p.h b/src/corelib/codecs/qisciicodec_p.h index f92c0091ce..f818e7d83e 100644 --- a/src/corelib/codecs/qisciicodec_p.h +++ b/src/corelib/codecs/qisciicodec_p.h @@ -65,11 +65,11 @@ public: static QTextCodec *create(const char *name); - QByteArray name() const Q_DECL_OVERRIDE; - int mibEnum() const Q_DECL_OVERRIDE; + QByteArray name() const override; + int mibEnum() const override; - QString convertToUnicode(const char *, int, ConverterState *) const Q_DECL_OVERRIDE; - QByteArray convertFromUnicode(const QChar *, int, ConverterState *) const Q_DECL_OVERRIDE; + QString convertToUnicode(const char *, int, ConverterState *) const override; + QByteArray convertFromUnicode(const QChar *, int, ConverterState *) const override; private: int idx; diff --git a/src/corelib/codecs/qlatincodec_p.h b/src/corelib/codecs/qlatincodec_p.h index 1042c3b80d..3e258e5ae1 100644 --- a/src/corelib/codecs/qlatincodec_p.h +++ b/src/corelib/codecs/qlatincodec_p.h @@ -63,12 +63,12 @@ class QLatin1Codec : public QTextCodec public: ~QLatin1Codec(); - QString convertToUnicode(const char *, int, ConverterState *) const Q_DECL_OVERRIDE; - QByteArray convertFromUnicode(const QChar *, int, ConverterState *) const Q_DECL_OVERRIDE; + QString convertToUnicode(const char *, int, ConverterState *) const override; + QByteArray convertFromUnicode(const QChar *, int, ConverterState *) const override; - QByteArray name() const Q_DECL_OVERRIDE; - QList<QByteArray> aliases() const Q_DECL_OVERRIDE; - int mibEnum() const Q_DECL_OVERRIDE; + QByteArray name() const override; + QList<QByteArray> aliases() const override; + int mibEnum() const override; }; @@ -78,12 +78,12 @@ class QLatin15Codec: public QTextCodec public: ~QLatin15Codec(); - QString convertToUnicode(const char *, int, ConverterState *) const Q_DECL_OVERRIDE; - QByteArray convertFromUnicode(const QChar *, int, ConverterState *) const Q_DECL_OVERRIDE; + QString convertToUnicode(const char *, int, ConverterState *) const override; + QByteArray convertFromUnicode(const QChar *, int, ConverterState *) const override; - QByteArray name() const Q_DECL_OVERRIDE; - QList<QByteArray> aliases() const Q_DECL_OVERRIDE; - int mibEnum() const Q_DECL_OVERRIDE; + QByteArray name() const override; + QList<QByteArray> aliases() const override; + int mibEnum() const override; }; #endif // QT_NO_TEXTCODEC diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp index 4f0cd914ca..1541c498e6 100644 --- a/src/corelib/codecs/qtextcodec.cpp +++ b/src/corelib/codecs/qtextcodec.cpp @@ -88,7 +88,7 @@ #include <stdlib.h> #include <ctype.h> #include <locale.h> -#if defined (_XOPEN_UNIX) && !defined(Q_OS_QNX) && !defined(Q_OS_OSF) && !defined(Q_OS_ANDROID) +#if defined (_XOPEN_UNIX) && !defined(Q_OS_QNX) && !defined(Q_OS_ANDROID) # include <langinfo.h> #endif @@ -180,7 +180,7 @@ static QTextCodec *setupLocaleMapper() // This is because the builtin utf8 codec is around 5 times faster // then the using QIconvCodec -#if defined (_XOPEN_UNIX) && !defined(Q_OS_OSF) +#if defined (_XOPEN_UNIX) char *charset = nl_langinfo(CODESET); if (charset) locale = QTextCodec::codecForName(charset); diff --git a/src/corelib/codecs/qtextcodec.h b/src/corelib/codecs/qtextcodec.h index 5163d37238..8153bebac8 100644 --- a/src/corelib/codecs/qtextcodec.h +++ b/src/corelib/codecs/qtextcodec.h @@ -100,7 +100,7 @@ public: struct Q_CORE_EXPORT ConverterState { ConverterState(ConversionFlags f = DefaultConversion) - : flags(f), remainingChars(0), invalidChars(0), d(Q_NULLPTR) { state_data[0] = state_data[1] = state_data[2] = 0; } + : flags(f), remainingChars(0), invalidChars(0), d(nullptr) { state_data[0] = state_data[1] = state_data[2] = 0; } ~ConverterState(); ConversionFlags flags; int remainingChars; @@ -111,9 +111,9 @@ public: Q_DISABLE_COPY(ConverterState) }; - QString toUnicode(const char *in, int length, ConverterState *state = Q_NULLPTR) const + QString toUnicode(const char *in, int length, ConverterState *state = nullptr) const { return convertToUnicode(in, length, state); } - QByteArray fromUnicode(const QChar *in, int length, ConverterState *state = Q_NULLPTR) const + QByteArray fromUnicode(const QChar *in, int length, ConverterState *state = nullptr) const { return convertFromUnicode(in, length, state); } QTextDecoder* makeDecoder(ConversionFlags flags = DefaultConversion) const; diff --git a/src/corelib/codecs/qtsciicodec_p.h b/src/corelib/codecs/qtsciicodec_p.h index 68ab01f7b5..78f9350a19 100644 --- a/src/corelib/codecs/qtsciicodec_p.h +++ b/src/corelib/codecs/qtsciicodec_p.h @@ -91,11 +91,11 @@ class QTsciiCodec : public QTextCodec { public: ~QTsciiCodec(); - QByteArray name() const Q_DECL_OVERRIDE; - int mibEnum() const Q_DECL_OVERRIDE; + QByteArray name() const override; + int mibEnum() const override; - QString convertToUnicode(const char *, int, ConverterState *) const Q_DECL_OVERRIDE; - QByteArray convertFromUnicode(const QChar *, int, ConverterState *) const Q_DECL_OVERRIDE; + QString convertToUnicode(const char *, int, ConverterState *) const override; + QByteArray convertFromUnicode(const QChar *, int, ConverterState *) const override; }; #endif // QT_NO_CODECS diff --git a/src/corelib/codecs/qutfcodec_p.h b/src/corelib/codecs/qutfcodec_p.h index 152fe174c4..36752cc909 100644 --- a/src/corelib/codecs/qutfcodec_p.h +++ b/src/corelib/codecs/qutfcodec_p.h @@ -310,11 +310,11 @@ class QUtf8Codec : public QTextCodec { public: ~QUtf8Codec(); - QByteArray name() const Q_DECL_OVERRIDE; - int mibEnum() const Q_DECL_OVERRIDE; + QByteArray name() const override; + int mibEnum() const override; - QString convertToUnicode(const char *, int, ConverterState *) const Q_DECL_OVERRIDE; - QByteArray convertFromUnicode(const QChar *, int, ConverterState *) const Q_DECL_OVERRIDE; + QString convertToUnicode(const char *, int, ConverterState *) const override; + QByteArray convertFromUnicode(const QChar *, int, ConverterState *) const override; void convertToUnicode(QString *target, const char *, int, ConverterState *) const; }; @@ -324,12 +324,12 @@ public: QUtf16Codec() { e = DetectEndianness; } ~QUtf16Codec(); - QByteArray name() const Q_DECL_OVERRIDE; - QList<QByteArray> aliases() const Q_DECL_OVERRIDE; - int mibEnum() const Q_DECL_OVERRIDE; + QByteArray name() const override; + QList<QByteArray> aliases() const override; + int mibEnum() const override; - QString convertToUnicode(const char *, int, ConverterState *) const Q_DECL_OVERRIDE; - QByteArray convertFromUnicode(const QChar *, int, ConverterState *) const Q_DECL_OVERRIDE; + QString convertToUnicode(const char *, int, ConverterState *) const override; + QByteArray convertFromUnicode(const QChar *, int, ConverterState *) const override; protected: DataEndianness e; @@ -338,17 +338,17 @@ protected: class QUtf16BECodec : public QUtf16Codec { public: QUtf16BECodec() : QUtf16Codec() { e = BigEndianness; } - QByteArray name() const Q_DECL_OVERRIDE; - QList<QByteArray> aliases() const Q_DECL_OVERRIDE; - int mibEnum() const Q_DECL_OVERRIDE; + QByteArray name() const override; + QList<QByteArray> aliases() const override; + int mibEnum() const override; }; class QUtf16LECodec : public QUtf16Codec { public: QUtf16LECodec() : QUtf16Codec() { e = LittleEndianness; } - QByteArray name() const Q_DECL_OVERRIDE; - QList<QByteArray> aliases() const Q_DECL_OVERRIDE; - int mibEnum() const Q_DECL_OVERRIDE; + QByteArray name() const override; + QList<QByteArray> aliases() const override; + int mibEnum() const override; }; class QUtf32Codec : public QTextCodec { @@ -356,12 +356,12 @@ public: QUtf32Codec() { e = DetectEndianness; } ~QUtf32Codec(); - QByteArray name() const Q_DECL_OVERRIDE; - QList<QByteArray> aliases() const Q_DECL_OVERRIDE; - int mibEnum() const Q_DECL_OVERRIDE; + QByteArray name() const override; + QList<QByteArray> aliases() const override; + int mibEnum() const override; - QString convertToUnicode(const char *, int, ConverterState *) const Q_DECL_OVERRIDE; - QByteArray convertFromUnicode(const QChar *, int, ConverterState *) const Q_DECL_OVERRIDE; + QString convertToUnicode(const char *, int, ConverterState *) const override; + QByteArray convertFromUnicode(const QChar *, int, ConverterState *) const override; protected: DataEndianness e; @@ -370,17 +370,17 @@ protected: class QUtf32BECodec : public QUtf32Codec { public: QUtf32BECodec() : QUtf32Codec() { e = BigEndianness; } - QByteArray name() const Q_DECL_OVERRIDE; - QList<QByteArray> aliases() const Q_DECL_OVERRIDE; - int mibEnum() const Q_DECL_OVERRIDE; + QByteArray name() const override; + QList<QByteArray> aliases() const override; + int mibEnum() const override; }; class QUtf32LECodec : public QUtf32Codec { public: QUtf32LECodec() : QUtf32Codec() { e = LittleEndianness; } - QByteArray name() const Q_DECL_OVERRIDE; - QList<QByteArray> aliases() const Q_DECL_OVERRIDE; - int mibEnum() const Q_DECL_OVERRIDE; + QByteArray name() const override; + QList<QByteArray> aliases() const override; + int mibEnum() const override; }; diff --git a/src/corelib/corelib.pro b/src/corelib/corelib.pro index 6dc11e1a4d..1a7a463c2d 100644 --- a/src/corelib/corelib.pro +++ b/src/corelib/corelib.pro @@ -10,18 +10,15 @@ CONFIG += $$MODULE_CONFIG DEFINES += $$MODULE_DEFINES DEFINES += QT_NO_USING_NAMESPACE QT_NO_FOREACH win32-msvc*|win32-icc:QMAKE_LFLAGS += /BASE:0x67000000 -irix-cc*:QMAKE_CXXFLAGS += -no_prelink -ptused CONFIG += optimize_full QMAKE_DOCS = $$PWD/doc/qtcore.qdocconf -ANDROID_JAR_DEPENDENCIES = \ - jar/QtAndroid.jar ANDROID_LIB_DEPENDENCIES = \ plugins/platforms/android/libqtforandroid.so ANDROID_BUNDLED_JAR_DEPENDENCIES = \ - jar/QtAndroid-bundled.jar + jar/QtAndroid.jar ANDROID_PERMISSIONS = \ android.permission.INTERNET \ android.permission.WRITE_EXTERNAL_STORAGE diff --git a/src/corelib/global/qflags.h b/src/corelib/global/qflags.h index feeb488acd..4806f6cd74 100644 --- a/src/corelib/global/qflags.h +++ b/src/corelib/global/qflags.h @@ -118,7 +118,7 @@ public: Q_DECL_CONSTEXPR inline QFlags &operator=(const QFlags &other); #endif Q_DECL_CONSTEXPR inline QFlags(Enum f) Q_DECL_NOTHROW : i(Int(f)) {} - Q_DECL_CONSTEXPR inline QFlags(Zero = Q_NULLPTR) Q_DECL_NOTHROW : i(0) {} + Q_DECL_CONSTEXPR inline QFlags(Zero = nullptr) Q_DECL_NOTHROW : i(0) {} Q_DECL_CONSTEXPR inline QFlags(QFlag f) Q_DECL_NOTHROW : i(f) {} #ifdef Q_COMPILER_INITIALIZER_LISTS diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 36b7560398..6ab45e1487 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -1428,13 +1428,6 @@ bool qSharedBuild() Q_DECL_NOTHROW */ /*! - \macro Q_OS_ULTRIX - \relates <QtGlobal> - - Defined on DEC Ultrix. -*/ - -/*! \macro Q_OS_LINUX \relates <QtGlobal> @@ -1470,41 +1463,6 @@ bool qSharedBuild() Q_DECL_NOTHROW */ /*! - \macro Q_OS_BSDI - \relates <QtGlobal> - - Defined on BSD/OS. -*/ - -/*! - \macro Q_OS_IRIX - \relates <QtGlobal> - - Defined on SGI Irix. -*/ - -/*! - \macro Q_OS_OSF - \relates <QtGlobal> - - Defined on HP Tru64 UNIX. -*/ - -/*! - \macro Q_OS_SCO - \relates <QtGlobal> - - Defined on SCO OpenServer 5. -*/ - -/*! - \macro Q_OS_UNIXWARE - \relates <QtGlobal> - - Defined on UnixWare 7, Open UNIX 8. -*/ - -/*! \macro Q_OS_AIX \relates <QtGlobal> @@ -1519,27 +1477,6 @@ bool qSharedBuild() Q_DECL_NOTHROW */ /*! - \macro Q_OS_DGUX - \relates <QtGlobal> - - Defined on DG/UX. -*/ - -/*! - \macro Q_OS_RELIANT - \relates <QtGlobal> - - Defined on Reliant UNIX. -*/ - -/*! - \macro Q_OS_DYNIX - \relates <QtGlobal> - - Defined on DYNIX/ptx. -*/ - -/*! \macro Q_OS_QNX \relates <QtGlobal> diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 7b691ca59e..e49bace002 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -1138,7 +1138,7 @@ Q_CORE_EXPORT bool qunsetenv(const char *varName); Q_CORE_EXPORT bool qEnvironmentVariableIsEmpty(const char *varName) Q_DECL_NOEXCEPT; Q_CORE_EXPORT bool qEnvironmentVariableIsSet(const char *varName) Q_DECL_NOEXCEPT; -Q_CORE_EXPORT int qEnvironmentVariableIntValue(const char *varName, bool *ok=Q_NULLPTR) Q_DECL_NOEXCEPT; +Q_CORE_EXPORT int qEnvironmentVariableIntValue(const char *varName, bool *ok=nullptr) Q_DECL_NOEXCEPT; inline int qIntCast(double f) { return int(f); } inline int qIntCast(float f) { return int(f); } diff --git a/src/corelib/global/qlogging.h b/src/corelib/global/qlogging.h index ec21198784..0c8d7dab38 100644 --- a/src/corelib/global/qlogging.h +++ b/src/corelib/global/qlogging.h @@ -64,7 +64,7 @@ class QMessageLogContext Q_DISABLE_COPY(QMessageLogContext) public: Q_DECL_CONSTEXPR QMessageLogContext() - : version(2), line(0), file(Q_NULLPTR), function(Q_NULLPTR), category(Q_NULLPTR) {} + : version(2), line(0), file(nullptr), function(nullptr), category(nullptr) {} Q_DECL_CONSTEXPR QMessageLogContext(const char *fileName, int lineNumber, const char *functionName, const char *categoryName) : version(2), line(lineNumber), file(fileName), function(functionName), category(categoryName) {} @@ -150,9 +150,9 @@ private: #define QT_MESSAGELOG_LINE __LINE__ #define QT_MESSAGELOG_FUNC Q_FUNC_INFO #else - #define QT_MESSAGELOG_FILE Q_NULLPTR + #define QT_MESSAGELOG_FILE nullptr #define QT_MESSAGELOG_LINE 0 - #define QT_MESSAGELOG_FUNC Q_NULLPTR + #define QT_MESSAGELOG_FUNC nullptr #endif #define qDebug QMessageLogger(QT_MESSAGELOG_FILE, QT_MESSAGELOG_LINE, QT_MESSAGELOG_FUNC).debug diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index e64fb221d3..c53db50e71 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -3077,9 +3077,8 @@ it is displayed regardless of device type. The keypad is used to implement a virtual cursor, unless the device has an analog mouse type of input device (e.g. touchpad) - - \note In 4.6, cursor navigation is only implemented for Symbian OS. - On other platforms, it behaves as NavigationModeNone. + \note Cursor navigation is not currently implemented on any platform + and behaves as NavigationModeNone. \sa QApplication::setNavigationMode() \sa QApplication::navigationMode() */ diff --git a/src/corelib/global/qrandom.cpp b/src/corelib/global/qrandom.cpp index 0bbe79aeb4..9abb9ece7f 100644 --- a/src/corelib/global/qrandom.cpp +++ b/src/corelib/global/qrandom.cpp @@ -138,11 +138,13 @@ public: // getentropy can't fail under normal circumstances int ret = getentropy(reinterpret_cast<uchar *>(buffer) + read, 256); Q_ASSERT(ret == 0); + Q_UNUSED(ret); read += 256; } int ret = getentropy(reinterpret_cast<uchar *>(buffer) + read, count - read); Q_ASSERT(ret == 0); + Q_UNUSED(ret); return count; } }; diff --git a/src/corelib/global/qsystemdetection.h b/src/corelib/global/qsystemdetection.h index 4a2c3f79bb..ff0e03108b 100644 --- a/src/corelib/global/qsystemdetection.h +++ b/src/corelib/global/qsystemdetection.h @@ -52,30 +52,18 @@ IOS - iOS WATCHOS - watchOS TVOS - tvOS - MSDOS - MS-DOS and Windows - OS2 - OS/2 - OS2EMX - XFree86 on OS/2 (not PM) WIN32 - Win32 (Windows 2000/XP/Vista/7 and Windows Server 2003/2008) - WINRT - WinRT (Windows 8 Runtime) + WINRT - WinRT (Windows Runtime) CYGWIN - Cygwin SOLARIS - Sun Solaris HPUX - HP-UX - ULTRIX - DEC Ultrix LINUX - Linux [has variants] FREEBSD - FreeBSD [has variants] NETBSD - NetBSD OPENBSD - OpenBSD - BSDI - BSD/OS INTERIX - Interix - IRIX - SGI Irix - OSF - HP Tru64 UNIX - SCO - SCO OpenServer 5 - UNIXWARE - UnixWare 7, Open UNIX 8 AIX - AIX HURD - GNU Hurd - DGUX - DG/UX - RELIANT - Reliant UNIX - DYNIX - DYNIX/ptx QNX - QNX [has variants] QNX6 - QNX RTP 6.1 LYNX - LynxOS @@ -147,10 +135,6 @@ # define Q_OS_SOLARIS #elif defined(hpux) || defined(__hpux) # define Q_OS_HPUX -#elif defined(__ultrix) || defined(ultrix) -# define Q_OS_ULTRIX -#elif defined(sinix) -# define Q_OS_RELIANT #elif defined(__native_client__) # define Q_OS_NACL #elif defined(__linux__) || defined(__linux) @@ -167,34 +151,17 @@ #elif defined(__OpenBSD__) # define Q_OS_OPENBSD # define Q_OS_BSD4 -#elif defined(__bsdi__) -# define Q_OS_BSDI -# define Q_OS_BSD4 #elif defined(__INTERIX) # define Q_OS_INTERIX # define Q_OS_BSD4 -#elif defined(__sgi) -# define Q_OS_IRIX -#elif defined(__osf__) -# define Q_OS_OSF #elif defined(_AIX) # define Q_OS_AIX #elif defined(__Lynx__) # define Q_OS_LYNX #elif defined(__GNU__) # define Q_OS_HURD -#elif defined(__DGUX__) -# define Q_OS_DGUX #elif defined(__QNXNTO__) # define Q_OS_QNX -#elif defined(_SEQUENT_) -# define Q_OS_DYNIX -#elif defined(_SCO_DS) /* SCO OpenServer 5 + GCC */ -# define Q_OS_SCO -#elif defined(__USLC__) /* all SCO platforms + UDK or OUDK */ -# define Q_OS_UNIXWARE -#elif defined(__svr4__) && defined(i386) /* Open UNIX 8 + GCC */ -# define Q_OS_UNIXWARE #elif defined(__INTEGRITY) # define Q_OS_INTEGRITY #elif defined(VXWORKS) /* there is no "real" VxWorks define - this has to be set in the mkspec! */ diff --git a/src/corelib/global/qversiontagging.cpp b/src/corelib/global/qversiontagging.cpp index e3d4037a16..cbfd93f135 100644 --- a/src/corelib/global/qversiontagging.cpp +++ b/src/corelib/global/qversiontagging.cpp @@ -84,6 +84,16 @@ make_versioned_symbol(SYM, QT_VERSION_MAJOR, 8, "@"); make_versioned_symbol(SYM, QT_VERSION_MAJOR, 9, "@"); #endif #if QT_VERSION_MINOR > 10 +make_versioned_symbol(SYM, QT_VERSION_MAJOR, 10, "@"); +#endif +#if QT_VERSION_MINOR > 11 +make_versioned_symbol(SYM, QT_VERSION_MAJOR, 11, "@"); +#endif +#if QT_VERSION_MINOR > 12 +make_versioned_symbol(SYM, QT_VERSION_MAJOR, 12, "@"); +#endif +#if QT_VERSION_MINOR > 13 +// We don't expect there will be a Qt 5.13 # error "Please update this file with more Qt versions." #endif diff --git a/src/corelib/io/qbuffer.cpp b/src/corelib/io/qbuffer.cpp index 86dd737809..e0b9c41323 100644 --- a/src/corelib/io/qbuffer.cpp +++ b/src/corelib/io/qbuffer.cpp @@ -60,8 +60,8 @@ public: QByteArray *buf; QByteArray defaultBuf; - virtual qint64 peek(char *data, qint64 maxSize) Q_DECL_OVERRIDE; - virtual QByteArray peek(qint64 maxSize) Q_DECL_OVERRIDE; + virtual qint64 peek(char *data, qint64 maxSize) override; + virtual QByteArray peek(qint64 maxSize) override; #ifndef QT_NO_QOBJECT // private slots diff --git a/src/corelib/io/qbuffer.h b/src/corelib/io/qbuffer.h index fd05dff311..39e1e7b39d 100644 --- a/src/corelib/io/qbuffer.h +++ b/src/corelib/io/qbuffer.h @@ -57,8 +57,8 @@ class Q_CORE_EXPORT QBuffer : public QIODevice public: #ifndef QT_NO_QOBJECT - explicit QBuffer(QObject *parent = Q_NULLPTR); - QBuffer(QByteArray *buf, QObject *parent = Q_NULLPTR); + explicit QBuffer(QObject *parent = nullptr); + QBuffer(QByteArray *buf, QObject *parent = nullptr); #else QBuffer(); explicit QBuffer(QByteArray *buf); @@ -73,22 +73,22 @@ public: inline void setData(const char *data, int len); const QByteArray &data() const; - bool open(OpenMode openMode) Q_DECL_OVERRIDE; + bool open(OpenMode openMode) override; - void close() Q_DECL_OVERRIDE; - qint64 size() const Q_DECL_OVERRIDE; - qint64 pos() const Q_DECL_OVERRIDE; - bool seek(qint64 off) Q_DECL_OVERRIDE; - bool atEnd() const Q_DECL_OVERRIDE; - bool canReadLine() const Q_DECL_OVERRIDE; + void close() override; + qint64 size() const override; + qint64 pos() const override; + bool seek(qint64 off) override; + bool atEnd() const override; + bool canReadLine() const override; protected: #ifndef QT_NO_QOBJECT - void connectNotify(const QMetaMethod &) Q_DECL_OVERRIDE; - void disconnectNotify(const QMetaMethod &) Q_DECL_OVERRIDE; + void connectNotify(const QMetaMethod &) override; + void disconnectNotify(const QMetaMethod &) override; #endif - qint64 readData(char *data, qint64 maxlen) Q_DECL_OVERRIDE; - qint64 writeData(const char *data, qint64 len) Q_DECL_OVERRIDE; + qint64 readData(char *data, qint64 maxlen) override; + qint64 writeData(const char *data, qint64 len) override; private: Q_DECLARE_PRIVATE(QBuffer) diff --git a/src/corelib/io/qdatastream.cpp b/src/corelib/io/qdatastream.cpp index 1486d3630c..5fa5b558ea 100644 --- a/src/corelib/io/qdatastream.cpp +++ b/src/corelib/io/qdatastream.cpp @@ -563,6 +563,7 @@ void QDataStream::setByteOrder(ByteOrder bo) \value Qt_5_8 Same as Qt_5_6 \value Qt_5_9 Same as Qt_5_6 \value Qt_5_10 Same as Qt_5_6 + \value Qt_5_11 Same as Qt_5_6 \omitvalue Qt_DefaultCompiledVersion \sa setVersion(), version() diff --git a/src/corelib/io/qdatastream.h b/src/corelib/io/qdatastream.h index 0a429d091a..1f1b13686c 100644 --- a/src/corelib/io/qdatastream.h +++ b/src/corelib/io/qdatastream.h @@ -97,10 +97,11 @@ public: Qt_5_8 = Qt_5_7, Qt_5_9 = Qt_5_8, Qt_5_10 = Qt_5_9, -#if QT_VERSION >= 0x050b00 + Qt_5_11 = Qt_5_10, +#if QT_VERSION >= 0x050c00 #error Add the datastream version for this Qt version and update Qt_DefaultCompiledVersion #endif - Qt_DefaultCompiledVersion = Qt_5_10 + Qt_DefaultCompiledVersion = Qt_5_11 }; enum ByteOrder { diff --git a/src/corelib/io/qfile.h b/src/corelib/io/qfile.h index c5819e8076..e6f3d942fe 100644 --- a/src/corelib/io/qfile.h +++ b/src/corelib/io/qfile.h @@ -70,7 +70,7 @@ public: #endif ~QFile(); - QString fileName() const Q_DECL_OVERRIDE; + QString fileName() const override; void setFileName(const QString &name); #if defined(Q_OS_DARWIN) @@ -124,25 +124,25 @@ public: bool copy(const QString &newName); static bool copy(const QString &fileName, const QString &newName); - bool open(OpenMode flags) Q_DECL_OVERRIDE; + bool open(OpenMode flags) override; bool open(FILE *f, OpenMode ioFlags, FileHandleFlags handleFlags=DontCloseHandle); bool open(int fd, OpenMode ioFlags, FileHandleFlags handleFlags=DontCloseHandle); - qint64 size() const Q_DECL_OVERRIDE; + qint64 size() const override; - bool resize(qint64 sz) Q_DECL_OVERRIDE; + bool resize(qint64 sz) override; static bool resize(const QString &filename, qint64 sz); - Permissions permissions() const Q_DECL_OVERRIDE; + Permissions permissions() const override; static Permissions permissions(const QString &filename); - bool setPermissions(Permissions permissionSpec) Q_DECL_OVERRIDE; + bool setPermissions(Permissions permissionSpec) override; static bool setPermissions(const QString &filename, Permissions permissionSpec); protected: #ifdef QT_NO_QOBJECT QFile(QFilePrivate &dd); #else - QFile(QFilePrivate &dd, QObject *parent = Q_NULLPTR); + QFile(QFilePrivate &dd, QObject *parent = nullptr); #endif private: diff --git a/src/corelib/io/qfiledevice.h b/src/corelib/io/qfiledevice.h index e941781c25..af41bec2f6 100644 --- a/src/corelib/io/qfiledevice.h +++ b/src/corelib/io/qfiledevice.h @@ -100,19 +100,19 @@ public: FileError error() const; void unsetError(); - virtual void close() Q_DECL_OVERRIDE; + virtual void close() override; - bool isSequential() const Q_DECL_OVERRIDE; + bool isSequential() const override; int handle() const; virtual QString fileName() const; - qint64 pos() const Q_DECL_OVERRIDE; - bool seek(qint64 offset) Q_DECL_OVERRIDE; - bool atEnd() const Q_DECL_OVERRIDE; + qint64 pos() const override; + bool seek(qint64 offset) override; + bool atEnd() const override; bool flush(); - qint64 size() const Q_DECL_OVERRIDE; + qint64 size() const override; virtual bool resize(qint64 sz); virtual Permissions permissions() const; @@ -136,12 +136,12 @@ protected: QFileDevice(QFileDevicePrivate &dd); #else explicit QFileDevice(QObject *parent); - QFileDevice(QFileDevicePrivate &dd, QObject *parent = Q_NULLPTR); + QFileDevice(QFileDevicePrivate &dd, QObject *parent = nullptr); #endif - qint64 readData(char *data, qint64 maxlen) Q_DECL_OVERRIDE; - qint64 writeData(const char *data, qint64 len) Q_DECL_OVERRIDE; - qint64 readLineData(char *data, qint64 maxlen) Q_DECL_OVERRIDE; + qint64 readData(char *data, qint64 maxlen) override; + qint64 writeData(const char *data, qint64 len) override; + qint64 readLineData(char *data, qint64 maxlen) override; private: Q_DISABLE_COPY(QFileDevice) diff --git a/src/corelib/io/qfiledevice_p.h b/src/corelib/io/qfiledevice_p.h index 60c51afb7e..47053d01b7 100644 --- a/src/corelib/io/qfiledevice_p.h +++ b/src/corelib/io/qfiledevice_p.h @@ -69,7 +69,7 @@ protected: inline bool ensureFlushed() const; - bool putCharHelper(char c) Q_DECL_OVERRIDE; + bool putCharHelper(char c) override; void setError(QFileDevice::FileError err); void setError(QFileDevice::FileError err, const QString &errorString); diff --git a/src/corelib/io/qfileselector.h b/src/corelib/io/qfileselector.h index fafb7f7609..c9c2f564f6 100644 --- a/src/corelib/io/qfileselector.h +++ b/src/corelib/io/qfileselector.h @@ -50,7 +50,7 @@ class Q_CORE_EXPORT QFileSelector : public QObject { Q_OBJECT public: - explicit QFileSelector(QObject *parent = Q_NULLPTR); + explicit QFileSelector(QObject *parent = nullptr); ~QFileSelector(); QString select(const QString &filePath) const; diff --git a/src/corelib/io/qfilesystemwatcher.h b/src/corelib/io/qfilesystemwatcher.h index 09d4e8e65e..057a20672c 100644 --- a/src/corelib/io/qfilesystemwatcher.h +++ b/src/corelib/io/qfilesystemwatcher.h @@ -55,8 +55,8 @@ class Q_CORE_EXPORT QFileSystemWatcher : public QObject Q_DECLARE_PRIVATE(QFileSystemWatcher) public: - QFileSystemWatcher(QObject *parent = Q_NULLPTR); - QFileSystemWatcher(const QStringList &paths, QObject *parent = Q_NULLPTR); + QFileSystemWatcher(QObject *parent = nullptr); + QFileSystemWatcher(const QStringList &paths, QObject *parent = nullptr); ~QFileSystemWatcher(); bool addPath(const QString &file); diff --git a/src/corelib/io/qfilesystemwatcher_fsevents.mm b/src/corelib/io/qfilesystemwatcher_fsevents.mm index b4517cbac7..792ea387ac 100644 --- a/src/corelib/io/qfilesystemwatcher_fsevents.mm +++ b/src/corelib/io/qfilesystemwatcher_fsevents.mm @@ -336,7 +336,7 @@ QStringList QFseventsFileSystemWatcherEngine::addPaths(const QStringList &paths, QMutexLocker locker(&lock); - bool wasRunning = stream != Q_NULLPTR; + bool wasRunning = stream != nullptr; bool needsRestart = false; WatchingState oldState = watchingState; diff --git a/src/corelib/io/qfilesystemwatcher_inotify_p.h b/src/corelib/io/qfilesystemwatcher_inotify_p.h index 777d62dc8a..0c873466c8 100644 --- a/src/corelib/io/qfilesystemwatcher_inotify_p.h +++ b/src/corelib/io/qfilesystemwatcher_inotify_p.h @@ -70,8 +70,8 @@ public: static QInotifyFileSystemWatcherEngine *create(QObject *parent); - QStringList addPaths(const QStringList &paths, QStringList *files, QStringList *directories) Q_DECL_OVERRIDE; - QStringList removePaths(const QStringList &paths, QStringList *files, QStringList *directories) Q_DECL_OVERRIDE; + QStringList addPaths(const QStringList &paths, QStringList *files, QStringList *directories) override; + QStringList removePaths(const QStringList &paths, QStringList *files, QStringList *directories) override; private Q_SLOTS: void readFromInotify(); diff --git a/src/corelib/io/qfilesystemwatcher_polling_p.h b/src/corelib/io/qfilesystemwatcher_polling_p.h index 6dff08ac05..4c46633fdf 100644 --- a/src/corelib/io/qfilesystemwatcher_polling_p.h +++ b/src/corelib/io/qfilesystemwatcher_polling_p.h @@ -110,8 +110,8 @@ class QPollingFileSystemWatcherEngine : public QFileSystemWatcherEngine public: QPollingFileSystemWatcherEngine(QObject *parent); - QStringList addPaths(const QStringList &paths, QStringList *files, QStringList *directories) Q_DECL_OVERRIDE; - QStringList removePaths(const QStringList &paths, QStringList *files, QStringList *directories) Q_DECL_OVERRIDE; + QStringList addPaths(const QStringList &paths, QStringList *files, QStringList *directories) override; + QStringList removePaths(const QStringList &paths, QStringList *files, QStringList *directories) override; private Q_SLOTS: void timeout(); diff --git a/src/corelib/io/qfsfileengine_iterator_p.h b/src/corelib/io/qfsfileengine_iterator_p.h index 7f094ba9d7..bde00bf578 100644 --- a/src/corelib/io/qfsfileengine_iterator_p.h +++ b/src/corelib/io/qfsfileengine_iterator_p.h @@ -68,11 +68,11 @@ public: QFSFileEngineIterator(QDir::Filters filters, const QStringList &filterNames); ~QFSFileEngineIterator(); - QString next() Q_DECL_OVERRIDE; - bool hasNext() const Q_DECL_OVERRIDE; + QString next() override; + bool hasNext() const override; - QString currentFileName() const Q_DECL_OVERRIDE; - QFileInfo currentFileInfo() const Q_DECL_OVERRIDE; + QString currentFileName() const override; + QFileInfo currentFileInfo() const override; private: void advance() const; diff --git a/src/corelib/io/qfsfileengine_p.h b/src/corelib/io/qfsfileengine_p.h index 1f34dfc2be..bf90995fdd 100644 --- a/src/corelib/io/qfsfileengine_p.h +++ b/src/corelib/io/qfsfileengine_p.h @@ -71,49 +71,49 @@ public: explicit QFSFileEngine(const QString &file); ~QFSFileEngine(); - bool open(QIODevice::OpenMode openMode) Q_DECL_OVERRIDE; + bool open(QIODevice::OpenMode openMode) override; bool open(QIODevice::OpenMode flags, FILE *fh); - bool close() Q_DECL_OVERRIDE; - bool flush() Q_DECL_OVERRIDE; - bool syncToDisk() Q_DECL_OVERRIDE; - qint64 size() const Q_DECL_OVERRIDE; - qint64 pos() const Q_DECL_OVERRIDE; - bool seek(qint64) Q_DECL_OVERRIDE; - bool isSequential() const Q_DECL_OVERRIDE; - bool remove() Q_DECL_OVERRIDE; - bool copy(const QString &newName) Q_DECL_OVERRIDE; - bool rename(const QString &newName) Q_DECL_OVERRIDE; - bool renameOverwrite(const QString &newName) Q_DECL_OVERRIDE; - bool link(const QString &newName) Q_DECL_OVERRIDE; - bool mkdir(const QString &dirName, bool createParentDirectories) const Q_DECL_OVERRIDE; - bool rmdir(const QString &dirName, bool recurseParentDirectories) const Q_DECL_OVERRIDE; - bool setSize(qint64 size) Q_DECL_OVERRIDE; - bool caseSensitive() const Q_DECL_OVERRIDE; - bool isRelativePath() const Q_DECL_OVERRIDE; - QStringList entryList(QDir::Filters filters, const QStringList &filterNames) const Q_DECL_OVERRIDE; - FileFlags fileFlags(FileFlags type) const Q_DECL_OVERRIDE; - bool setPermissions(uint perms) Q_DECL_OVERRIDE; + bool close() override; + bool flush() override; + bool syncToDisk() override; + qint64 size() const override; + qint64 pos() const override; + bool seek(qint64) override; + bool isSequential() const override; + bool remove() override; + bool copy(const QString &newName) override; + bool rename(const QString &newName) override; + bool renameOverwrite(const QString &newName) override; + bool link(const QString &newName) override; + bool mkdir(const QString &dirName, bool createParentDirectories) const override; + bool rmdir(const QString &dirName, bool recurseParentDirectories) const override; + bool setSize(qint64 size) override; + bool caseSensitive() const override; + bool isRelativePath() const override; + QStringList entryList(QDir::Filters filters, const QStringList &filterNames) const override; + FileFlags fileFlags(FileFlags type) const override; + bool setPermissions(uint perms) override; QByteArray id() const override; - QString fileName(FileName file) const Q_DECL_OVERRIDE; - uint ownerId(FileOwner) const Q_DECL_OVERRIDE; - QString owner(FileOwner) const Q_DECL_OVERRIDE; - bool setFileTime(const QDateTime &newDate, FileTime time) Q_DECL_OVERRIDE; - QDateTime fileTime(FileTime time) const Q_DECL_OVERRIDE; - void setFileName(const QString &file) Q_DECL_OVERRIDE; - int handle() const Q_DECL_OVERRIDE; + QString fileName(FileName file) const override; + uint ownerId(FileOwner) const override; + QString owner(FileOwner) const override; + bool setFileTime(const QDateTime &newDate, FileTime time) override; + QDateTime fileTime(FileTime time) const override; + void setFileName(const QString &file) override; + int handle() const override; #ifndef QT_NO_FILESYSTEMITERATOR - Iterator *beginEntryList(QDir::Filters filters, const QStringList &filterNames) Q_DECL_OVERRIDE; - Iterator *endEntryList() Q_DECL_OVERRIDE; + Iterator *beginEntryList(QDir::Filters filters, const QStringList &filterNames) override; + Iterator *endEntryList() override; #endif - qint64 read(char *data, qint64 maxlen) Q_DECL_OVERRIDE; - qint64 readLine(char *data, qint64 maxlen) Q_DECL_OVERRIDE; - qint64 write(const char *data, qint64 len) Q_DECL_OVERRIDE; + qint64 read(char *data, qint64 maxlen) override; + qint64 readLine(char *data, qint64 maxlen) override; + qint64 write(const char *data, qint64 len) override; bool cloneTo(QAbstractFileEngine *target) override; - bool extension(Extension extension, const ExtensionOption *option = 0, ExtensionReturn *output = 0) Q_DECL_OVERRIDE; - bool supportsExtension(Extension extension) const Q_DECL_OVERRIDE; + bool extension(Extension extension, const ExtensionOption *option = 0, ExtensionReturn *output = 0) override; + bool supportsExtension(Extension extension) const override; //FS only!! bool open(QIODevice::OpenMode flags, int fd); diff --git a/src/corelib/io/qiodevice.h b/src/corelib/io/qiodevice.h index e64a4d0bb1..af37b3fd53 100644 --- a/src/corelib/io/qiodevice.h +++ b/src/corelib/io/qiodevice.h @@ -161,7 +161,7 @@ protected: #ifdef QT_NO_QOBJECT QIODevice(QIODevicePrivate &dd); #else - QIODevice(QIODevicePrivate &dd, QObject *parent = Q_NULLPTR); + QIODevice(QIODevicePrivate &dd, QObject *parent = nullptr); #endif virtual qint64 readData(char *data, qint64 maxlen) = 0; virtual qint64 readLineData(char *data, qint64 maxlen); diff --git a/src/corelib/io/qiodevice_p.h b/src/corelib/io/qiodevice_p.h index de2aa1597e..15a53a67dc 100644 --- a/src/corelib/io/qiodevice_p.h +++ b/src/corelib/io/qiodevice_p.h @@ -88,14 +88,14 @@ public: class QRingBufferRef { QRingBuffer *m_buf; - inline QRingBufferRef() : m_buf(Q_NULLPTR) { } + inline QRingBufferRef() : m_buf(nullptr) { } friend class QIODevicePrivate; public: // wrap functions from QRingBuffer inline void setChunkSize(int size) { Q_ASSERT(m_buf); m_buf->setChunkSize(size); } inline int chunkSize() const { Q_ASSERT(m_buf); return m_buf->chunkSize(); } inline qint64 nextDataBlockSize() const { return (m_buf ? m_buf->nextDataBlockSize() : Q_INT64_C(0)); } - inline const char *readPointer() const { return (m_buf ? m_buf->readPointer() : Q_NULLPTR); } + inline const char *readPointer() const { return (m_buf ? m_buf->readPointer() : nullptr); } inline const char *readPointerAtPosition(qint64 pos, qint64 &length) const { Q_ASSERT(m_buf); return m_buf->readPointerAtPosition(pos, length); } inline void free(qint64 bytes) { Q_ASSERT(m_buf); m_buf->free(bytes); } inline char *reserve(qint64 bytes) { Q_ASSERT(m_buf); return m_buf->reserve(bytes); } diff --git a/src/corelib/io/qnoncontiguousbytedevice_p.h b/src/corelib/io/qnoncontiguousbytedevice_p.h index bb0b533831..ebed1120db 100644 --- a/src/corelib/io/qnoncontiguousbytedevice_p.h +++ b/src/corelib/io/qnoncontiguousbytedevice_p.h @@ -105,12 +105,12 @@ class QNonContiguousByteDeviceByteArrayImpl : public QNonContiguousByteDevice public: QNonContiguousByteDeviceByteArrayImpl(QByteArray *ba); ~QNonContiguousByteDeviceByteArrayImpl(); - const char* readPointer(qint64 maximumLength, qint64 &len) Q_DECL_OVERRIDE; - bool advanceReadPointer(qint64 amount) Q_DECL_OVERRIDE; - bool atEnd() const Q_DECL_OVERRIDE; - bool reset() Q_DECL_OVERRIDE; - qint64 size() const Q_DECL_OVERRIDE; - qint64 pos() const Q_DECL_OVERRIDE; + const char* readPointer(qint64 maximumLength, qint64 &len) override; + bool advanceReadPointer(qint64 amount) override; + bool atEnd() const override; + bool reset() override; + qint64 size() const override; + qint64 pos() const override; protected: QByteArray* byteArray; qint64 currentPosition; @@ -121,12 +121,12 @@ class QNonContiguousByteDeviceRingBufferImpl : public QNonContiguousByteDevice public: QNonContiguousByteDeviceRingBufferImpl(QSharedPointer<QRingBuffer> rb); ~QNonContiguousByteDeviceRingBufferImpl(); - const char* readPointer(qint64 maximumLength, qint64 &len) Q_DECL_OVERRIDE; - bool advanceReadPointer(qint64 amount) Q_DECL_OVERRIDE; - bool atEnd() const Q_DECL_OVERRIDE; - bool reset() Q_DECL_OVERRIDE; - qint64 size() const Q_DECL_OVERRIDE; - qint64 pos() const Q_DECL_OVERRIDE; + const char* readPointer(qint64 maximumLength, qint64 &len) override; + bool advanceReadPointer(qint64 amount) override; + bool atEnd() const override; + bool reset() override; + qint64 size() const override; + qint64 pos() const override; protected: QSharedPointer<QRingBuffer> ringBuffer; qint64 currentPosition; @@ -139,12 +139,12 @@ class QNonContiguousByteDeviceIoDeviceImpl : public QNonContiguousByteDevice public: QNonContiguousByteDeviceIoDeviceImpl(QIODevice *d); ~QNonContiguousByteDeviceIoDeviceImpl(); - const char* readPointer(qint64 maximumLength, qint64 &len) Q_DECL_OVERRIDE; - bool advanceReadPointer(qint64 amount) Q_DECL_OVERRIDE; - bool atEnd() const Q_DECL_OVERRIDE; - bool reset() Q_DECL_OVERRIDE; - qint64 size() const Q_DECL_OVERRIDE; - qint64 pos() const Q_DECL_OVERRIDE; + const char* readPointer(qint64 maximumLength, qint64 &len) override; + bool advanceReadPointer(qint64 amount) override; + bool atEnd() const override; + bool reset() override; + qint64 size() const override; + qint64 pos() const override; protected: QIODevice* device; QByteArray* currentReadBuffer; @@ -162,11 +162,11 @@ class QNonContiguousByteDeviceBufferImpl : public QNonContiguousByteDevice public: QNonContiguousByteDeviceBufferImpl(QBuffer *b); ~QNonContiguousByteDeviceBufferImpl(); - const char* readPointer(qint64 maximumLength, qint64 &len) Q_DECL_OVERRIDE; - bool advanceReadPointer(qint64 amount) Q_DECL_OVERRIDE; - bool atEnd() const Q_DECL_OVERRIDE; - bool reset() Q_DECL_OVERRIDE; - qint64 size() const Q_DECL_OVERRIDE; + const char* readPointer(qint64 maximumLength, qint64 &len) override; + bool advanceReadPointer(qint64 amount) override; + bool atEnd() const override; + bool reset() override; + qint64 size() const override; protected: QBuffer* buffer; QByteArray byteArray; @@ -179,13 +179,13 @@ class QByteDeviceWrappingIoDevice : public QIODevice public: QByteDeviceWrappingIoDevice (QNonContiguousByteDevice *bd); ~QByteDeviceWrappingIoDevice (); - virtual bool isSequential () const Q_DECL_OVERRIDE; - virtual bool atEnd () const Q_DECL_OVERRIDE; - virtual bool reset () Q_DECL_OVERRIDE; - virtual qint64 size () const Q_DECL_OVERRIDE; + virtual bool isSequential () const override; + virtual bool atEnd () const override; + virtual bool reset () override; + virtual qint64 size () const override; protected: - virtual qint64 readData ( char * data, qint64 maxSize ) Q_DECL_OVERRIDE; - virtual qint64 writeData ( const char * data, qint64 maxSize ) Q_DECL_OVERRIDE; + virtual qint64 readData ( char * data, qint64 maxSize ) override; + virtual qint64 writeData ( const char * data, qint64 maxSize ) override; QNonContiguousByteDevice *byteDevice; }; diff --git a/src/corelib/io/qprocess.h b/src/corelib/io/qprocess.h index c8aef2f0b1..474fc87de8 100644 --- a/src/corelib/io/qprocess.h +++ b/src/corelib/io/qprocess.h @@ -155,7 +155,7 @@ public: }; Q_ENUM(ExitStatus) - explicit QProcess(QObject *parent = Q_NULLPTR); + explicit QProcess(QObject *parent = nullptr); virtual ~QProcess(); void start(const QString &program, const QStringList &arguments, OpenMode mode = ReadWrite); @@ -164,7 +164,7 @@ public: #endif void start(OpenMode mode = ReadWrite); bool startDetached(qint64 *pid = nullptr); - bool open(OpenMode mode = ReadWrite) Q_DECL_OVERRIDE; + bool open(OpenMode mode = ReadWrite) override; QString program() const; void setProgram(const QString &program); @@ -227,8 +227,8 @@ public: qint64 processId() const; bool waitForStarted(int msecs = 30000); - bool waitForReadyRead(int msecs = 30000) Q_DECL_OVERRIDE; - bool waitForBytesWritten(int msecs = 30000) Q_DECL_OVERRIDE; + bool waitForReadyRead(int msecs = 30000) override; + bool waitForBytesWritten(int msecs = 30000) override; bool waitForFinished(int msecs = 30000); QByteArray readAllStandardOutput(); @@ -238,12 +238,12 @@ public: QProcess::ExitStatus exitStatus() const; // QIODevice - qint64 bytesAvailable() const Q_DECL_OVERRIDE; // ### Qt6: remove trivial override - qint64 bytesToWrite() const Q_DECL_OVERRIDE; - bool isSequential() const Q_DECL_OVERRIDE; - bool canReadLine() const Q_DECL_OVERRIDE; // ### Qt6: remove trivial override - void close() Q_DECL_OVERRIDE; - bool atEnd() const Q_DECL_OVERRIDE; // ### Qt6: remove trivial override + qint64 bytesAvailable() const override; // ### Qt6: remove trivial override + qint64 bytesToWrite() const override; + bool isSequential() const override; + bool canReadLine() const override; // ### Qt6: remove trivial override + void close() override; + bool atEnd() const override; // ### Qt6: remove trivial override static int execute(const QString &program, const QStringList &arguments); static int execute(const QString &command); @@ -253,7 +253,7 @@ public: #if defined(Q_QDOC) = QString() #endif - , qint64 *pid = Q_NULLPTR); + , qint64 *pid = nullptr); #if !defined(Q_QDOC) static bool startDetached(const QString &program, const QStringList &arguments); // ### Qt6: merge overloads #endif @@ -286,8 +286,8 @@ protected: virtual void setupChildProcess(); // QIODevice - qint64 readData(char *data, qint64 maxlen) Q_DECL_OVERRIDE; - qint64 writeData(const char *data, qint64 len) Q_DECL_OVERRIDE; + qint64 readData(char *data, qint64 maxlen) override; + qint64 writeData(const char *data, qint64 len) override; private: Q_DECLARE_PRIVATE(QProcess) diff --git a/src/corelib/io/qprocess_p.h b/src/corelib/io/qprocess_p.h index deb29dca0a..aa7ecbe91d 100644 --- a/src/corelib/io/qprocess_p.h +++ b/src/corelib/io/qprocess_p.h @@ -352,7 +352,7 @@ public: #if defined(Q_OS_UNIX) void execChild(const char *workingDirectory, char **argv, char **envp); #endif - bool processStarted(QString *errorMessage = Q_NULLPTR); + bool processStarted(QString *errorMessage = nullptr); void terminateProcess(); void killProcess(); void findExitCode(); diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp index 15752f84b2..68b7a8bf9b 100644 --- a/src/corelib/io/qprocess_unix.cpp +++ b/src/corelib/io/qprocess_unix.cpp @@ -885,7 +885,7 @@ bool QProcessPrivate::waitForDeadChild() // read the process information from our fd forkfd_info info; int ret; - EINTR_LOOP(ret, forkfd_wait(forkfd, &info, Q_NULLPTR)); + EINTR_LOOP(ret, forkfd_wait(forkfd, &info, nullptr)); exitCode = info.status; crashed = info.code != CLD_EXITED; diff --git a/src/corelib/io/qprocess_win.cpp b/src/corelib/io/qprocess_win.cpp index 2bbc4eddd0..fbbfac26f6 100644 --- a/src/corelib/io/qprocess_win.cpp +++ b/src/corelib/io/qprocess_win.cpp @@ -115,9 +115,7 @@ static void qt_create_pipe(Q_PIPE *pipe, bool isInputPipe) dwOpenMode |= PIPE_ACCESS_INBOUND; dwInputBufferSize = dwPipeBufferSize; } - DWORD dwPipeFlags = PIPE_TYPE_BYTE | PIPE_WAIT; - if (QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA) - dwPipeFlags |= PIPE_REJECT_REMOTE_CLIENTS; + DWORD dwPipeFlags = PIPE_TYPE_BYTE | PIPE_WAIT | PIPE_REJECT_REMOTE_CLIENTS; hServer = CreateNamedPipe(pipeName, dwOpenMode, dwPipeFlags, diff --git a/src/corelib/io/qresource.cpp b/src/corelib/io/qresource.cpp index c1187e5145..9a63374e6f 100644 --- a/src/corelib/io/qresource.cpp +++ b/src/corelib/io/qresource.cpp @@ -911,8 +911,8 @@ public: inline QDynamicBufferResourceRoot(const QString &_root) : root(_root), buffer(0) { } inline ~QDynamicBufferResourceRoot() { } inline const uchar *mappingBuffer() const { return buffer; } - virtual QString mappingRoot() const Q_DECL_OVERRIDE { return root; } - virtual ResourceRootType type() const Q_DECL_OVERRIDE { return Resource_Buffer; } + virtual QString mappingRoot() const override { return root; } + virtual ResourceRootType type() const override { return Resource_Buffer; } // size == -1 means "unknown" bool registerSelf(const uchar *b, int size) @@ -994,7 +994,7 @@ public: } } QString mappingFile() const { return fileName; } - virtual ResourceRootType type() const Q_DECL_OVERRIDE { return Resource_File; } + virtual ResourceRootType type() const override { return Resource_File; } bool registerSelf(const QString &f) { bool fromMM = false; diff --git a/src/corelib/io/qresource_iterator_p.h b/src/corelib/io/qresource_iterator_p.h index 6a4e215864..207a88b0ba 100644 --- a/src/corelib/io/qresource_iterator_p.h +++ b/src/corelib/io/qresource_iterator_p.h @@ -63,10 +63,10 @@ public: QResourceFileEngineIterator(QDir::Filters filters, const QStringList &filterNames); ~QResourceFileEngineIterator(); - QString next() Q_DECL_OVERRIDE; - bool hasNext() const Q_DECL_OVERRIDE; + QString next() override; + bool hasNext() const override; - QString currentFileName() const Q_DECL_OVERRIDE; + QString currentFileName() const override; private: mutable QStringList entries; diff --git a/src/corelib/io/qresource_p.h b/src/corelib/io/qresource_p.h index e08ba64d2b..dcfe46704c 100644 --- a/src/corelib/io/qresource_p.h +++ b/src/corelib/io/qresource_p.h @@ -64,52 +64,52 @@ public: explicit QResourceFileEngine(const QString &path); ~QResourceFileEngine(); - virtual void setFileName(const QString &file) Q_DECL_OVERRIDE; + virtual void setFileName(const QString &file) override; - virtual bool open(QIODevice::OpenMode flags) Q_DECL_OVERRIDE ; - virtual bool close() Q_DECL_OVERRIDE; - virtual bool flush() Q_DECL_OVERRIDE; - virtual qint64 size() const Q_DECL_OVERRIDE; - virtual qint64 pos() const Q_DECL_OVERRIDE; + virtual bool open(QIODevice::OpenMode flags) override ; + virtual bool close() override; + virtual bool flush() override; + virtual qint64 size() const override; + virtual qint64 pos() const override; virtual bool atEnd() const; - virtual bool seek(qint64) Q_DECL_OVERRIDE; - virtual qint64 read(char *data, qint64 maxlen) Q_DECL_OVERRIDE; - virtual qint64 write(const char *data, qint64 len) Q_DECL_OVERRIDE; + virtual bool seek(qint64) override; + virtual qint64 read(char *data, qint64 maxlen) override; + virtual qint64 write(const char *data, qint64 len) override; - virtual bool remove() Q_DECL_OVERRIDE; - virtual bool copy(const QString &newName) Q_DECL_OVERRIDE; - virtual bool rename(const QString &newName) Q_DECL_OVERRIDE; - virtual bool link(const QString &newName) Q_DECL_OVERRIDE; + virtual bool remove() override; + virtual bool copy(const QString &newName) override; + virtual bool rename(const QString &newName) override; + virtual bool link(const QString &newName) override; - virtual bool isSequential() const Q_DECL_OVERRIDE; + virtual bool isSequential() const override; - virtual bool isRelativePath() const Q_DECL_OVERRIDE; + virtual bool isRelativePath() const override; - virtual bool mkdir(const QString &dirName, bool createParentDirectories) const Q_DECL_OVERRIDE; - virtual bool rmdir(const QString &dirName, bool recurseParentDirectories) const Q_DECL_OVERRIDE; + virtual bool mkdir(const QString &dirName, bool createParentDirectories) const override; + virtual bool rmdir(const QString &dirName, bool recurseParentDirectories) const override; - virtual bool setSize(qint64 size) Q_DECL_OVERRIDE; + virtual bool setSize(qint64 size) override; - virtual QStringList entryList(QDir::Filters filters, const QStringList &filterNames) const Q_DECL_OVERRIDE; + virtual QStringList entryList(QDir::Filters filters, const QStringList &filterNames) const override; - virtual bool caseSensitive() const Q_DECL_OVERRIDE; + virtual bool caseSensitive() const override; - virtual FileFlags fileFlags(FileFlags type) const Q_DECL_OVERRIDE; + virtual FileFlags fileFlags(FileFlags type) const override; - virtual bool setPermissions(uint perms) Q_DECL_OVERRIDE; + virtual bool setPermissions(uint perms) override; - virtual QString fileName(QAbstractFileEngine::FileName file) const Q_DECL_OVERRIDE; + virtual QString fileName(QAbstractFileEngine::FileName file) const override; - virtual uint ownerId(FileOwner) const Q_DECL_OVERRIDE; - virtual QString owner(FileOwner) const Q_DECL_OVERRIDE; + virtual uint ownerId(FileOwner) const override; + virtual QString owner(FileOwner) const override; - virtual QDateTime fileTime(FileTime time) const Q_DECL_OVERRIDE; + virtual QDateTime fileTime(FileTime time) const override; - virtual Iterator *beginEntryList(QDir::Filters filters, const QStringList &filterNames) Q_DECL_OVERRIDE; - virtual Iterator *endEntryList() Q_DECL_OVERRIDE; + virtual Iterator *beginEntryList(QDir::Filters filters, const QStringList &filterNames) override; + virtual Iterator *endEntryList() override; - bool extension(Extension extension, const ExtensionOption *option = 0, ExtensionReturn *output = 0) Q_DECL_OVERRIDE; - bool supportsExtension(Extension extension) const Q_DECL_OVERRIDE; + bool extension(Extension extension, const ExtensionOption *option = 0, ExtensionReturn *output = 0) override; + bool supportsExtension(Extension extension) const override; }; QT_END_NAMESPACE diff --git a/src/corelib/io/qsavefile.h b/src/corelib/io/qsavefile.h index 09d6e29272..200068d30d 100644 --- a/src/corelib/io/qsavefile.h +++ b/src/corelib/io/qsavefile.h @@ -67,15 +67,15 @@ public: explicit QSaveFile(const QString &name); #ifndef QT_NO_QOBJECT - explicit QSaveFile(QObject *parent = Q_NULLPTR); + explicit QSaveFile(QObject *parent = nullptr); explicit QSaveFile(const QString &name, QObject *parent); #endif ~QSaveFile(); - QString fileName() const Q_DECL_OVERRIDE; + QString fileName() const override; void setFileName(const QString &name); - bool open(OpenMode flags) Q_DECL_OVERRIDE; + bool open(OpenMode flags) override; bool commit(); void cancelWriting(); @@ -84,10 +84,10 @@ public: bool directWriteFallback() const; protected: - qint64 writeData(const char *data, qint64 len) Q_DECL_OVERRIDE; + qint64 writeData(const char *data, qint64 len) override; private: - void close() Q_DECL_OVERRIDE; + void close() override; #if !QT_CONFIG(translation) static QString tr(const char *string) { return QString::fromLatin1(string); } #endif diff --git a/src/corelib/io/qsettings.h b/src/corelib/io/qsettings.h index da5502e5ca..f34e6bea1b 100644 --- a/src/corelib/io/qsettings.h +++ b/src/corelib/io/qsettings.h @@ -125,13 +125,13 @@ public: #ifndef QT_NO_QOBJECT explicit QSettings(const QString &organization, - const QString &application = QString(), QObject *parent = Q_NULLPTR); + const QString &application = QString(), QObject *parent = nullptr); QSettings(Scope scope, const QString &organization, - const QString &application = QString(), QObject *parent = Q_NULLPTR); + const QString &application = QString(), QObject *parent = nullptr); QSettings(Format format, Scope scope, const QString &organization, - const QString &application = QString(), QObject *parent = Q_NULLPTR); - QSettings(const QString &fileName, Format format, QObject *parent = Q_NULLPTR); - explicit QSettings(QObject *parent = Q_NULLPTR); + const QString &application = QString(), QObject *parent = nullptr); + QSettings(const QString &fileName, Format format, QObject *parent = nullptr); + explicit QSettings(QObject *parent = nullptr); #else explicit QSettings(const QString &organization, const QString &application = QString()); @@ -199,7 +199,7 @@ public: protected: #ifndef QT_NO_QOBJECT - bool event(QEvent *event) Q_DECL_OVERRIDE; + bool event(QEvent *event) override; #endif private: diff --git a/src/corelib/io/qsettings_mac.cpp b/src/corelib/io/qsettings_mac.cpp index 2a08ee2e64..aa14d8435a 100644 --- a/src/corelib/io/qsettings_mac.cpp +++ b/src/corelib/io/qsettings_mac.cpp @@ -616,7 +616,7 @@ bool QConfFileSettingsPrivate::readPlistFile(const QByteArray &data, ParsedSetti { QCFType<CFDataRef> cfData = data.toRawCFData(); QCFType<CFPropertyListRef> propertyList = - CFPropertyListCreateWithData(kCFAllocatorDefault, cfData, kCFPropertyListImmutable, Q_NULLPTR, Q_NULLPTR); + CFPropertyListCreateWithData(kCFAllocatorDefault, cfData, kCFPropertyListImmutable, nullptr, nullptr); if (!propertyList) return true; diff --git a/src/corelib/io/qsettings_p.h b/src/corelib/io/qsettings_p.h index 7923c24770..d18c96a06c 100644 --- a/src/corelib/io/qsettings_p.h +++ b/src/corelib/io/qsettings_p.h @@ -261,17 +261,17 @@ public: QConfFileSettingsPrivate(const QString &fileName, QSettings::Format format); ~QConfFileSettingsPrivate(); - void remove(const QString &key) Q_DECL_OVERRIDE; - void set(const QString &key, const QVariant &value) Q_DECL_OVERRIDE; - bool get(const QString &key, QVariant *value) const Q_DECL_OVERRIDE; + void remove(const QString &key) override; + void set(const QString &key, const QVariant &value) override; + bool get(const QString &key, QVariant *value) const override; - QStringList children(const QString &prefix, ChildSpec spec) const Q_DECL_OVERRIDE; + QStringList children(const QString &prefix, ChildSpec spec) const override; - void clear() Q_DECL_OVERRIDE; - void sync() Q_DECL_OVERRIDE; - void flush() Q_DECL_OVERRIDE; - bool isWritable() const Q_DECL_OVERRIDE; - QString fileName() const Q_DECL_OVERRIDE; + void clear() override; + void sync() override; + void flush() override; + bool isWritable() const override; + QString fileName() const override; bool readIniFile(const QByteArray &data, UnparsedSettingsMap *unparsedIniSections); static bool readIniSection(const QSettingsKey §ion, const QByteArray &data, diff --git a/src/corelib/io/qstandardpaths_mac.mm b/src/corelib/io/qstandardpaths_mac.mm index e25339a7d1..3bb7a7877a 100644 --- a/src/corelib/io/qstandardpaths_mac.mm +++ b/src/corelib/io/qstandardpaths_mac.mm @@ -203,28 +203,17 @@ QStringList QStandardPaths::standardLocations(StandardLocation type) if (type == AppDataLocation || type == AppLocalDataLocation) { CFBundleRef mainBundle = CFBundleGetMainBundle(); if (mainBundle) { - CFURLRef bundleUrl = CFBundleCopyBundleURL(mainBundle); - CFStringRef cfBundlePath = CFURLCopyFileSystemPath(bundleUrl, kCFURLPOSIXPathStyle); - QString bundlePath = QString::fromCFString(cfBundlePath); - CFRelease(cfBundlePath); - CFRelease(bundleUrl); - - CFURLRef resourcesUrl = CFBundleCopyResourcesDirectoryURL(mainBundle); - CFStringRef cfResourcesPath = CFURLCopyFileSystemPath(resourcesUrl, - kCFURLPOSIXPathStyle); - QString resourcesPath = QString::fromCFString(cfResourcesPath); - CFRelease(cfResourcesPath); - CFRelease(resourcesUrl); - - // Handle bundled vs unbundled executables. CFBundleGetMainBundle() returns - // a valid bundle in both cases. CFBundleCopyResourcesDirectoryURL() returns - // an absolute path for unbundled executables. - if (resourcesPath.startsWith(QLatin1Char('/'))) - dirs.append(resourcesPath); - else - dirs.append(bundlePath + resourcesPath); + if (QCFType<CFURLRef> resourcesURL = CFBundleCopyResourcesDirectoryURL(mainBundle)) { + if (QCFType<CFURLRef> absoluteResouresURL = CFURLCopyAbsoluteURL(resourcesURL)) { + if (QCFType<CFStringRef> path = CFURLCopyFileSystemPath(absoluteResouresURL, + kCFURLPOSIXPathStyle)) { + dirs.append(QString::fromCFString(path)); + } + } + } } } + const QString localDir = writableLocation(type); if (!localDir.isEmpty()) dirs.prepend(localDir); diff --git a/src/corelib/io/qstorageinfo_mac.cpp b/src/corelib/io/qstorageinfo_mac.cpp index 0f271f2bc6..8b06543d71 100644 --- a/src/corelib/io/qstorageinfo_mac.cpp +++ b/src/corelib/io/qstorageinfo_mac.cpp @@ -112,7 +112,7 @@ void QStorageInfoPrivate::retrieveUrlProperties(bool initRootPath) QCFType<CFArrayRef> keys = CFArrayCreate(kCFAllocatorDefault, initRootPath ? rootPathKeys : propertyKeys, size, - Q_NULLPTR); + nullptr); if (!keys) return; @@ -178,9 +178,9 @@ QList<QStorageInfo> QStorageInfoPrivate::mountedVolumes() QList<QStorageInfo> volumes; QCFType<CFURLEnumeratorRef> enumerator; - enumerator = CFURLEnumeratorCreateForMountedVolumes(Q_NULLPTR, + enumerator = CFURLEnumeratorCreateForMountedVolumes(nullptr, kCFURLEnumeratorSkipInvisibles, - Q_NULLPTR); + nullptr); CFURLEnumeratorResult result = kCFURLEnumeratorSuccess; do { diff --git a/src/corelib/io/qstorageinfo_unix.cpp b/src/corelib/io/qstorageinfo_unix.cpp index 9072b34f54..0911083bac 100644 --- a/src/corelib/io/qstorageinfo_unix.cpp +++ b/src/corelib/io/qstorageinfo_unix.cpp @@ -257,7 +257,7 @@ inline QStorageIterator::~QStorageIterator() inline bool QStorageIterator::isValid() const { - return fp != Q_NULLPTR; + return fp != nullptr; } inline bool QStorageIterator::next() @@ -357,12 +357,12 @@ inline QStorageIterator::~QStorageIterator() inline bool QStorageIterator::isValid() const { - return fp != Q_NULLPTR; + return fp != nullptr; } inline bool QStorageIterator::next() { - return ::getmntent_r(fp, &mnt, buffer.data(), buffer.size()) != Q_NULLPTR; + return ::getmntent_r(fp, &mnt, buffer.data(), buffer.size()) != nullptr; } inline QString QStorageIterator::rootPath() const diff --git a/src/corelib/io/qstorageinfo_win.cpp b/src/corelib/io/qstorageinfo_win.cpp index 3830c5480c..8a3db90f87 100644 --- a/src/corelib/io/qstorageinfo_win.cpp +++ b/src/corelib/io/qstorageinfo_win.cpp @@ -147,8 +147,8 @@ void QStorageInfoPrivate::retrieveVolumeInfo() const bool result = ::GetVolumeInformation(reinterpret_cast<const wchar_t *>(path.utf16()), nameBuffer, defaultBufferSize, - Q_NULLPTR, - Q_NULLPTR, + nullptr, + nullptr, &fileSystemFlags, fileSystemTypeBuffer, defaultBufferSize); diff --git a/src/corelib/io/qtemporarydir.cpp b/src/corelib/io/qtemporarydir.cpp index 2779246c5b..ed52472ab3 100644 --- a/src/corelib/io/qtemporarydir.cpp +++ b/src/corelib/io/qtemporarydir.cpp @@ -42,12 +42,12 @@ #ifndef QT_NO_TEMPORARYFILE +#include "qdebug.h" #include "qdiriterator.h" +#include "qpair.h" #include "qplatformdefs.h" +#include "qrandom.h" #include "private/qtemporaryfile_p.h" -#include <QDebug> -#include <QPair> -#include <QRandomGenerator> #if defined(QT_BUILD_CORE_LIB) #include "qcoreapplication.h" diff --git a/src/corelib/io/qtemporarydir.h b/src/corelib/io/qtemporarydir.h index 3f6b70a2eb..5864ce5cfc 100644 --- a/src/corelib/io/qtemporarydir.h +++ b/src/corelib/io/qtemporarydir.h @@ -41,7 +41,7 @@ #define QTEMPORARYDIR_H #include <QtCore/qdir.h> -#include <QtCore/QScopedPointer> +#include <QtCore/qscopedpointer.h> QT_BEGIN_NAMESPACE diff --git a/src/corelib/io/qtemporaryfile.h b/src/corelib/io/qtemporaryfile.h index 7fc5a299fc..90a6a613e6 100644 --- a/src/corelib/io/qtemporaryfile.h +++ b/src/corelib/io/qtemporaryfile.h @@ -77,7 +77,7 @@ public: // ### Hides open(flags) bool open() { return open(QIODevice::ReadWrite); } - QString fileName() const Q_DECL_OVERRIDE; + QString fileName() const override; QString fileTemplate() const; void setFileTemplate(const QString &name); @@ -95,7 +95,7 @@ public: static QTemporaryFile *createNativeFile(QFile &file); protected: - bool open(OpenMode flags) Q_DECL_OVERRIDE; + bool open(OpenMode flags) override; private: friend class QFile; diff --git a/src/corelib/io/qtextstream.h b/src/corelib/io/qtextstream.h index e72b7942fd..ee0b09419d 100644 --- a/src/corelib/io/qtextstream.h +++ b/src/corelib/io/qtextstream.h @@ -212,8 +212,8 @@ typedef void (QTextStream::*QTSMFC)(QChar); // manipulator w/QChar argument class Q_CORE_EXPORT QTextStreamManipulator { public: - Q_DECL_CONSTEXPR QTextStreamManipulator(QTSMFI m, int a) Q_DECL_NOTHROW : mf(m), mc(Q_NULLPTR), arg(a), ch() {} - Q_DECL_CONSTEXPR QTextStreamManipulator(QTSMFC m, QChar c) Q_DECL_NOTHROW : mf(Q_NULLPTR), mc(m), arg(-1), ch(c) {} + Q_DECL_CONSTEXPR QTextStreamManipulator(QTSMFI m, int a) Q_DECL_NOTHROW : mf(m), mc(nullptr), arg(a), ch() {} + Q_DECL_CONSTEXPR QTextStreamManipulator(QTSMFC m, QChar c) Q_DECL_NOTHROW : mf(nullptr), mc(m), arg(-1), ch(c) {} void exec(QTextStream &s) { if (mf) { (s.*mf)(arg); } else { (s.*mc)(ch); } } private: diff --git a/src/corelib/io/qurl.h b/src/corelib/io/qurl.h index 0bb8707ff9..5062ef7905 100644 --- a/src/corelib/io/qurl.h +++ b/src/corelib/io/qurl.h @@ -184,7 +184,7 @@ public: #endif #ifdef Q_COMPILER_RVALUE_REFS QUrl(QUrl &&other) Q_DECL_NOTHROW : d(other.d) - { other.d = Q_NULLPTR; } + { other.d = nullptr; } inline QUrl &operator=(QUrl &&other) Q_DECL_NOTHROW { qSwap(d, other.d); return *this; } #endif diff --git a/src/corelib/itemmodels/qabstractitemmodel.cpp b/src/corelib/itemmodels/qabstractitemmodel.cpp index f893cf06e3..44622a0ad9 100644 --- a/src/corelib/itemmodels/qabstractitemmodel.cpp +++ b/src/corelib/itemmodels/qabstractitemmodel.cpp @@ -482,12 +482,12 @@ class QEmptyItemModel : public QAbstractItemModel { public: explicit QEmptyItemModel(QObject *parent = 0) : QAbstractItemModel(parent) {} - QModelIndex index(int, int, const QModelIndex &) const Q_DECL_OVERRIDE { return QModelIndex(); } - QModelIndex parent(const QModelIndex &) const Q_DECL_OVERRIDE { return QModelIndex(); } - int rowCount(const QModelIndex &) const Q_DECL_OVERRIDE { return 0; } - int columnCount(const QModelIndex &) const Q_DECL_OVERRIDE { return 0; } - bool hasChildren(const QModelIndex &) const Q_DECL_OVERRIDE { return false; } - QVariant data(const QModelIndex &, int) const Q_DECL_OVERRIDE { return QVariant(); } + QModelIndex index(int, int, const QModelIndex &) const override { return QModelIndex(); } + QModelIndex parent(const QModelIndex &) const override { return QModelIndex(); } + int rowCount(const QModelIndex &) const override { return 0; } + int columnCount(const QModelIndex &) const override { return 0; } + bool hasChildren(const QModelIndex &) const override { return false; } + QVariant data(const QModelIndex &, int) const override { return QVariant(); } }; Q_GLOBAL_STATIC(QEmptyItemModel, qEmptyModel) diff --git a/src/corelib/itemmodels/qabstractitemmodel.h b/src/corelib/itemmodels/qabstractitemmodel.h index a211d8e8ca..cd294ef8fa 100644 --- a/src/corelib/itemmodels/qabstractitemmodel.h +++ b/src/corelib/itemmodels/qabstractitemmodel.h @@ -55,7 +55,7 @@ class Q_CORE_EXPORT QModelIndex { friend class QAbstractItemModel; public: - Q_DECL_CONSTEXPR inline QModelIndex() Q_DECL_NOTHROW : r(-1), c(-1), i(0), m(Q_NULLPTR) {} + Q_DECL_CONSTEXPR inline QModelIndex() Q_DECL_NOTHROW : r(-1), c(-1), i(0), m(nullptr) {} // compiler-generated copy/move ctors/assignment operators are fine! Q_DECL_CONSTEXPR inline int row() const Q_DECL_NOTHROW { return r; } Q_DECL_CONSTEXPR inline int column() const Q_DECL_NOTHROW { return c; } @@ -69,7 +69,7 @@ public: inline QVariant data(int role = Qt::DisplayRole) const; inline Qt::ItemFlags flags() const; Q_DECL_CONSTEXPR inline const QAbstractItemModel *model() const Q_DECL_NOTHROW { return m; } - Q_DECL_CONSTEXPR inline bool isValid() const Q_DECL_NOTHROW { return (r >= 0) && (c >= 0) && (m != Q_NULLPTR); } + Q_DECL_CONSTEXPR inline bool isValid() const Q_DECL_NOTHROW { return (r >= 0) && (c >= 0) && (m != nullptr); } Q_DECL_CONSTEXPR inline bool operator==(const QModelIndex &other) const Q_DECL_NOTHROW { return (other.r == r) && (other.i == i) && (other.c == c) && (other.m == m); } Q_DECL_CONSTEXPR inline bool operator!=(const QModelIndex &other) const Q_DECL_NOTHROW @@ -115,7 +115,7 @@ public: QPersistentModelIndex &operator=(const QPersistentModelIndex &other); #ifdef Q_COMPILER_RVALUE_REFS inline QPersistentModelIndex(QPersistentModelIndex &&other) Q_DECL_NOTHROW - : d(other.d) { other.d = Q_NULLPTR; } + : d(other.d) { other.d = nullptr; } inline QPersistentModelIndex &operator=(QPersistentModelIndex &&other) Q_DECL_NOTHROW { qSwap(d, other.d); return *this; } #endif @@ -171,7 +171,7 @@ class Q_CORE_EXPORT QAbstractItemModel : public QObject friend class QIdentityProxyModel; public: - explicit QAbstractItemModel(QObject *parent = Q_NULLPTR); + explicit QAbstractItemModel(QObject *parent = nullptr); virtual ~QAbstractItemModel(); Q_INVOKABLE bool hasIndex(int row, int column, const QModelIndex &parent = QModelIndex()) const; @@ -286,9 +286,9 @@ protected Q_SLOTS: void resetInternalData(); protected: - QAbstractItemModel(QAbstractItemModelPrivate &dd, QObject *parent = Q_NULLPTR); + QAbstractItemModel(QAbstractItemModelPrivate &dd, QObject *parent = nullptr); - inline QModelIndex createIndex(int row, int column, void *data = Q_NULLPTR) const; + inline QModelIndex createIndex(int row, int column, void *data = nullptr) const; inline QModelIndex createIndex(int row, int column, quintptr id) const; void encodeData(const QModelIndexList &indexes, QDataStream &stream) const; @@ -367,15 +367,15 @@ class Q_CORE_EXPORT QAbstractTableModel : public QAbstractItemModel Q_OBJECT public: - explicit QAbstractTableModel(QObject *parent = Q_NULLPTR); + explicit QAbstractTableModel(QObject *parent = nullptr); ~QAbstractTableModel(); - QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; - QModelIndex sibling(int row, int column, const QModelIndex &idx) const Q_DECL_OVERRIDE; + QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override; + QModelIndex sibling(int row, int column, const QModelIndex &idx) const override; bool dropMimeData(const QMimeData *data, Qt::DropAction action, - int row, int column, const QModelIndex &parent) Q_DECL_OVERRIDE; + int row, int column, const QModelIndex &parent) override; - Qt::ItemFlags flags(const QModelIndex &index) const Q_DECL_OVERRIDE; + Qt::ItemFlags flags(const QModelIndex &index) const override; using QObject::parent; @@ -384,8 +384,8 @@ protected: private: Q_DISABLE_COPY(QAbstractTableModel) - QModelIndex parent(const QModelIndex &child) const Q_DECL_OVERRIDE; - bool hasChildren(const QModelIndex &parent) const Q_DECL_OVERRIDE; + QModelIndex parent(const QModelIndex &child) const override; + bool hasChildren(const QModelIndex &parent) const override; }; class Q_CORE_EXPORT QAbstractListModel : public QAbstractItemModel @@ -393,15 +393,15 @@ class Q_CORE_EXPORT QAbstractListModel : public QAbstractItemModel Q_OBJECT public: - explicit QAbstractListModel(QObject *parent = Q_NULLPTR); + explicit QAbstractListModel(QObject *parent = nullptr); ~QAbstractListModel(); - QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; - QModelIndex sibling(int row, int column, const QModelIndex &idx) const Q_DECL_OVERRIDE; + QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const override; + QModelIndex sibling(int row, int column, const QModelIndex &idx) const override; bool dropMimeData(const QMimeData *data, Qt::DropAction action, - int row, int column, const QModelIndex &parent) Q_DECL_OVERRIDE; + int row, int column, const QModelIndex &parent) override; - Qt::ItemFlags flags(const QModelIndex &index) const Q_DECL_OVERRIDE; + Qt::ItemFlags flags(const QModelIndex &index) const override; using QObject::parent; @@ -410,9 +410,9 @@ protected: private: Q_DISABLE_COPY(QAbstractListModel) - QModelIndex parent(const QModelIndex &child) const Q_DECL_OVERRIDE; - int columnCount(const QModelIndex &parent) const Q_DECL_OVERRIDE; - bool hasChildren(const QModelIndex &parent) const Q_DECL_OVERRIDE; + QModelIndex parent(const QModelIndex &child) const override; + int columnCount(const QModelIndex &parent) const override; + bool hasChildren(const QModelIndex &parent) const override; }; // inline implementations diff --git a/src/corelib/itemmodels/qabstractproxymodel.h b/src/corelib/itemmodels/qabstractproxymodel.h index c9eafa09ee..6aa82b21ee 100644 --- a/src/corelib/itemmodels/qabstractproxymodel.h +++ b/src/corelib/itemmodels/qabstractproxymodel.h @@ -56,7 +56,7 @@ class Q_CORE_EXPORT QAbstractProxyModel : public QAbstractItemModel Q_PROPERTY(QAbstractItemModel* sourceModel READ sourceModel WRITE setSourceModel NOTIFY sourceModelChanged) public: - explicit QAbstractProxyModel(QObject *parent = Q_NULLPTR); + explicit QAbstractProxyModel(QObject *parent = nullptr); ~QAbstractProxyModel(); virtual void setSourceModel(QAbstractItemModel *sourceModel); @@ -68,34 +68,34 @@ public: Q_INVOKABLE virtual QItemSelection mapSelectionToSource(const QItemSelection &selection) const; Q_INVOKABLE virtual QItemSelection mapSelectionFromSource(const QItemSelection &selection) const; - bool submit() Q_DECL_OVERRIDE; - void revert() Q_DECL_OVERRIDE; + bool submit() override; + void revert() override; - QVariant data(const QModelIndex &proxyIndex, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE; - QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE; - QMap<int, QVariant> itemData(const QModelIndex &index) const Q_DECL_OVERRIDE; - Qt::ItemFlags flags(const QModelIndex &index) const Q_DECL_OVERRIDE; + QVariant data(const QModelIndex &proxyIndex, int role = Qt::DisplayRole) const override; + QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; + QMap<int, QVariant> itemData(const QModelIndex &index) const override; + Qt::ItemFlags flags(const QModelIndex &index) const override; - bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) Q_DECL_OVERRIDE; - bool setItemData(const QModelIndex& index, const QMap<int, QVariant> &roles) Q_DECL_OVERRIDE; - bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role = Qt::EditRole) Q_DECL_OVERRIDE; + bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override; + bool setItemData(const QModelIndex& index, const QMap<int, QVariant> &roles) override; + bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role = Qt::EditRole) override; - QModelIndex buddy(const QModelIndex &index) const Q_DECL_OVERRIDE; - bool canFetchMore(const QModelIndex &parent) const Q_DECL_OVERRIDE; - void fetchMore(const QModelIndex &parent) Q_DECL_OVERRIDE; - void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) Q_DECL_OVERRIDE; - QSize span(const QModelIndex &index) const Q_DECL_OVERRIDE; - bool hasChildren(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; - QModelIndex sibling(int row, int column, const QModelIndex &idx) const Q_DECL_OVERRIDE; + QModelIndex buddy(const QModelIndex &index) const override; + bool canFetchMore(const QModelIndex &parent) const override; + void fetchMore(const QModelIndex &parent) override; + void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override; + QSize span(const QModelIndex &index) const override; + bool hasChildren(const QModelIndex &parent = QModelIndex()) const override; + QModelIndex sibling(int row, int column, const QModelIndex &idx) const override; - QMimeData* mimeData(const QModelIndexList &indexes) const Q_DECL_OVERRIDE; + QMimeData* mimeData(const QModelIndexList &indexes) const override; bool canDropMimeData(const QMimeData *data, Qt::DropAction action, - int row, int column, const QModelIndex &parent) const Q_DECL_OVERRIDE; + int row, int column, const QModelIndex &parent) const override; bool dropMimeData(const QMimeData *data, Qt::DropAction action, - int row, int column, const QModelIndex &parent) Q_DECL_OVERRIDE; - QStringList mimeTypes() const Q_DECL_OVERRIDE; - Qt::DropActions supportedDragActions() const Q_DECL_OVERRIDE; - Qt::DropActions supportedDropActions() const Q_DECL_OVERRIDE; + int row, int column, const QModelIndex &parent) override; + QStringList mimeTypes() const override; + Qt::DropActions supportedDragActions() const override; + Qt::DropActions supportedDropActions() const override; Q_SIGNALS: void sourceModelChanged(QPrivateSignal); diff --git a/src/corelib/itemmodels/qidentityproxymodel.h b/src/corelib/itemmodels/qidentityproxymodel.h index e93740c1a2..d2b1ed9498 100644 --- a/src/corelib/itemmodels/qidentityproxymodel.h +++ b/src/corelib/itemmodels/qidentityproxymodel.h @@ -54,29 +54,29 @@ class Q_CORE_EXPORT QIdentityProxyModel : public QAbstractProxyModel { Q_OBJECT public: - explicit QIdentityProxyModel(QObject* parent = Q_NULLPTR); + explicit QIdentityProxyModel(QObject* parent = nullptr); ~QIdentityProxyModel(); - int columnCount(const QModelIndex& parent = QModelIndex()) const Q_DECL_OVERRIDE; - QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const Q_DECL_OVERRIDE; - QModelIndex mapFromSource(const QModelIndex& sourceIndex) const Q_DECL_OVERRIDE; - QModelIndex mapToSource(const QModelIndex& proxyIndex) const Q_DECL_OVERRIDE; - QModelIndex parent(const QModelIndex& child) const Q_DECL_OVERRIDE; + int columnCount(const QModelIndex& parent = QModelIndex()) const override; + QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override; + QModelIndex mapFromSource(const QModelIndex& sourceIndex) const override; + QModelIndex mapToSource(const QModelIndex& proxyIndex) const override; + QModelIndex parent(const QModelIndex& child) const override; using QObject::parent; - int rowCount(const QModelIndex& parent = QModelIndex()) const Q_DECL_OVERRIDE; - QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE; - bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent) Q_DECL_OVERRIDE; - QModelIndex sibling(int row, int column, const QModelIndex &idx) const Q_DECL_OVERRIDE; - - QItemSelection mapSelectionFromSource(const QItemSelection& selection) const Q_DECL_OVERRIDE; - QItemSelection mapSelectionToSource(const QItemSelection& selection) const Q_DECL_OVERRIDE; - QModelIndexList match(const QModelIndex& start, int role, const QVariant& value, int hits = 1, Qt::MatchFlags flags = Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) const Q_DECL_OVERRIDE; - void setSourceModel(QAbstractItemModel* sourceModel) Q_DECL_OVERRIDE; - - bool insertColumns(int column, int count, const QModelIndex& parent = QModelIndex()) Q_DECL_OVERRIDE; - bool insertRows(int row, int count, const QModelIndex& parent = QModelIndex()) Q_DECL_OVERRIDE; - bool removeColumns(int column, int count, const QModelIndex& parent = QModelIndex()) Q_DECL_OVERRIDE; - bool removeRows(int row, int count, const QModelIndex& parent = QModelIndex()) Q_DECL_OVERRIDE; + int rowCount(const QModelIndex& parent = QModelIndex()) const override; + QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; + bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent) override; + QModelIndex sibling(int row, int column, const QModelIndex &idx) const override; + + QItemSelection mapSelectionFromSource(const QItemSelection& selection) const override; + QItemSelection mapSelectionToSource(const QItemSelection& selection) const override; + QModelIndexList match(const QModelIndex& start, int role, const QVariant& value, int hits = 1, Qt::MatchFlags flags = Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) const override; + void setSourceModel(QAbstractItemModel* sourceModel) override; + + bool insertColumns(int column, int count, const QModelIndex& parent = QModelIndex()) override; + bool insertRows(int row, int count, const QModelIndex& parent = QModelIndex()) override; + bool removeColumns(int column, int count, const QModelIndex& parent = QModelIndex()) override; + bool removeRows(int row, int count, const QModelIndex& parent = QModelIndex()) override; protected: QIdentityProxyModel(QIdentityProxyModelPrivate &dd, QObject* parent); diff --git a/src/corelib/itemmodels/qitemselectionmodel.h b/src/corelib/itemmodels/qitemselectionmodel.h index 9d33303ddc..091c5a21a5 100644 --- a/src/corelib/itemmodels/qitemselectionmodel.h +++ b/src/corelib/itemmodels/qitemselectionmodel.h @@ -164,7 +164,7 @@ public: Q_DECLARE_FLAGS(SelectionFlags, SelectionFlag) Q_FLAG(SelectionFlags) - explicit QItemSelectionModel(QAbstractItemModel *model = Q_NULLPTR); + explicit QItemSelectionModel(QAbstractItemModel *model = nullptr); explicit QItemSelectionModel(QAbstractItemModel *model, QObject *parent); virtual ~QItemSelectionModel(); diff --git a/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/src/corelib/itemmodels/qsortfilterproxymodel.cpp index ef3281df30..fad980f568 100644 --- a/src/corelib/itemmodels/qsortfilterproxymodel.cpp +++ b/src/corelib/itemmodels/qsortfilterproxymodel.cpp @@ -300,7 +300,7 @@ public: void updateChildrenMapping(const QModelIndex &source_parent, Mapping *parent_mapping, Qt::Orientation orient, int start, int end, int delta_item_count, bool remove); - virtual void _q_sourceModelDestroyed() Q_DECL_OVERRIDE; + virtual void _q_sourceModelDestroyed() override; bool needsReorder(const QVector<int> &source_rows, const QModelIndex &source_parent) const; diff --git a/src/corelib/itemmodels/qsortfilterproxymodel.h b/src/corelib/itemmodels/qsortfilterproxymodel.h index 6f2e9806ed..2f93836544 100644 --- a/src/corelib/itemmodels/qsortfilterproxymodel.h +++ b/src/corelib/itemmodels/qsortfilterproxymodel.h @@ -70,16 +70,16 @@ class Q_CORE_EXPORT QSortFilterProxyModel : public QAbstractProxyModel Q_PROPERTY(bool recursiveFiltering READ recursiveFiltering WRITE setRecursiveFiltering) public: - explicit QSortFilterProxyModel(QObject *parent = Q_NULLPTR); + explicit QSortFilterProxyModel(QObject *parent = nullptr); ~QSortFilterProxyModel(); - void setSourceModel(QAbstractItemModel *sourceModel) Q_DECL_OVERRIDE; + void setSourceModel(QAbstractItemModel *sourceModel) override; - QModelIndex mapToSource(const QModelIndex &proxyIndex) const Q_DECL_OVERRIDE; - QModelIndex mapFromSource(const QModelIndex &sourceIndex) const Q_DECL_OVERRIDE; + QModelIndex mapToSource(const QModelIndex &proxyIndex) const override; + QModelIndex mapFromSource(const QModelIndex &sourceIndex) const override; - QItemSelection mapSelectionToSource(const QItemSelection &proxySelection) const Q_DECL_OVERRIDE; - QItemSelection mapSelectionFromSource(const QItemSelection &sourceSelection) const Q_DECL_OVERRIDE; + QItemSelection mapSelectionToSource(const QItemSelection &proxySelection) const override; + QItemSelection mapSelectionFromSource(const QItemSelection &sourceSelection) const override; QRegExp filterRegExp() const; void setFilterRegExp(const QRegExp ®Exp); @@ -129,44 +129,44 @@ protected: public: using QObject::parent; - QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; - QModelIndex parent(const QModelIndex &child) const Q_DECL_OVERRIDE; - QModelIndex sibling(int row, int column, const QModelIndex &idx) const Q_DECL_OVERRIDE; + QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override; + QModelIndex parent(const QModelIndex &child) const override; + QModelIndex sibling(int row, int column, const QModelIndex &idx) const override; - int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; - int columnCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; - bool hasChildren(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; + int rowCount(const QModelIndex &parent = QModelIndex()) const override; + int columnCount(const QModelIndex &parent = QModelIndex()) const override; + bool hasChildren(const QModelIndex &parent = QModelIndex()) const override; - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE; - bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) Q_DECL_OVERRIDE; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override; - QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE; + QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; bool setHeaderData(int section, Qt::Orientation orientation, - const QVariant &value, int role = Qt::EditRole) Q_DECL_OVERRIDE; + const QVariant &value, int role = Qt::EditRole) override; - QMimeData *mimeData(const QModelIndexList &indexes) const Q_DECL_OVERRIDE; + QMimeData *mimeData(const QModelIndexList &indexes) const override; bool dropMimeData(const QMimeData *data, Qt::DropAction action, - int row, int column, const QModelIndex &parent) Q_DECL_OVERRIDE; + int row, int column, const QModelIndex &parent) override; - bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) Q_DECL_OVERRIDE; - bool insertColumns(int column, int count, const QModelIndex &parent = QModelIndex()) Q_DECL_OVERRIDE; - bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) Q_DECL_OVERRIDE; - bool removeColumns(int column, int count, const QModelIndex &parent = QModelIndex()) Q_DECL_OVERRIDE; + bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) override; + bool insertColumns(int column, int count, const QModelIndex &parent = QModelIndex()) override; + bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override; + bool removeColumns(int column, int count, const QModelIndex &parent = QModelIndex()) override; - void fetchMore(const QModelIndex &parent) Q_DECL_OVERRIDE; - bool canFetchMore(const QModelIndex &parent) const Q_DECL_OVERRIDE; - Qt::ItemFlags flags(const QModelIndex &index) const Q_DECL_OVERRIDE; + void fetchMore(const QModelIndex &parent) override; + bool canFetchMore(const QModelIndex &parent) const override; + Qt::ItemFlags flags(const QModelIndex &index) const override; - QModelIndex buddy(const QModelIndex &index) const Q_DECL_OVERRIDE; + QModelIndex buddy(const QModelIndex &index) const override; QModelIndexList match(const QModelIndex &start, int role, const QVariant &value, int hits = 1, Qt::MatchFlags flags = - Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) const Q_DECL_OVERRIDE; - QSize span(const QModelIndex &index) const Q_DECL_OVERRIDE; - void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) Q_DECL_OVERRIDE; + Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) const override; + QSize span(const QModelIndex &index) const override; + void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override; - QStringList mimeTypes() const Q_DECL_OVERRIDE; - Qt::DropActions supportedDropActions() const Q_DECL_OVERRIDE; + QStringList mimeTypes() const override; + Qt::DropActions supportedDropActions() const override; private: Q_DECLARE_PRIVATE(QSortFilterProxyModel) Q_DISABLE_COPY(QSortFilterProxyModel) diff --git a/src/corelib/itemmodels/qstringlistmodel.h b/src/corelib/itemmodels/qstringlistmodel.h index 3bda848f48..38da1022ea 100644 --- a/src/corelib/itemmodels/qstringlistmodel.h +++ b/src/corelib/itemmodels/qstringlistmodel.h @@ -52,26 +52,26 @@ class Q_CORE_EXPORT QStringListModel : public QAbstractListModel { Q_OBJECT public: - explicit QStringListModel(QObject *parent = Q_NULLPTR); - explicit QStringListModel(const QStringList &strings, QObject *parent = Q_NULLPTR); + explicit QStringListModel(QObject *parent = nullptr); + explicit QStringListModel(const QStringList &strings, QObject *parent = nullptr); - int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; - QModelIndex sibling(int row, int column, const QModelIndex &idx) const Q_DECL_OVERRIDE; + int rowCount(const QModelIndex &parent = QModelIndex()) const override; + QModelIndex sibling(int row, int column, const QModelIndex &idx) const override; - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE; - bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) Q_DECL_OVERRIDE; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override; - Qt::ItemFlags flags(const QModelIndex &index) const Q_DECL_OVERRIDE; + Qt::ItemFlags flags(const QModelIndex &index) const override; - bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) Q_DECL_OVERRIDE; - bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) Q_DECL_OVERRIDE; + bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) override; + bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override; - void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) Q_DECL_OVERRIDE; + void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override; QStringList stringList() const; void setStringList(const QStringList &strings); - Qt::DropActions supportedDropActions() const Q_DECL_OVERRIDE; + Qt::DropActions supportedDropActions() const override; private: Q_DISABLE_COPY(QStringListModel) diff --git a/src/corelib/json/qjsonarray.h b/src/corelib/json/qjsonarray.h index ddba2ca78e..8d41138c97 100644 --- a/src/corelib/json/qjsonarray.h +++ b/src/corelib/json/qjsonarray.h @@ -133,7 +133,7 @@ public: typedef QJsonValueRef reference; typedef QJsonValueRefPtr pointer; - inline iterator() : a(Q_NULLPTR), i(0) { } + inline iterator() : a(nullptr), i(0) { } explicit inline iterator(QJsonArray *array, int index) : a(array), i(index) { } inline QJsonValueRef operator*() const { return QJsonValueRef(a, i); } @@ -178,7 +178,7 @@ public: typedef QJsonValue reference; typedef QJsonValuePtr pointer; - inline const_iterator() : a(Q_NULLPTR), i(0) { } + inline const_iterator() : a(nullptr), i(0) { } explicit inline const_iterator(const QJsonArray *array, int index) : a(array), i(index) { } #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) inline const_iterator(const const_iterator &o) : a(o.a), i(o.i) {} // ### Qt 6: Removed so class can be trivially-copyable diff --git a/src/corelib/json/qjsondocument.h b/src/corelib/json/qjsondocument.h index 4e76af21e2..e1730cf374 100644 --- a/src/corelib/json/qjsondocument.h +++ b/src/corelib/json/qjsondocument.h @@ -129,7 +129,7 @@ public: Compact }; - static QJsonDocument fromJson(const QByteArray &json, QJsonParseError *error = Q_NULLPTR); + static QJsonDocument fromJson(const QByteArray &json, QJsonParseError *error = nullptr); #ifdef Q_QDOC QByteArray toJson(JsonFormat format = Indented) const; diff --git a/src/corelib/json/qjsonobject.h b/src/corelib/json/qjsonobject.h index c77e2164a8..610bce694c 100644 --- a/src/corelib/json/qjsonobject.h +++ b/src/corelib/json/qjsonobject.h @@ -135,7 +135,7 @@ public: typedef QJsonValueRef reference; typedef QJsonValuePtr pointer; - Q_DECL_CONSTEXPR inline iterator() : o(Q_NULLPTR), i(0) {} + Q_DECL_CONSTEXPR inline iterator() : o(nullptr), i(0) {} Q_DECL_CONSTEXPR inline iterator(QJsonObject *obj, int index) : o(obj), i(index) {} inline QString key() const { return o->keyAt(i); } @@ -178,7 +178,7 @@ public: typedef QJsonValue reference; typedef QJsonValuePtr pointer; - Q_DECL_CONSTEXPR inline const_iterator() : o(Q_NULLPTR), i(0) {} + Q_DECL_CONSTEXPR inline const_iterator() : o(nullptr), i(0) {} Q_DECL_CONSTEXPR inline const_iterator(const QJsonObject *obj, int index) : o(obj), i(index) {} inline const_iterator(const iterator &other) diff --git a/src/corelib/json/qjsonvalue.h b/src/corelib/json/qjsonvalue.h index 5d5ec72605..96538ebbf9 100644 --- a/src/corelib/json/qjsonvalue.h +++ b/src/corelib/json/qjsonvalue.h @@ -82,7 +82,7 @@ public: QJsonValue(QLatin1String s); #ifndef QT_NO_CAST_FROM_ASCII inline QT_ASCII_CAST_WARN QJsonValue(const char *s) - : d(Q_NULLPTR), t(String) { stringDataFromQStringHelper(QString::fromUtf8(s)); } + : d(nullptr), t(String) { stringDataFromQStringHelper(QString::fromUtf8(s)); } #endif QJsonValue(const QJsonArray &a); QJsonValue(const QJsonObject &o); diff --git a/src/corelib/kernel/qabstracteventdispatcher.h b/src/corelib/kernel/qabstracteventdispatcher.h index 3a530cf1de..b84e047f3f 100644 --- a/src/corelib/kernel/qabstracteventdispatcher.h +++ b/src/corelib/kernel/qabstracteventdispatcher.h @@ -70,10 +70,10 @@ public: { } }; - explicit QAbstractEventDispatcher(QObject *parent = Q_NULLPTR); + explicit QAbstractEventDispatcher(QObject *parent = nullptr); ~QAbstractEventDispatcher(); - static QAbstractEventDispatcher *instance(QThread *thread = Q_NULLPTR); + static QAbstractEventDispatcher *instance(QThread *thread = nullptr); virtual bool processEvents(QEventLoop::ProcessEventsFlags flags) = 0; virtual bool hasPendingEvents() = 0; // ### Qt6: remove, mark final or make protected @@ -112,7 +112,7 @@ public: bool filterNativeEvent(const QByteArray &eventType, void *message, long *result); #if QT_DEPRECATED_SINCE(5, 0) QT_DEPRECATED bool filterEvent(void *message) - { return filterNativeEvent("", message, Q_NULLPTR); } + { return filterNativeEvent("", message, nullptr); } #endif Q_SIGNALS: diff --git a/src/corelib/kernel/qcore_unix.cpp b/src/corelib/kernel/qcore_unix.cpp index 3b0da136ca..eb98cbef8f 100644 --- a/src/corelib/kernel/qcore_unix.cpp +++ b/src/corelib/kernel/qcore_unix.cpp @@ -130,7 +130,7 @@ int qt_safe_poll(struct pollfd *fds, nfds_t nfds, const struct timespec *timeout if (!timeout_ts) { // no timeout -> block forever int ret; - EINTR_LOOP(ret, qt_ppoll(fds, nfds, Q_NULLPTR)); + EINTR_LOOP(ret, qt_ppoll(fds, nfds, nullptr)); return ret; } diff --git a/src/corelib/kernel/qcore_unix_p.h b/src/corelib/kernel/qcore_unix_p.h index f78d2b9f24..e538a7e22b 100644 --- a/src/corelib/kernel/qcore_unix_p.h +++ b/src/corelib/kernel/qcore_unix_p.h @@ -362,7 +362,7 @@ Q_CORE_EXPORT int qt_safe_poll(struct pollfd *fds, nfds_t nfds, const struct tim static inline int qt_poll_msecs(struct pollfd *fds, nfds_t nfds, int timeout) { - timespec ts, *pts = Q_NULLPTR; + timespec ts, *pts = nullptr; if (timeout >= 0) { ts.tv_sec = timeout / 1000; diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 609e52d9d2..d1640bdc49 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -449,7 +449,7 @@ QCoreApplicationPrivate::QCoreApplicationPrivate(int &aargc, char **aargv, uint , argv(aargv) #if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) , origArgc(0) - , origArgv(Q_NULLPTR) + , origArgv(nullptr) #endif , application_type(QCoreApplicationPrivate::Tty) #ifndef QT_NO_QOBJECT diff --git a/src/corelib/kernel/qcoreapplication.h b/src/corelib/kernel/qcoreapplication.h index 6555733c4e..a886c9d1d2 100644 --- a/src/corelib/kernel/qcoreapplication.h +++ b/src/corelib/kernel/qcoreapplication.h @@ -123,7 +123,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 = Q_NULLPTR, int event_type = 0); + static void sendPostedEvents(QObject *receiver = nullptr, int event_type = 0); static void removePostedEvents(QObject *receiver, int eventType = 0); #if QT_DEPRECATED_SINCE(5, 3) QT_DEPRECATED static bool hasPendingEvents(); @@ -155,7 +155,7 @@ public: static QString translate(const char * context, const char * key, - const char * disambiguation = Q_NULLPTR, + const char * disambiguation = nullptr, int n = -1); #if QT_DEPRECATED_SINCE(5, 0) enum Encoding { UnicodeUTF8, Latin1, DefaultCodec = UnicodeUTF8, CodecForTr = UnicodeUTF8 }; @@ -187,7 +187,7 @@ Q_SIGNALS: void applicationVersionChanged(); protected: - bool event(QEvent *) Q_DECL_OVERRIDE; + bool event(QEvent *) override; virtual bool compressEvent(QEvent *, QObject *receiver, QPostEventList *); #endif // QT_NO_QOBJECT @@ -241,13 +241,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 = Q_NULLPTR, int n = -1) \ + QT_DEPRECATED static inline QString trUtf8(const char *sourceText, const char *disambiguation = 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 = Q_NULLPTR, int n = -1) \ + static inline QString tr(const char *sourceText, const char *disambiguation = nullptr, int n = -1) \ { return QCoreApplication::translate(#context, sourceText, disambiguation, n); } \ QT_DECLARE_DEPRECATED_TR_FUNCTIONS(context) \ private: diff --git a/src/corelib/kernel/qeventdispatcher_glib_p.h b/src/corelib/kernel/qeventdispatcher_glib_p.h index 8e9925d7a5..799f23b14a 100644 --- a/src/corelib/kernel/qeventdispatcher_glib_p.h +++ b/src/corelib/kernel/qeventdispatcher_glib_p.h @@ -70,22 +70,22 @@ public: explicit QEventDispatcherGlib(GMainContext *context, QObject *parent = 0); ~QEventDispatcherGlib(); - bool processEvents(QEventLoop::ProcessEventsFlags flags) Q_DECL_OVERRIDE; - bool hasPendingEvents() Q_DECL_OVERRIDE; + bool processEvents(QEventLoop::ProcessEventsFlags flags) override; + bool hasPendingEvents() override; - void registerSocketNotifier(QSocketNotifier *socketNotifier) Q_DECL_FINAL; - void unregisterSocketNotifier(QSocketNotifier *socketNotifier) Q_DECL_FINAL; + void registerSocketNotifier(QSocketNotifier *socketNotifier) final; + void unregisterSocketNotifier(QSocketNotifier *socketNotifier) final; - void registerTimer(int timerId, int interval, Qt::TimerType timerType, QObject *object) Q_DECL_FINAL; - bool unregisterTimer(int timerId) Q_DECL_FINAL; - bool unregisterTimers(QObject *object) Q_DECL_FINAL; - QList<TimerInfo> registeredTimers(QObject *object) const Q_DECL_FINAL; + void registerTimer(int timerId, int interval, Qt::TimerType timerType, QObject *object) final; + bool unregisterTimer(int timerId) final; + bool unregisterTimers(QObject *object) final; + QList<TimerInfo> registeredTimers(QObject *object) const final; - int remainingTime(int timerId) Q_DECL_FINAL; + int remainingTime(int timerId) final; - void wakeUp() Q_DECL_FINAL; - void interrupt() Q_DECL_FINAL; - void flush() Q_DECL_FINAL; + void wakeUp() final; + void interrupt() final; + void flush() final; static bool versionSupported(); diff --git a/src/corelib/kernel/qeventdispatcher_unix_p.h b/src/corelib/kernel/qeventdispatcher_unix_p.h index bcf5b10baa..0fd068b074 100644 --- a/src/corelib/kernel/qeventdispatcher_unix_p.h +++ b/src/corelib/kernel/qeventdispatcher_unix_p.h @@ -62,7 +62,7 @@ QT_BEGIN_NAMESPACE class QEventDispatcherUNIXPrivate; -struct Q_CORE_EXPORT QSocketNotifierSetUNIX Q_DECL_FINAL +struct Q_CORE_EXPORT QSocketNotifierSetUNIX final { inline QSocketNotifierSetUNIX() Q_DECL_NOTHROW; @@ -105,22 +105,22 @@ public: explicit QEventDispatcherUNIX(QObject *parent = 0); ~QEventDispatcherUNIX(); - bool processEvents(QEventLoop::ProcessEventsFlags flags) Q_DECL_OVERRIDE; - bool hasPendingEvents() Q_DECL_OVERRIDE; + bool processEvents(QEventLoop::ProcessEventsFlags flags) override; + bool hasPendingEvents() override; - void registerSocketNotifier(QSocketNotifier *notifier) Q_DECL_FINAL; - void unregisterSocketNotifier(QSocketNotifier *notifier) Q_DECL_FINAL; + void registerSocketNotifier(QSocketNotifier *notifier) final; + void unregisterSocketNotifier(QSocketNotifier *notifier) final; - void registerTimer(int timerId, int interval, Qt::TimerType timerType, QObject *object) Q_DECL_FINAL; - bool unregisterTimer(int timerId) Q_DECL_FINAL; - bool unregisterTimers(QObject *object) Q_DECL_FINAL; - QList<TimerInfo> registeredTimers(QObject *object) const Q_DECL_FINAL; + void registerTimer(int timerId, int interval, Qt::TimerType timerType, QObject *object) final; + bool unregisterTimer(int timerId) final; + bool unregisterTimers(QObject *object) final; + QList<TimerInfo> registeredTimers(QObject *object) const final; - int remainingTime(int timerId) Q_DECL_FINAL; + int remainingTime(int timerId) final; - void wakeUp() Q_DECL_FINAL; - void interrupt() Q_DECL_FINAL; - void flush() Q_DECL_OVERRIDE; + void wakeUp() final; + void interrupt() final; + void flush() override; protected: QEventDispatcherUNIX(QEventDispatcherUNIXPrivate &dd, QObject *parent = 0); diff --git a/src/corelib/kernel/qeventloop.h b/src/corelib/kernel/qeventloop.h index e62b1d8419..eb1348220b 100644 --- a/src/corelib/kernel/qeventloop.h +++ b/src/corelib/kernel/qeventloop.h @@ -53,7 +53,7 @@ class Q_CORE_EXPORT QEventLoop : public QObject Q_DECLARE_PRIVATE(QEventLoop) public: - explicit QEventLoop(QObject *parent = Q_NULLPTR); + explicit QEventLoop(QObject *parent = nullptr); ~QEventLoop(); enum ProcessEventsFlag { @@ -76,7 +76,7 @@ public: void wakeUp(); - bool event(QEvent *event) Q_DECL_OVERRIDE; + bool event(QEvent *event) override; public Q_SLOTS: void quit(); diff --git a/src/corelib/kernel/qfunctions_vxworks.h b/src/corelib/kernel/qfunctions_vxworks.h index 34630a735b..86f243959f 100644 --- a/src/corelib/kernel/qfunctions_vxworks.h +++ b/src/corelib/kernel/qfunctions_vxworks.h @@ -62,9 +62,6 @@ #include <sys/stat.h> #include <sys/wait.h> #include <netinet/in.h> -#ifndef QT_NO_IPV6IFNAME -#include <net/if.h> -#endif // VxWorks has public header mbuf.h which defines following variables for DKM. // Let's undef those to because they overlap with Qt variable names- diff --git a/src/corelib/kernel/qjni.cpp b/src/corelib/kernel/qjni.cpp index 60154328c2..75a2436d9d 100644 --- a/src/corelib/kernel/qjni.cpp +++ b/src/corelib/kernel/qjni.cpp @@ -260,7 +260,7 @@ QJNIEnvironmentPrivate::QJNIEnvironmentPrivate() return; if (ret == JNI_EDETACHED) { // We need to (re-)attach - JavaVMAttachArgs args = { JNI_VERSION_1_6, qJniThreadName, Q_NULLPTR }; + JavaVMAttachArgs args = { JNI_VERSION_1_6, qJniThreadName, nullptr }; if (vm->AttachCurrentThread(&jniEnv, &args) != JNI_OK) return; diff --git a/src/corelib/kernel/qjnihelpers.cpp b/src/corelib/kernel/qjnihelpers.cpp index 02c58858ff..c7109a6506 100644 --- a/src/corelib/kernel/qjnihelpers.cpp +++ b/src/corelib/kernel/qjnihelpers.cpp @@ -64,14 +64,14 @@ namespace QtAndroidPrivate { KeyEventListener::~KeyEventListener() {} } -static JavaVM *g_javaVM = Q_NULLPTR; -static jobject g_jActivity = Q_NULLPTR; -static jobject g_jService = Q_NULLPTR; -static jobject g_jClassLoader = Q_NULLPTR; +static JavaVM *g_javaVM = nullptr; +static jobject g_jActivity = nullptr; +static jobject g_jService = nullptr; +static jobject g_jClassLoader = nullptr; static jint g_androidSdkVersion = 0; -static jclass g_jNativeClass = Q_NULLPTR; -static jmethodID g_runPendingCppRunnablesMethodID = Q_NULLPTR; -static jmethodID g_hideSplashScreenMethodID = Q_NULLPTR; +static jclass g_jNativeClass = nullptr; +static jmethodID g_runPendingCppRunnablesMethodID = nullptr; +static jmethodID g_hideSplashScreenMethodID = nullptr; Q_GLOBAL_STATIC(std::deque<QtAndroidPrivate::Runnable>, g_pendingRunnables); static QBasicMutex g_pendingRunnablesMutex; diff --git a/src/corelib/kernel/qjnionload.cpp b/src/corelib/kernel/qjnionload.cpp index 8f60800dba..0550b86553 100644 --- a/src/corelib/kernel/qjnionload.cpp +++ b/src/corelib/kernel/qjnionload.cpp @@ -61,7 +61,7 @@ Q_CORE_EXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) __android_log_print(ANDROID_LOG_INFO, logTag, "Start"); _JNIEnv uenv; - uenv.venv = Q_NULLPTR; + uenv.venv = nullptr; if (vm->GetEnv(&uenv.venv, JNI_VERSION_1_6) != JNI_OK) { diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index f07b463482..f24a511295 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -1589,7 +1589,7 @@ bool QMetaObject::invokeMethodImpl(QObject *object, QtPrivate::QSlotObjectBase * */ /*! - \fn bool QMetaObject::invokeMethod(QObject *receiver, PointerToMemberFunction function, Qt::ConnectionType type = Qt::AutoConnection, MemberFunctionReturnType *ret = Q_NULLPTR) + \fn bool QMetaObject::invokeMethod(QObject *receiver, PointerToMemberFunction function, Qt::ConnectionType type = Qt::AutoConnection, MemberFunctionReturnType *ret = nullptr) \since 5.10 @@ -1607,7 +1607,7 @@ bool QMetaObject::invokeMethodImpl(QObject *object, QtPrivate::QSlotObjectBase * */ /*! - \fn bool QMetaObject::invokeMethod(QObject *context, Functor function, Qt::ConnectionType type = Qt::AutoConnection, FunctorReturnType *ret = Q_NULLPTR) + \fn bool QMetaObject::invokeMethod(QObject *context, Functor function, Qt::ConnectionType type = Qt::AutoConnection, FunctorReturnType *ret = nullptr) \since 5.10 @@ -1617,7 +1617,7 @@ bool QMetaObject::invokeMethodImpl(QObject *object, QtPrivate::QSlotObjectBase * */ /*! - \fn bool QMetaObject::invokeMethod(QObject *context, Functor function, FunctorReturnType *ret = Q_NULLPTR) + \fn bool QMetaObject::invokeMethod(QObject *context, Functor function, FunctorReturnType *ret = nullptr) \since 5.10 diff --git a/src/corelib/kernel/qmetaobject.h b/src/corelib/kernel/qmetaobject.h index 40b2aa6402..51df8faad3 100644 --- a/src/corelib/kernel/qmetaobject.h +++ b/src/corelib/kernel/qmetaobject.h @@ -54,7 +54,7 @@ template <typename T> class QList; class Q_CORE_EXPORT QMetaMethod { public: - Q_DECL_CONSTEXPR inline QMetaMethod() : mobj(Q_NULLPTR), handle(0) {} + Q_DECL_CONSTEXPR inline QMetaMethod() : mobj(nullptr), handle(0) {} QByteArray methodSignature() const; QByteArray name() const; @@ -80,7 +80,7 @@ public: bool invoke(QObject *object, Qt::ConnectionType connectionType, QGenericReturnArgument returnValue, - QGenericArgument val0 = QGenericArgument(Q_NULLPTR), + QGenericArgument val0 = QGenericArgument(nullptr), QGenericArgument val1 = QGenericArgument(), QGenericArgument val2 = QGenericArgument(), QGenericArgument val3 = QGenericArgument(), @@ -92,7 +92,7 @@ public: QGenericArgument val9 = QGenericArgument()) const; inline bool invoke(QObject *object, QGenericReturnArgument returnValue, - QGenericArgument val0 = QGenericArgument(Q_NULLPTR), + QGenericArgument val0 = QGenericArgument(nullptr), QGenericArgument val1 = QGenericArgument(), QGenericArgument val2 = QGenericArgument(), QGenericArgument val3 = QGenericArgument(), @@ -108,7 +108,7 @@ public: } inline bool invoke(QObject *object, Qt::ConnectionType connectionType, - QGenericArgument val0 = QGenericArgument(Q_NULLPTR), + QGenericArgument val0 = QGenericArgument(nullptr), QGenericArgument val1 = QGenericArgument(), QGenericArgument val2 = QGenericArgument(), QGenericArgument val3 = QGenericArgument(), @@ -123,7 +123,7 @@ public: val0, val1, val2, val3, val4, val5, val6, val7, val8, val9); } inline bool invoke(QObject *object, - QGenericArgument val0 = QGenericArgument(Q_NULLPTR), + QGenericArgument val0 = QGenericArgument(nullptr), QGenericArgument val1 = QGenericArgument(), QGenericArgument val2 = QGenericArgument(), QGenericArgument val3 = QGenericArgument(), @@ -140,7 +140,7 @@ public: bool invokeOnGadget(void *gadget, QGenericReturnArgument returnValue, - QGenericArgument val0 = QGenericArgument(Q_NULLPTR), + QGenericArgument val0 = QGenericArgument(nullptr), QGenericArgument val1 = QGenericArgument(), QGenericArgument val2 = QGenericArgument(), QGenericArgument val3 = QGenericArgument(), @@ -151,7 +151,7 @@ public: QGenericArgument val8 = QGenericArgument(), QGenericArgument val9 = QGenericArgument()) const; inline bool invokeOnGadget(void *gadget, - QGenericArgument val0 = QGenericArgument(Q_NULLPTR), + QGenericArgument val0 = QGenericArgument(nullptr), QGenericArgument val1 = QGenericArgument(), QGenericArgument val2 = QGenericArgument(), QGenericArgument val3 = QGenericArgument(), @@ -166,7 +166,7 @@ public: val0, val1, val2, val3, val4, val5, val6, val7, val8, val9); } - inline bool isValid() const { return mobj != Q_NULLPTR; } + inline bool isValid() const { return mobj != nullptr; } template <typename PointerToMemberFunction> static inline QMetaMethod fromSignal(PointerToMemberFunction signal) @@ -183,7 +183,7 @@ private: // signature() has been renamed to methodSignature() in Qt 5. // Warning, that function returns a QByteArray; check the life time if // you convert to char*. - char *signature(struct renamedInQt5_warning_checkTheLifeTime * = Q_NULLPTR) Q_DECL_EQ_DELETE; + char *signature(struct renamedInQt5_warning_checkTheLifeTime * = nullptr) Q_DECL_EQ_DELETE; #endif static QMetaMethod fromSignalImpl(const QMetaObject *, void **); @@ -206,7 +206,7 @@ inline bool operator!=(const QMetaMethod &m1, const QMetaMethod &m2) class Q_CORE_EXPORT QMetaEnum { public: - Q_DECL_CONSTEXPR inline QMetaEnum() : mobj(Q_NULLPTR), handle(0) {} + Q_DECL_CONSTEXPR inline QMetaEnum() : mobj(nullptr), handle(0) {} const char *name() const; bool isFlag() const; @@ -218,14 +218,14 @@ public: const char *scope() const; - int keyToValue(const char *key, bool *ok = Q_NULLPTR) const; + int keyToValue(const char *key, bool *ok = nullptr) const; const char* valueToKey(int value) const; - int keysToValue(const char * keys, bool *ok = Q_NULLPTR) const; + int keysToValue(const char * keys, bool *ok = nullptr) const; QByteArray valueToKeys(int value) const; inline const QMetaObject *enclosingMetaObject() const { return mobj; } - inline bool isValid() const { return name() != Q_NULLPTR; } + inline bool isValid() const { return name() != nullptr; } template<typename T> static QMetaEnum fromType() { Q_STATIC_ASSERT_X(QtPrivate::IsQEnumHelper<T>::Value, @@ -256,11 +256,11 @@ public: bool isReadable() const; bool isWritable() const; bool isResettable() 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 isDesignable(const QObject *obj = nullptr) const; + bool isScriptable(const QObject *obj = nullptr) const; + bool isStored(const QObject *obj = nullptr) const; + bool isEditable(const QObject *obj = nullptr) const; + bool isUser(const QObject *obj = nullptr) const; bool isConstant() const; bool isFinal() const; @@ -300,7 +300,7 @@ private: class Q_CORE_EXPORT QMetaClassInfo { public: - Q_DECL_CONSTEXPR inline QMetaClassInfo() : mobj(Q_NULLPTR), handle(0) {} + Q_DECL_CONSTEXPR inline QMetaClassInfo() : mobj(nullptr), handle(0) {} const char *name() const; const char *value() const; inline const QMetaObject *enclosingMetaObject() const { return mobj; } diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index f704c5b21a..47c3a1c6f6 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -234,7 +234,7 @@ struct AbstractDebugStreamFunction { typedef void (*Stream)(const AbstractDebugStreamFunction *, QDebug&, const void *); typedef void (*Destroy)(AbstractDebugStreamFunction *); - explicit AbstractDebugStreamFunction(Stream s = Q_NULLPTR, Destroy d = Q_NULLPTR) + explicit AbstractDebugStreamFunction(Stream s = nullptr, Destroy d = nullptr) : stream(s), destroy(d) {} Q_DISABLE_COPY(AbstractDebugStreamFunction) Stream stream; @@ -264,7 +264,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 = Q_NULLPTR, Equals e = Q_NULLPTR, Destroy d = Q_NULLPTR) + explicit AbstractComparatorFunction(LessThan lt = nullptr, Equals e = nullptr, Destroy d = nullptr) : lessThan(lt), equals(e), destroy(d) {} Q_DISABLE_COPY(AbstractComparatorFunction) LessThan lessThan; @@ -301,7 +301,7 @@ template<typename T> struct BuiltInEqualsComparatorFunction : public AbstractComparatorFunction { BuiltInEqualsComparatorFunction() - : AbstractComparatorFunction(Q_NULLPTR, equals, destroy) {} + : AbstractComparatorFunction(nullptr, equals, destroy) {} static bool equals(const AbstractComparatorFunction *, const void *l, const void *r) { const T *lhs = static_cast<const T *>(l); @@ -318,7 +318,7 @@ struct BuiltInEqualsComparatorFunction : public AbstractComparatorFunction struct AbstractConverterFunction { typedef bool (*Converter)(const AbstractConverterFunction *, const void *, void*); - explicit AbstractConverterFunction(Converter c = Q_NULLPTR) + explicit AbstractConverterFunction(Converter c = nullptr) : convert(c) {} Q_DISABLE_COPY(AbstractConverterFunction) Converter convert; @@ -513,9 +513,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 = Q_NULLPTR); + static void *create(int type, const void *copy = nullptr); #if QT_DEPRECATED_SINCE(5, 0) - QT_DEPRECATED static void *construct(int type, const void *copy = Q_NULLPTR) + QT_DEPRECATED static void *construct(int type, const void *copy = nullptr) { return create(type, copy); } #endif static void destroy(int type, void *data); @@ -536,9 +536,9 @@ public: inline TypeFlags flags() const; inline const QMetaObject *metaObject() const; - inline void *create(const void *copy = Q_NULLPTR) const; + inline void *create(const void *copy = nullptr) const; inline void destroy(void *data) const; - inline void *construct(void *where, const void *copy = Q_NULLPTR) const; + inline void *construct(void *where, const void *copy = nullptr) const; inline void destruct(void *data) const; public: @@ -617,7 +617,7 @@ public: return registerConverterFunction(&f, fromTypeId, toTypeId); } - // member function as in "double QString::toDouble(bool *ok = Q_NULLPTR) const" + // member function as in "double QString::toDouble(bool *ok = nullptr) const" template<typename From, typename To> static bool registerConverter(To(From::*function)(bool*) const) { @@ -680,9 +680,9 @@ private: uint sizeExtended() const; QMetaType::TypeFlags flagsExtended() const; const QMetaObject *metaObjectExtended() const; - void *createExtended(const void *copy = Q_NULLPTR) const; + void *createExtended(const void *copy = nullptr) const; void destroyExtended(void *data) const; - void *constructExtended(void *where, const void *copy = Q_NULLPTR) const; + void *constructExtended(void *where, const void *copy = nullptr) const; void destructExtended(void *data) const; static bool registerComparatorFunction(const QtPrivate::AbstractComparatorFunction *f, int type); @@ -782,7 +782,7 @@ struct QMetaTypeFunctionHelper { template <typename T> struct QMetaTypeFunctionHelper<T, /* Accepted */ false> { static void Destruct(void *) {} - static void *Construct(void *, const void *) { return Q_NULLPTR; } + static void *Construct(void *, const void *) { return nullptr; } #ifndef QT_NO_DATASTREAM static void Save(QDataStream &, const void *) {} static void Load(QDataStream &, void *) {} @@ -1020,7 +1020,7 @@ public: public: template<class T> QSequentialIterableImpl(const T*p) : _iterable(p) - , _iterator(Q_NULLPTR) + , _iterator(nullptr) , _metaType_id(qMetaTypeId<typename T::value_type>()) , _metaType_flags(QTypeInfo<typename T::value_type>::isPointer) , _iteratorCapabilities(ContainerAPI<T>::IteratorCapabilities) @@ -1037,20 +1037,20 @@ public: } QSequentialIterableImpl() - : _iterable(Q_NULLPTR) - , _iterator(Q_NULLPTR) + : _iterable(nullptr) + , _iterator(nullptr) , _metaType_id(QMetaType::UnknownType) , _metaType_flags(0) , _iteratorCapabilities(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) + , _size(nullptr) + , _at(nullptr) + , _moveToBegin(nullptr) + , _moveToEnd(nullptr) + , _advance(nullptr) + , _get(nullptr) + , _destroyIter(nullptr) + , _equalIter(nullptr) + , _copyIter(nullptr) { } @@ -1189,7 +1189,7 @@ public: public: template<class T> QAssociativeIterableImpl(const T*p) : _iterable(p) - , _iterator(Q_NULLPTR) + , _iterator(nullptr) , _metaType_id_key(qMetaTypeId<typename T::key_type>()) , _metaType_flags_key(QTypeInfo<typename T::key_type>::isPointer) , _metaType_id_value(qMetaTypeId<typename T::mapped_type>()) @@ -1208,22 +1208,22 @@ public: } QAssociativeIterableImpl() - : _iterable(Q_NULLPTR) - , _iterator(Q_NULLPTR) + : _iterable(nullptr) + , _iterator(nullptr) , _metaType_id_key(QMetaType::UnknownType) , _metaType_flags_key(0) , _metaType_id_value(QMetaType::UnknownType) , _metaType_flags_value(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) + , _size(nullptr) + , _find(nullptr) + , _begin(nullptr) + , _end(nullptr) + , _advance(nullptr) + , _getKey(nullptr) + , _getValue(nullptr) + , _destroyIter(nullptr) + , _equalIter(nullptr) + , _copyIter(nullptr) { } @@ -1292,13 +1292,13 @@ public: } QPairVariantInterfaceImpl() - : _pair(Q_NULLPTR) + : _pair(nullptr) , _metaType_id_first(QMetaType::UnknownType) , _metaType_flags_first(0) , _metaType_id_second(QMetaType::UnknownType) , _metaType_flags_second(0) - , _getFirst(Q_NULLPTR) - , _getSecond(Q_NULLPTR) + , _getFirst(nullptr) + , _getSecond(nullptr) { } @@ -1374,7 +1374,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*>(Q_NULLPTR))) == sizeof(yes_type) }; + enum { Value = sizeof(checkType(static_cast<T*>(nullptr))) == sizeof(yes_type) }; }; template<typename T, typename Enable = void> @@ -1419,12 +1419,12 @@ namespace QtPrivate template<typename T, typename Enable = void> struct MetaObjectForType { - static inline const QMetaObject *value() { return Q_NULLPTR; } + static inline const QMetaObject *value() { return nullptr; } }; template<> struct MetaObjectForType<void> { - static inline const QMetaObject *value() { return Q_NULLPTR; } + static inline const QMetaObject *value() { return nullptr; } }; template<typename T> struct MetaObjectForType<T*, typename std::enable_if<IsPointerToTypeDerivedFromQObject<T*>::Value>::type> @@ -1720,7 +1720,7 @@ int qRegisterNormalizedMetaType(const QT_PREPEND_NAMESPACE(QByteArray) &normaliz template <typename T> int qRegisterMetaType(const char *typeName #ifndef Q_QDOC - , T * dummy = Q_NULLPTR + , T * dummy = nullptr , typename QtPrivate::MetaTypeDefinedHelper<T, QMetaTypeId2<T>::Defined && !QMetaTypeId2<T>::IsBuiltIn>::DefinedType defined = QtPrivate::MetaTypeDefinedHelper<T, QMetaTypeId2<T>::Defined && !QMetaTypeId2<T>::IsBuiltIn>::Defined #endif ) @@ -1737,7 +1737,7 @@ int qRegisterMetaType(const char *typeName template <typename T> void qRegisterMetaTypeStreamOperators(const char *typeName #ifndef Q_QDOC - , T * /* dummy */ = Q_NULLPTR + , T * /* dummy */ = nullptr #endif ) { @@ -2150,7 +2150,7 @@ inline QMetaType::QMetaType(const ExtensionFlag extensionFlags, const QMetaTypeI , m_loadOp(loadOp) , m_constructor(constructor) , m_destructor(destructor) - , m_extension(Q_NULLPTR) + , m_extension(nullptr) , m_size(size) , m_typeFlags(theTypeFlags) , m_extensionFlags(extensionFlags) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 3b0f7ead09..aa228af21a 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -998,7 +998,7 @@ QObject::~QObject() if (senderLists) senderLists->dirty = true; - QtPrivate::QSlotObjectBase *slotObj = Q_NULLPTR; + QtPrivate::QSlotObjectBase *slotObj = nullptr; if (node->isSlotObject) { slotObj = node->slotObj; node->isSlotObject = false; @@ -1468,14 +1468,14 @@ void QObject::moveToThread(QThread *targetThread) } QThreadData *currentData = QThreadData::current(); - QThreadData *targetData = targetThread ? QThreadData::get2(targetThread) : Q_NULLPTR; + QThreadData *targetData = targetThread ? QThreadData::get2(targetThread) : nullptr; if (d->threadData->thread == 0 && currentData == targetData) { // one exception to the rule: we allow moving objects with no thread affinity to the current thread currentData = d->threadData; } else if (d->threadData != currentData) { qWarning("QObject::moveToThread: Current thread (%p) is not the object's thread (%p).\n" "Cannot move to target thread (%p)\n", - currentData->thread.load(), d->threadData->thread.load(), targetData ? targetData->thread.load() : Q_NULLPTR); + currentData->thread.load(), d->threadData->thread.load(), targetData ? targetData->thread.load() : nullptr); #ifdef Q_OS_MAC qWarning("You might be loading two sets of Qt binaries into the same process. " diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h index 2e66daa914..d297109acb 100644 --- a/src/corelib/kernel/qobject.h +++ b/src/corelib/kernel/qobject.h @@ -120,23 +120,23 @@ class Q_CORE_EXPORT QObject Q_DECLARE_PRIVATE(QObject) public: - Q_INVOKABLE explicit QObject(QObject *parent=Q_NULLPTR); + Q_INVOKABLE explicit QObject(QObject *parent=nullptr); virtual ~QObject(); virtual bool event(QEvent *event); virtual bool eventFilter(QObject *watched, QEvent *event); #ifdef Q_QDOC - 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); + static QString tr(const char *sourceText, const char *comment = nullptr, int n = -1); + static QString trUtf8(const char *sourceText, const char *comment = 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 * = Q_NULLPTR, int = -1) + static QString tr(const char *sourceText, const char * = nullptr, int = -1) { return QString::fromUtf8(sourceText); } #if QT_DEPRECATED_SINCE(5, 0) - QT_DEPRECATED static QString trUtf8(const char *sourceText, const char * = Q_NULLPTR, int = -1) + QT_DEPRECATED static QString trUtf8(const char *sourceText, const char * = nullptr, int = -1) { return QString::fromUtf8(sourceText); } #endif #endif //QT_NO_TRANSLATION @@ -248,7 +248,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 = Q_NULLPTR; + const int *types = nullptr; if (type == Qt::QueuedConnection || type == Qt::BlockingQueuedConnection) types = QtPrivate::ConnectionTypes<typename SignalType::Arguments>::types(); @@ -288,11 +288,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 = Q_NULLPTR; + const int *types = nullptr; if (type == Qt::QueuedConnection || type == Qt::BlockingQueuedConnection) types = QtPrivate::ConnectionTypes<typename SignalType::Arguments>::types(); - return connectImpl(sender, reinterpret_cast<void **>(&signal), context, Q_NULLPTR, + return connectImpl(sender, reinterpret_cast<void **>(&signal), context, nullptr, new QtPrivate::QStaticSlotObject<Func2, typename QtPrivate::List_Left<typename SignalType::Arguments, SlotType::ArgumentCount>::Value, typename SignalType::ReturnType>(slot), @@ -327,11 +327,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 = Q_NULLPTR; + const int *types = nullptr; if (type == Qt::QueuedConnection || type == Qt::BlockingQueuedConnection) types = QtPrivate::ConnectionTypes<typename SignalType::Arguments>::types(); - return connectImpl(sender, reinterpret_cast<void **>(&signal), context, Q_NULLPTR, + return connectImpl(sender, reinterpret_cast<void **>(&signal), context, nullptr, new QtPrivate::QFunctorSlotObject<Func2, SlotArgumentCount, typename QtPrivate::List_Left<typename SignalType::Arguments, SlotArgumentCount>::Value, typename SignalType::ReturnType>(std::move(slot)), @@ -343,11 +343,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 = Q_NULLPTR, - const QObject *receiver = Q_NULLPTR, const char *member = Q_NULLPTR) const + inline bool disconnect(const char *signal = nullptr, + const QObject *receiver = nullptr, const char *member = nullptr) const { return disconnect(this, signal, receiver, member); } - inline bool disconnect(const QObject *receiver, const char *member = Q_NULLPTR) const - { return disconnect(this, Q_NULLPTR, receiver, member); } + inline bool disconnect(const QObject *receiver, const char *member = nullptr) const + { return disconnect(this, nullptr, receiver, member); } static bool disconnect(const QMetaObject::Connection &); #ifdef Q_QDOC @@ -375,7 +375,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=Q_NULLPTR) + // This is the overload for when one wish to disconnect a signal from any slot. (slot=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); @@ -406,14 +406,14 @@ public: #endif // QT_NO_USERDATA Q_SIGNALS: - void destroyed(QObject * = Q_NULLPTR); + void destroyed(QObject * = 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) != Q_NULLPTR; } + { return const_cast<QObject *>(this)->qt_metacast(classname) != nullptr; } public Q_SLOTS: void deleteLater(); @@ -432,7 +432,7 @@ protected: virtual void disconnectNotify(const QMetaMethod &signal); protected: - QObject(QObjectPrivate &dd, QObject *parent = Q_NULLPTR); + QObject(QObjectPrivate &dd, QObject *parent = nullptr); protected: QScopedPointer<QObjectData> d_ptr; @@ -525,16 +525,16 @@ inline T qobject_cast(const QObject *object) template <class T> inline const char * qobject_interface_iid() -{ return Q_NULLPTR; } +{ return 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) : Q_NULLPTR)); } \ + { return reinterpret_cast<IFace *>((object ? object->qt_metacast(IId) : nullptr)); } \ template <> inline IFace *qobject_cast<IFace *>(const QObject *object) \ - { return reinterpret_cast<IFace *>((object ? const_cast<QObject *>(object)->qt_metacast(IId) : Q_NULLPTR)); } + { return reinterpret_cast<IFace *>((object ? const_cast<QObject *>(object)->qt_metacast(IId) : nullptr)); } #endif // Q_MOC_RUN #ifndef QT_NO_DEBUG_STREAM @@ -580,7 +580,7 @@ QSignalBlocker::QSignalBlocker(QSignalBlocker &&other) Q_DECL_NOTHROW m_blocked(other.m_blocked), m_inhibited(other.m_inhibited) { - other.m_o = Q_NULLPTR; + other.m_o = nullptr; } QSignalBlocker &QSignalBlocker::operator=(QSignalBlocker &&other) Q_DECL_NOTHROW @@ -594,7 +594,7 @@ QSignalBlocker &QSignalBlocker::operator=(QSignalBlocker &&other) Q_DECL_NOTHROW m_blocked = other.m_blocked; m_inhibited = other.m_inhibited; // disable other: - other.m_o = Q_NULLPTR; + other.m_o = nullptr; } return *this; } diff --git a/src/corelib/kernel/qobject_impl.h b/src/corelib/kernel/qobject_impl.h index c775d807b1..1a14b93dcd 100644 --- a/src/corelib/kernel/qobject_impl.h +++ b/src/corelib/kernel/qobject_impl.h @@ -68,9 +68,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 Q_NULLPTR; } }; + { static const int *types() { return nullptr; } }; template <> struct ConnectionTypes<List<>, true> - { static const int *types() { return Q_NULLPTR; } }; + { static const int *types() { return 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; } }; diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index ad88bcf274..6aea40cf4a 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2017 The Qt Company Ltd. ** Copyright (C) 2013 Olivier Goffart <ogoffart@woboq.com> ** Contact: https://www.qt.io/licensing/ ** @@ -145,7 +145,7 @@ public: ushort connectionType : 3; // 0 == auto, 1 == direct, 2 == queued, 4 == blocking ushort isSlotObject : 1; ushort ownArgumentTypes : 1; - Connection() : nextConnectionList(0), ref_(2), ownArgumentTypes(true) { + Connection() : nextConnectionList(nullptr), ref_(2), ownArgumentTypes(true) { //ref_ is 2 for the use in the internal lists, and for the use in QMetaObject::Connection } ~Connection(); @@ -160,7 +160,7 @@ public: }; // ConnectionList is a singly-linked list struct ConnectionList { - ConnectionList() : first(0), last(0) {} + ConnectionList() : first(nullptr), last(nullptr) {} Connection *first; Connection *last; }; @@ -200,7 +200,7 @@ public: } static const QObjectPrivate *get(const QObject *o) { return o->d_func(); } - int signalIndex(const char *signalName, const QMetaObject **meta = 0) const; + int signalIndex(const char *signalName, const QMetaObject **meta = nullptr) const; inline bool isSignalConnected(uint signalIdx, bool checkDeclarative = true) const; inline bool isDeclarativeSignalConnected(uint signalIdx) const; @@ -376,12 +376,12 @@ class Q_CORE_EXPORT QMetaCallEvent : public QEvent { public: QMetaCallEvent(ushort method_offset, ushort method_relative, QObjectPrivate::StaticMetaCallFunction callFunction , const QObject *sender, int signalId, - int nargs = 0, int *types = 0, void **args = 0, QSemaphore *semaphore = 0); + int nargs = 0, int *types = nullptr, void **args = nullptr, QSemaphore *semaphore = nullptr); /*! \internal \a signalId is in the signal index range (see QObjectPrivate::signalIndex()). */ QMetaCallEvent(QtPrivate::QSlotObjectBase *slotObj, const QObject *sender, int signalId, - int nargs = 0, int *types = 0, void **args = 0, QSemaphore *semaphore = 0); + int nargs = 0, int *types = nullptr, void **args = nullptr, QSemaphore *semaphore = nullptr); ~QMetaCallEvent(); @@ -432,9 +432,9 @@ struct Q_CORE_EXPORT QAbstractDynamicMetaObject : public QDynamicMetaObjectData, { ~QAbstractDynamicMetaObject(); - virtual QAbstractDynamicMetaObject *toDynamicMetaObject(QObject *) Q_DECL_OVERRIDE { return this; } + virtual QAbstractDynamicMetaObject *toDynamicMetaObject(QObject *) 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 + virtual int metaCall(QObject *, QMetaObject::Call c, int _id, void **a) override { return metaCall(c, _id, a); } virtual int metaCall(QMetaObject::Call, int _id, void **) { return _id; } // Compat overload }; diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h index 5fc8937f23..6cd0e82a86 100644 --- a/src/corelib/kernel/qobjectdefs.h +++ b/src/corelib/kernel/qobjectdefs.h @@ -137,9 +137,9 @@ class QString; #ifndef QT_NO_TRANSLATION // full set of tr functions # define QT_TR_FUNCTIONS \ - static inline QString tr(const char *s, const char *c = Q_NULLPTR, int n = -1) \ + static inline QString tr(const char *s, const char *c = nullptr, int n = -1) \ { return staticMetaObject.tr(s, c, n); } \ - QT_DEPRECATED static inline QString trUtf8(const char *s, const char *c = Q_NULLPTR, int n = -1) \ + QT_DEPRECATED static inline QString trUtf8(const char *s, const char *c = nullptr, int n = -1) \ { return staticMetaObject.tr(s, c, n); } #else // inherit the ones from QObject @@ -294,7 +294,7 @@ class QMetaClassInfo; class Q_CORE_EXPORT QGenericArgument { public: - inline QGenericArgument(const char *aName = Q_NULLPTR, const void *aData = Q_NULLPTR) + inline QGenericArgument(const char *aName = nullptr, const void *aData = nullptr) : _data(aData), _name(aName) {} inline void *data() const { return const_cast<void *>(_data); } inline const char *name() const { return _name; } @@ -307,7 +307,7 @@ private: class Q_CORE_EXPORT QGenericReturnArgument: public QGenericArgument { public: - inline QGenericReturnArgument(const char *aName = Q_NULLPTR, void *aData = Q_NULLPTR) + inline QGenericReturnArgument(const char *aName = nullptr, void *aData = nullptr) : QGenericArgument(aName, aData) {} }; @@ -388,7 +388,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 = Q_NULLPTR); + int type = 0, int *types = nullptr); // internal index-based disconnect static bool disconnect(const QObject *sender, int signal_index, const QObject *receiver, int method_index); @@ -405,7 +405,7 @@ struct Q_CORE_EXPORT QMetaObject static bool invokeMethod(QObject *obj, const char *member, Qt::ConnectionType, QGenericReturnArgument ret, - QGenericArgument val0 = QGenericArgument(Q_NULLPTR), + QGenericArgument val0 = QGenericArgument(nullptr), QGenericArgument val1 = QGenericArgument(), QGenericArgument val2 = QGenericArgument(), QGenericArgument val3 = QGenericArgument(), @@ -418,7 +418,7 @@ struct Q_CORE_EXPORT QMetaObject static inline bool invokeMethod(QObject *obj, const char *member, QGenericReturnArgument ret, - QGenericArgument val0 = QGenericArgument(Q_NULLPTR), + QGenericArgument val0 = QGenericArgument(nullptr), QGenericArgument val1 = QGenericArgument(), QGenericArgument val2 = QGenericArgument(), QGenericArgument val3 = QGenericArgument(), @@ -435,7 +435,7 @@ struct Q_CORE_EXPORT QMetaObject static inline bool invokeMethod(QObject *obj, const char *member, Qt::ConnectionType type, - QGenericArgument val0 = QGenericArgument(Q_NULLPTR), + QGenericArgument val0 = QGenericArgument(nullptr), QGenericArgument val1 = QGenericArgument(), QGenericArgument val2 = QGenericArgument(), QGenericArgument val3 = QGenericArgument(), @@ -451,7 +451,7 @@ struct Q_CORE_EXPORT QMetaObject } static inline bool invokeMethod(QObject *obj, const char *member, - QGenericArgument val0 = QGenericArgument(Q_NULLPTR), + QGenericArgument val0 = QGenericArgument(nullptr), QGenericArgument val1 = QGenericArgument(), QGenericArgument val2 = QGenericArgument(), QGenericArgument val3 = QGenericArgument(), @@ -551,7 +551,7 @@ struct Q_CORE_EXPORT QMetaObject #endif - QObject *newInstance(QGenericArgument val0 = QGenericArgument(Q_NULLPTR), + QObject *newInstance(QGenericArgument val0 = QGenericArgument(nullptr), QGenericArgument val1 = QGenericArgument(), QGenericArgument val2 = QGenericArgument(), QGenericArgument val3 = QGenericArgument(), @@ -611,11 +611,11 @@ public: operator bool() const; #else typedef void *Connection::*RestrictedBool; - operator RestrictedBool() const { return d_ptr && isConnected_helper() ? &Connection::d_ptr : Q_NULLPTR; } + operator RestrictedBool() const { return d_ptr && isConnected_helper() ? &Connection::d_ptr : nullptr; } #endif #ifdef Q_COMPILER_RVALUE_REFS - inline Connection(Connection &&o) : d_ptr(o.d_ptr) { o.d_ptr = Q_NULLPTR; } + inline Connection(Connection &&o) : d_ptr(o.d_ptr) { o.d_ptr = nullptr; } inline Connection &operator=(Connection &&other) { qSwap(d_ptr, other.d_ptr); return *this; } #endif diff --git a/src/corelib/kernel/qobjectdefs_impl.h b/src/corelib/kernel/qobjectdefs_impl.h index b9f2e47e32..17872d830e 100644 --- a/src/corelib/kernel/qobjectdefs_impl.h +++ b/src/corelib/kernel/qobjectdefs_impl.h @@ -372,10 +372,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, Q_NULLPTR, Q_NULLPTR, Q_NULLPTR); } + { if (!m_ref.deref()) m_impl(Destroy, this, nullptr, nullptr, nullptr); } - inline bool compare(void **a) { bool ret = false; 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); } + inline bool compare(void **a) { bool ret = false; m_impl(Compare, this, nullptr, a, &ret); return ret; } + inline void call(QObject *r, void **a) { m_impl(Call, this, r, a, nullptr); } protected: ~QSlotObjectBase() {} private: diff --git a/src/corelib/kernel/qsharedmemory.h b/src/corelib/kernel/qsharedmemory.h index 0d4edef23d..67cf52ac17 100644 --- a/src/corelib/kernel/qsharedmemory.h +++ b/src/corelib/kernel/qsharedmemory.h @@ -74,8 +74,8 @@ public: UnknownError }; - QSharedMemory(QObject *parent = Q_NULLPTR); - QSharedMemory(const QString &key, QObject *parent = Q_NULLPTR); + QSharedMemory(QObject *parent = nullptr); + QSharedMemory(const QString &key, QObject *parent = nullptr); ~QSharedMemory(); void setKey(const QString &key); diff --git a/src/corelib/kernel/qsocketnotifier.h b/src/corelib/kernel/qsocketnotifier.h index 92cdf5be95..38e5f27247 100644 --- a/src/corelib/kernel/qsocketnotifier.h +++ b/src/corelib/kernel/qsocketnotifier.h @@ -53,7 +53,7 @@ class Q_CORE_EXPORT QSocketNotifier : public QObject public: enum Type { Read, Write, Exception }; - QSocketNotifier(qintptr socket, Type, QObject *parent = Q_NULLPTR); + QSocketNotifier(qintptr socket, Type, QObject *parent = nullptr); ~QSocketNotifier(); qintptr socket() const; @@ -68,7 +68,7 @@ Q_SIGNALS: void activated(int socket, QPrivateSignal); protected: - bool event(QEvent *) Q_DECL_OVERRIDE; + bool event(QEvent *) override; private: Q_DISABLE_COPY(QSocketNotifier) diff --git a/src/corelib/kernel/qtimer.cpp b/src/corelib/kernel/qtimer.cpp index 55f75ab17e..85e95d7f7e 100644 --- a/src/corelib/kernel/qtimer.cpp +++ b/src/corelib/kernel/qtimer.cpp @@ -271,7 +271,7 @@ public: Q_SIGNALS: void timeout(); protected: - void timerEvent(QTimerEvent *) Q_DECL_OVERRIDE; + void timerEvent(QTimerEvent *) override; }; QSingleShotTimer::QSingleShotTimer(int msec, Qt::TimerType timerType, const QObject *r, const char *member) diff --git a/src/corelib/kernel/qtimer.h b/src/corelib/kernel/qtimer.h index 44ae04f38d..d41573264f 100644 --- a/src/corelib/kernel/qtimer.h +++ b/src/corelib/kernel/qtimer.h @@ -63,7 +63,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 = Q_NULLPTR); + explicit QTimer(QObject *parent = nullptr); ~QTimer(); inline bool isActive() const { return id >= 0; } @@ -197,7 +197,7 @@ public: #endif protected: - void timerEvent(QTimerEvent *) Q_DECL_OVERRIDE; + void timerEvent(QTimerEvent *) override; private: Q_DISABLE_COPY(QTimer) diff --git a/src/corelib/kernel/qtranslator.h b/src/corelib/kernel/qtranslator.h index 97be16bc90..e7c39191e7 100644 --- a/src/corelib/kernel/qtranslator.h +++ b/src/corelib/kernel/qtranslator.h @@ -55,11 +55,11 @@ class Q_CORE_EXPORT QTranslator : public QObject { Q_OBJECT public: - explicit QTranslator(QObject *parent = Q_NULLPTR); + explicit QTranslator(QObject *parent = nullptr); ~QTranslator(); virtual QString translate(const char *context, const char *sourceText, - const char *disambiguation = Q_NULLPTR, int n = -1) const; + const char *disambiguation = nullptr, int n = -1) const; virtual bool isEmpty() const; diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h index a2c5711993..6d4c163e76 100644 --- a/src/corelib/kernel/qvariant.h +++ b/src/corelib/kernel/qvariant.h @@ -284,14 +284,14 @@ class Q_CORE_EXPORT QVariant void detach(); inline bool isDetached() 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; + int toInt(bool *ok = nullptr) const; + uint toUInt(bool *ok = nullptr) const; + qlonglong toLongLong(bool *ok = nullptr) const; + qulonglong toULongLong(bool *ok = nullptr) const; bool toBool() const; - double toDouble(bool *ok = Q_NULLPTR) const; - float toFloat(bool *ok = Q_NULLPTR) const; - qreal toReal(bool *ok = Q_NULLPTR) const; + double toDouble(bool *ok = nullptr) const; + float toFloat(bool *ok = nullptr) const; + qreal toReal(bool *ok = nullptr) const; QByteArray toByteArray() const; QBitArray toBitArray() const; QString toString() const; @@ -370,7 +370,7 @@ class Q_CORE_EXPORT QVariant struct Private { inline Private() Q_DECL_NOTHROW : type(Invalid), is_shared(false), is_null(true) - { data.ptr = Q_NULLPTR; } + { data.ptr = nullptr; } // Internal constructor for initialized variants. explicit inline Private(uint variantType) Q_DECL_NOTHROW diff --git a/src/corelib/kernel/qvariant_p.h b/src/corelib/kernel/qvariant_p.h index 75c269d710..b22b7c231e 100644 --- a/src/corelib/kernel/qvariant_p.h +++ b/src/corelib/kernel/qvariant_p.h @@ -278,11 +278,11 @@ class QVariantIsNull Q_STATIC_ASSERT(!HasIsNullMethod<SelfTest2>::Value); struct SelfTest3 : public SelfTest1 {}; Q_STATIC_ASSERT(HasIsNullMethod<SelfTest3>::Value); - struct SelfTestFinal1 Q_DECL_FINAL { bool isNull() const; }; + struct SelfTestFinal1 final { bool isNull() const; }; Q_STATIC_ASSERT(HasIsNullMethod<SelfTestFinal1>::Value); - struct SelfTestFinal2 Q_DECL_FINAL {}; + struct SelfTestFinal2 final {}; Q_STATIC_ASSERT(!HasIsNullMethod<SelfTestFinal2>::Value); - struct SelfTestFinal3 Q_DECL_FINAL : public SelfTest1 {}; + struct SelfTestFinal3 final : public SelfTest1 {}; Q_STATIC_ASSERT(HasIsNullMethod<SelfTestFinal3>::Value); template<typename T, bool HasIsNull = HasIsNullMethod<T>::Value> diff --git a/src/corelib/kernel/qwineventnotifier.h b/src/corelib/kernel/qwineventnotifier.h index f29f325d13..624e77e638 100644 --- a/src/corelib/kernel/qwineventnotifier.h +++ b/src/corelib/kernel/qwineventnotifier.h @@ -54,8 +54,8 @@ class Q_CORE_EXPORT QWinEventNotifier : public QObject typedef Qt::HANDLE HANDLE; public: - explicit QWinEventNotifier(QObject *parent = Q_NULLPTR); - explicit QWinEventNotifier(HANDLE hEvent, QObject *parent = Q_NULLPTR); + explicit QWinEventNotifier(QObject *parent = nullptr); + explicit QWinEventNotifier(HANDLE hEvent, QObject *parent = nullptr); ~QWinEventNotifier(); void setHandle(HANDLE hEvent); diff --git a/src/corelib/mimetypes/qmimemagicrule_p.h b/src/corelib/mimetypes/qmimemagicrule_p.h index 0c6c1dbcd7..9b27ef2657 100644 --- a/src/corelib/mimetypes/qmimemagicrule_p.h +++ b/src/corelib/mimetypes/qmimemagicrule_p.h @@ -90,7 +90,7 @@ public: int endPos() const { return m_endPos; } QByteArray mask() const; - bool isValid() const { return m_matchFunction != Q_NULLPTR; } + bool isValid() const { return m_matchFunction != nullptr; } bool matches(const QByteArray &data) const; diff --git a/src/corelib/mimetypes/qmimeprovider_p.h b/src/corelib/mimetypes/qmimeprovider_p.h index 0be01d2fd0..3eae672823 100644 --- a/src/corelib/mimetypes/qmimeprovider_p.h +++ b/src/corelib/mimetypes/qmimeprovider_p.h @@ -98,17 +98,17 @@ public: QMimeBinaryProvider(QMimeDatabasePrivate *db); virtual ~QMimeBinaryProvider(); - virtual bool isValid() Q_DECL_OVERRIDE; - virtual QMimeType mimeTypeForName(const QString &name) Q_DECL_OVERRIDE; - virtual QMimeGlobMatchResult findByFileName(const QString &fileName) Q_DECL_OVERRIDE; - virtual QStringList parents(const QString &mime) Q_DECL_OVERRIDE; - virtual QString resolveAlias(const QString &name) Q_DECL_OVERRIDE; - virtual QStringList listAliases(const QString &name) Q_DECL_OVERRIDE; - virtual QMimeType findByMagic(const QByteArray &data, int *accuracyPtr) Q_DECL_OVERRIDE; - virtual QList<QMimeType> allMimeTypes() Q_DECL_OVERRIDE; - virtual void loadMimeTypePrivate(QMimeTypePrivate &) Q_DECL_OVERRIDE; - virtual void loadIcon(QMimeTypePrivate &) Q_DECL_OVERRIDE; - virtual void loadGenericIcon(QMimeTypePrivate &) Q_DECL_OVERRIDE; + virtual bool isValid() override; + virtual QMimeType mimeTypeForName(const QString &name) override; + virtual QMimeGlobMatchResult findByFileName(const QString &fileName) override; + virtual QStringList parents(const QString &mime) override; + virtual QString resolveAlias(const QString &name) override; + virtual QStringList listAliases(const QString &name) override; + virtual QMimeType findByMagic(const QByteArray &data, int *accuracyPtr) override; + virtual QList<QMimeType> allMimeTypes() override; + virtual void loadMimeTypePrivate(QMimeTypePrivate &) override; + virtual void loadIcon(QMimeTypePrivate &) override; + virtual void loadGenericIcon(QMimeTypePrivate &) override; private: struct CacheFile; @@ -141,14 +141,14 @@ public: QMimeXMLProvider(QMimeDatabasePrivate *db); ~QMimeXMLProvider(); - virtual bool isValid() Q_DECL_OVERRIDE; - virtual QMimeType mimeTypeForName(const QString &name) Q_DECL_OVERRIDE; - virtual QMimeGlobMatchResult findByFileName(const QString &fileName) Q_DECL_OVERRIDE; - virtual QStringList parents(const QString &mime) Q_DECL_OVERRIDE; - virtual QString resolveAlias(const QString &name) Q_DECL_OVERRIDE; - virtual QStringList listAliases(const QString &name) Q_DECL_OVERRIDE; - virtual QMimeType findByMagic(const QByteArray &data, int *accuracyPtr) Q_DECL_OVERRIDE; - virtual QList<QMimeType> allMimeTypes() Q_DECL_OVERRIDE; + virtual bool isValid() override; + virtual QMimeType mimeTypeForName(const QString &name) override; + virtual QMimeGlobMatchResult findByFileName(const QString &fileName) override; + virtual QStringList parents(const QString &mime) override; + virtual QString resolveAlias(const QString &name) override; + virtual QStringList listAliases(const QString &name) override; + virtual QMimeType findByMagic(const QByteArray &data, int *accuracyPtr) override; + virtual QList<QMimeType> allMimeTypes() override; bool load(const QString &fileName, QString *errorMessage); diff --git a/src/corelib/plugin/qlibrary.h b/src/corelib/plugin/qlibrary.h index 89be52aac3..0b37b8b134 100644 --- a/src/corelib/plugin/qlibrary.h +++ b/src/corelib/plugin/qlibrary.h @@ -65,10 +65,10 @@ public: Q_FLAG(LoadHint) Q_FLAG(LoadHints) - explicit QLibrary(QObject *parent = Q_NULLPTR); - explicit QLibrary(const QString& fileName, QObject *parent = Q_NULLPTR); - explicit QLibrary(const QString& fileName, int verNum, QObject *parent = Q_NULLPTR); - explicit QLibrary(const QString& fileName, const QString &version, QObject *parent = Q_NULLPTR); + explicit QLibrary(QObject *parent = nullptr); + explicit QLibrary(const QString& fileName, QObject *parent = nullptr); + explicit QLibrary(const QString& fileName, int verNum, QObject *parent = nullptr); + explicit QLibrary(const QString& fileName, const QString &version, QObject *parent = nullptr); ~QLibrary(); QFunctionPointer resolve(const char *symbol); diff --git a/src/corelib/plugin/qpluginloader.h b/src/corelib/plugin/qpluginloader.h index 80b10f76bf..5e417249a4 100644 --- a/src/corelib/plugin/qpluginloader.h +++ b/src/corelib/plugin/qpluginloader.h @@ -59,8 +59,8 @@ class Q_CORE_EXPORT QPluginLoader : public QObject Q_PROPERTY(QString fileName READ fileName WRITE setFileName) Q_PROPERTY(QLibrary::LoadHints loadHints READ loadHints WRITE setLoadHints) public: - explicit QPluginLoader(QObject *parent = Q_NULLPTR); - explicit QPluginLoader(const QString &fileName, QObject *parent = Q_NULLPTR); + explicit QPluginLoader(QObject *parent = nullptr); + explicit QPluginLoader(const QString &fileName, QObject *parent = nullptr); ~QPluginLoader(); QObject *instance(); diff --git a/src/corelib/statemachine/qabstractstate.h b/src/corelib/statemachine/qabstractstate.h index 02c7d9e830..ffc2eaae13 100644 --- a/src/corelib/statemachine/qabstractstate.h +++ b/src/corelib/statemachine/qabstractstate.h @@ -68,12 +68,12 @@ Q_SIGNALS: void activeChanged(bool active); protected: - QAbstractState(QState *parent = Q_NULLPTR); + QAbstractState(QState *parent = nullptr); virtual void onEntry(QEvent *event) = 0; virtual void onExit(QEvent *event) = 0; - bool event(QEvent *e) Q_DECL_OVERRIDE; + bool event(QEvent *e) override; protected: QAbstractState(QAbstractStatePrivate &dd, QState *parent); diff --git a/src/corelib/statemachine/qabstracttransition.cpp b/src/corelib/statemachine/qabstracttransition.cpp index 53c713d6a8..272e681fb4 100644 --- a/src/corelib/statemachine/qabstracttransition.cpp +++ b/src/corelib/statemachine/qabstracttransition.cpp @@ -258,7 +258,7 @@ void QAbstractTransition::setTargetStates(const QList<QAbstractState*> &targets) // Verify if any of the new target states is a null-pointer: for (int i = 0; i < targets.size(); ++i) { - if (targets.at(i) == Q_NULLPTR) { + if (targets.at(i) == nullptr) { qWarning("QAbstractTransition::setTargetStates: target state(s) cannot be null"); return; } diff --git a/src/corelib/statemachine/qabstracttransition.h b/src/corelib/statemachine/qabstracttransition.h index b86d26e969..9b35e0cdb6 100644 --- a/src/corelib/statemachine/qabstracttransition.h +++ b/src/corelib/statemachine/qabstracttransition.h @@ -72,7 +72,7 @@ public: }; Q_ENUM(TransitionType) - QAbstractTransition(QState *sourceState = Q_NULLPTR); + QAbstractTransition(QState *sourceState = nullptr); virtual ~QAbstractTransition(); QState *sourceState() const; @@ -102,7 +102,7 @@ protected: virtual void onTransition(QEvent *event) = 0; - bool event(QEvent *e) Q_DECL_OVERRIDE; + bool event(QEvent *e) override; protected: QAbstractTransition(QAbstractTransitionPrivate &dd, QState *parent); diff --git a/src/corelib/statemachine/qeventtransition.h b/src/corelib/statemachine/qeventtransition.h index 3c66e72658..ff4a991162 100644 --- a/src/corelib/statemachine/qeventtransition.h +++ b/src/corelib/statemachine/qeventtransition.h @@ -54,8 +54,8 @@ class Q_CORE_EXPORT QEventTransition : public QAbstractTransition Q_PROPERTY(QObject* eventSource READ eventSource WRITE setEventSource) Q_PROPERTY(QEvent::Type eventType READ eventType WRITE setEventType) public: - QEventTransition(QState *sourceState = Q_NULLPTR); - QEventTransition(QObject *object, QEvent::Type type, QState *sourceState = Q_NULLPTR); + QEventTransition(QState *sourceState = nullptr); + QEventTransition(QObject *object, QEvent::Type type, QState *sourceState = nullptr); ~QEventTransition(); QObject *eventSource() const; @@ -65,10 +65,10 @@ public: void setEventType(QEvent::Type type); protected: - bool eventTest(QEvent *event) Q_DECL_OVERRIDE; - void onTransition(QEvent *event) Q_DECL_OVERRIDE; + bool eventTest(QEvent *event) override; + void onTransition(QEvent *event) override; - bool event(QEvent *e) Q_DECL_OVERRIDE; + bool event(QEvent *e) override; protected: QEventTransition(QEventTransitionPrivate &dd, QState *parent); diff --git a/src/corelib/statemachine/qfinalstate.h b/src/corelib/statemachine/qfinalstate.h index 1563bef397..1e52a0411d 100644 --- a/src/corelib/statemachine/qfinalstate.h +++ b/src/corelib/statemachine/qfinalstate.h @@ -51,14 +51,14 @@ class Q_CORE_EXPORT QFinalState : public QAbstractState { Q_OBJECT public: - QFinalState(QState *parent = Q_NULLPTR); + QFinalState(QState *parent = nullptr); ~QFinalState(); protected: - void onEntry(QEvent *event) Q_DECL_OVERRIDE; - void onExit(QEvent *event) Q_DECL_OVERRIDE; + void onEntry(QEvent *event) override; + void onExit(QEvent *event) override; - bool event(QEvent *e) Q_DECL_OVERRIDE; + bool event(QEvent *e) override; protected: explicit QFinalState(QFinalStatePrivate &dd, QState *parent); diff --git a/src/corelib/statemachine/qhistorystate.cpp b/src/corelib/statemachine/qhistorystate.cpp index a179d7c75b..d4fb214a31 100644 --- a/src/corelib/statemachine/qhistorystate.cpp +++ b/src/corelib/statemachine/qhistorystate.cpp @@ -203,7 +203,7 @@ void QHistoryState::setDefaultTransition(QAbstractTransition *transition) QAbstractState *QHistoryState::defaultState() const { Q_D(const QHistoryState); - return d->defaultTransition ? d->defaultTransition->targetState() : Q_NULLPTR; + return d->defaultTransition ? d->defaultTransition->targetState() : nullptr; } static inline bool isSoleEntry(const QList<QAbstractState*> &states, const QAbstractState * state) diff --git a/src/corelib/statemachine/qhistorystate.h b/src/corelib/statemachine/qhistorystate.h index c20053abf6..44f4c5d6d4 100644 --- a/src/corelib/statemachine/qhistorystate.h +++ b/src/corelib/statemachine/qhistorystate.h @@ -61,8 +61,8 @@ public: }; Q_ENUM(HistoryType) - QHistoryState(QState *parent = Q_NULLPTR); - QHistoryState(HistoryType type, QState *parent = Q_NULLPTR); + QHistoryState(QState *parent = nullptr); + QHistoryState(HistoryType type, QState *parent = nullptr); ~QHistoryState(); QAbstractTransition *defaultTransition() const; @@ -80,10 +80,10 @@ Q_SIGNALS: void historyTypeChanged(QPrivateSignal); protected: - void onEntry(QEvent *event) Q_DECL_OVERRIDE; - void onExit(QEvent *event) Q_DECL_OVERRIDE; + void onEntry(QEvent *event) override; + void onExit(QEvent *event) override; - bool event(QEvent *e) Q_DECL_OVERRIDE; + bool event(QEvent *e) override; private: Q_DISABLE_COPY(QHistoryState) diff --git a/src/corelib/statemachine/qsignaltransition.h b/src/corelib/statemachine/qsignaltransition.h index 97c2916d9a..e785a18c73 100644 --- a/src/corelib/statemachine/qsignaltransition.h +++ b/src/corelib/statemachine/qsignaltransition.h @@ -55,17 +55,17 @@ class Q_CORE_EXPORT QSignalTransition : public QAbstractTransition Q_PROPERTY(QByteArray signal READ signal WRITE setSignal NOTIFY signalChanged) public: - QSignalTransition(QState *sourceState = Q_NULLPTR); + QSignalTransition(QState *sourceState = nullptr); QSignalTransition(const QObject *sender, const char *signal, - QState *sourceState = Q_NULLPTR); + QState *sourceState = nullptr); #ifdef Q_QDOC template<typename PointerToMemberFunction> QSignalTransition(const QObject *object, PointerToMemberFunction signal, - QState *sourceState = Q_NULLPTR); + QState *sourceState = nullptr); #elif defined(Q_COMPILER_DELEGATING_CONSTRUCTORS) template <typename Func> QSignalTransition(const typename QtPrivate::FunctionPointer<Func>::Object *obj, - Func sig, QState *srcState = Q_NULLPTR) + Func sig, QState *srcState = nullptr) : QSignalTransition(obj, QMetaMethod::fromSignal(sig).methodSignature().constData(), srcState) { } @@ -80,10 +80,10 @@ public: void setSignal(const QByteArray &signal); protected: - bool eventTest(QEvent *event) Q_DECL_OVERRIDE; - void onTransition(QEvent *event) Q_DECL_OVERRIDE; + bool eventTest(QEvent *event) override; + void onTransition(QEvent *event) override; - bool event(QEvent *e) Q_DECL_OVERRIDE; + bool event(QEvent *e) override; Q_SIGNALS: void senderObjectChanged(QPrivateSignal); diff --git a/src/corelib/statemachine/qsignaltransition_p.h b/src/corelib/statemachine/qsignaltransition_p.h index f270a5be4a..0666e600a4 100644 --- a/src/corelib/statemachine/qsignaltransition_p.h +++ b/src/corelib/statemachine/qsignaltransition_p.h @@ -70,7 +70,7 @@ public: void unregister(); void maybeRegister(); - virtual void callOnTransition(QEvent *e) Q_DECL_OVERRIDE; + virtual void callOnTransition(QEvent *e) override; const QObject *sender; QByteArray signal; diff --git a/src/corelib/statemachine/qstate.cpp b/src/corelib/statemachine/qstate.cpp index 76dcbf784b..6efa4897d6 100644 --- a/src/corelib/statemachine/qstate.cpp +++ b/src/corelib/statemachine/qstate.cpp @@ -396,8 +396,8 @@ public: : QAbstractTransition() { setTargetState(target); } protected: - void onTransition(QEvent *) Q_DECL_OVERRIDE {} - bool eventTest(QEvent *) Q_DECL_OVERRIDE { return true; } + void onTransition(QEvent *) override {} + bool eventTest(QEvent *) override { return true; } }; } // namespace @@ -524,7 +524,7 @@ void QState::setChildMode(ChildMode mode) if (mode == QState::ParallelStates && d->initialState) { qWarning("QState::setChildMode: setting the child-mode of state %p to " "parallel removes the initial state", this); - d->initialState = Q_NULLPTR; + d->initialState = nullptr; emit initialStateChanged(QState::QPrivateSignal()); } diff --git a/src/corelib/statemachine/qstate.h b/src/corelib/statemachine/qstate.h index 33f84c2de0..9f1f07dfcc 100644 --- a/src/corelib/statemachine/qstate.h +++ b/src/corelib/statemachine/qstate.h @@ -71,8 +71,8 @@ public: }; Q_ENUM(RestorePolicy) - QState(QState *parent = Q_NULLPTR); - QState(ChildMode childMode, QState *parent = Q_NULLPTR); + QState(QState *parent = nullptr); + QState(ChildMode childMode, QState *parent = nullptr); ~QState(); QAbstractState *errorState() const; @@ -116,10 +116,10 @@ Q_SIGNALS: void errorStateChanged(QPrivateSignal); protected: - void onEntry(QEvent *event) Q_DECL_OVERRIDE; - void onExit(QEvent *event) Q_DECL_OVERRIDE; + void onEntry(QEvent *event) override; + void onExit(QEvent *event) override; - bool event(QEvent *e) Q_DECL_OVERRIDE; + bool event(QEvent *e) override; protected: QState(QStatePrivate &dd, QState *parent); diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp index 1d80da55c9..eb425bcd4f 100644 --- a/src/corelib/statemachine/qstatemachine.cpp +++ b/src/corelib/statemachine/qstatemachine.cpp @@ -560,7 +560,7 @@ QList<QAbstractTransition*> QStateMachinePrivate::selectTransitions(QEvent *even QList<QAbstractTransition*> enabledTransitions; const_cast<QStateMachine*>(q)->beginSelectTransitions(event); for (QAbstractState *state : qAsConst(configuration_sorted)) { - QVector<QState*> lst = getProperAncestors(state, Q_NULLPTR); + QVector<QState*> lst = getProperAncestors(state, nullptr); if (QState *grp = toStandardState(state)) lst.prepend(grp); bool found = false; @@ -767,7 +767,7 @@ QSet<QAbstractState*> QStateMachinePrivate::computeExitSet_Unordered(QAbstractTr QList<QAbstractState *> effectiveTargetStates = getEffectiveTargetStates(t, cache); QAbstractState *domain = getTransitionDomain(t, effectiveTargetStates, cache); - if (domain == Q_NULLPTR && !t->targetStates().isEmpty()) { + if (domain == nullptr && !t->targetStates().isEmpty()) { // So we didn't find the least common ancestor for the source and target states of the // transition. If there were not target states, that would be fine: then the transition // will fire any events or signals, but not exit the state. @@ -909,7 +909,7 @@ QAbstractState *QStateMachinePrivate::getTransitionDomain(QAbstractTransition *t if (effectiveTargetStates.isEmpty()) return 0; - QAbstractState *domain = Q_NULLPTR; + QAbstractState *domain = nullptr; if (cache->transitionDomain(t, &domain)) return domain; @@ -1721,8 +1721,8 @@ QAbstractTransition *QStateMachinePrivate::createInitialTransition() const : QAbstractTransition() { setTargetStates(targets); } protected: - virtual bool eventTest(QEvent *) Q_DECL_OVERRIDE { return true; } - virtual void onTransition(QEvent *) Q_DECL_OVERRIDE {} + virtual bool eventTest(QEvent *) override { return true; } + virtual void onTransition(QEvent *) override {} }; QState *root = rootState(); @@ -2126,8 +2126,8 @@ public: : QAbstractTransition() { setTargetState(target); } protected: - void onTransition(QEvent *) Q_DECL_OVERRIDE { deleteLater(); } - bool eventTest(QEvent *) Q_DECL_OVERRIDE { return true; } + void onTransition(QEvent *) override { deleteLater(); } + bool eventTest(QEvent *) override { return true; } }; } // namespace diff --git a/src/corelib/statemachine/qstatemachine.h b/src/corelib/statemachine/qstatemachine.h index 4f31252eed..fd90b86fd5 100644 --- a/src/corelib/statemachine/qstatemachine.h +++ b/src/corelib/statemachine/qstatemachine.h @@ -109,8 +109,8 @@ public: NoCommonAncestorForTransitionError }; - explicit QStateMachine(QObject *parent = Q_NULLPTR); - explicit QStateMachine(QState::ChildMode childMode, QObject *parent = Q_NULLPTR); + explicit QStateMachine(QObject *parent = nullptr); + explicit QStateMachine(QState::ChildMode childMode, QObject *parent = nullptr); ~QStateMachine(); void addState(QAbstractState *state); @@ -141,7 +141,7 @@ public: QSet<QAbstractState*> configuration() const; #if QT_CONFIG(qeventtransition) - bool eventFilter(QObject *watched, QEvent *event) Q_DECL_OVERRIDE; + bool eventFilter(QObject *watched, QEvent *event) override; #endif public Q_SLOTS: @@ -156,8 +156,8 @@ Q_SIGNALS: protected: - void onEntry(QEvent *event) Q_DECL_OVERRIDE; - void onExit(QEvent *event) Q_DECL_OVERRIDE; + void onEntry(QEvent *event) override; + void onExit(QEvent *event) override; virtual void beginSelectTransitions(QEvent *event); virtual void endSelectTransitions(QEvent *event); @@ -165,7 +165,7 @@ protected: virtual void beginMicrostep(QEvent *event); virtual void endMicrostep(QEvent *event); - bool event(QEvent *e) Q_DECL_OVERRIDE; + bool event(QEvent *e) override; protected: QStateMachine(QStateMachinePrivate &dd, QObject *parent); diff --git a/src/corelib/thread/qatomic.h b/src/corelib/thread/qatomic.h index f9eacbf6f0..f17c38e2fe 100644 --- a/src/corelib/thread/qatomic.h +++ b/src/corelib/thread/qatomic.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2017 The Qt Company Ltd. ** Copyright (C) 2016 Intel Corporation. ** Contact: https://www.qt.io/licensing/ ** @@ -168,9 +168,9 @@ class QAtomicPointer : public QBasicAtomicPointer<T> { public: #ifdef QT_BASIC_ATOMIC_HAS_CONSTRUCTORS - constexpr QAtomicPointer(T *value = 0) Q_DECL_NOTHROW : QBasicAtomicPointer<T>(value) {} + constexpr QAtomicPointer(T *value = nullptr) Q_DECL_NOTHROW : QBasicAtomicPointer<T>(value) {} #else - inline QAtomicPointer(T *value = 0) Q_DECL_NOTHROW + inline QAtomicPointer(T *value = nullptr) Q_DECL_NOTHROW { this->store(value); } diff --git a/src/corelib/thread/qbasicatomic.h b/src/corelib/thread/qbasicatomic.h index 24218e833a..92db7a6228 100644 --- a/src/corelib/thread/qbasicatomic.h +++ b/src/corelib/thread/qbasicatomic.h @@ -90,6 +90,7 @@ template <typename T> class QBasicAtomicInteger { public: + typedef T Type; typedef QAtomicOps<T> Ops; // static check that this is a valid integer Q_STATIC_ASSERT_X(QTypeInfo<T>::isIntegral, "template parameter is not an integral type"); diff --git a/src/corelib/thread/qexception.cpp b/src/corelib/thread/qexception.cpp index 62c2b608d8..e00181e64b 100644 --- a/src/corelib/thread/qexception.cpp +++ b/src/corelib/thread/qexception.cpp @@ -171,7 +171,7 @@ public: }; ExceptionHolder::ExceptionHolder(QException *exception) -: base(exception ? new Base(exception) : Q_NULLPTR) {} +: base(exception ? new Base(exception) : nullptr) {} ExceptionHolder::ExceptionHolder(const ExceptionHolder &other) : base(other.base) @@ -188,7 +188,7 @@ ExceptionHolder::~ExceptionHolder() QException *ExceptionHolder::exception() const { if (!base) - return Q_NULLPTR; + return nullptr; return base->exception; } diff --git a/src/corelib/thread/qexception.h b/src/corelib/thread/qexception.h index b14d386c69..5c43cedffd 100644 --- a/src/corelib/thread/qexception.h +++ b/src/corelib/thread/qexception.h @@ -80,8 +80,8 @@ public: throw() #endif ; - void raise() const Q_DECL_OVERRIDE; - QUnhandledException *clone() const Q_DECL_OVERRIDE; + void raise() const override; + QUnhandledException *clone() const override; }; namespace QtPrivate { @@ -90,7 +90,7 @@ class Base; class Q_CORE_EXPORT ExceptionHolder { public: - ExceptionHolder(QException *exception = Q_NULLPTR); + ExceptionHolder(QException *exception = nullptr); ExceptionHolder(const ExceptionHolder &other); void operator=(const ExceptionHolder &other); // ### Qt6: copy-assign operator shouldn't return void. Remove this method and the copy-ctor, they are unneeded. ~ExceptionHolder(); diff --git a/src/corelib/thread/qfutex_p.h b/src/corelib/thread/qfutex_p.h new file mode 100644 index 0000000000..483664c783 --- /dev/null +++ b/src/corelib/thread/qfutex_p.h @@ -0,0 +1,142 @@ +/**************************************************************************** +** +** Copyright (C) 2017 Intel Corporation. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QFUTEX_P_H +#define QFUTEX_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <qglobal.h> + +QT_BEGIN_NAMESPACE + +namespace QtDummyFutex { + Q_DECL_CONSTEXPR inline bool futexAvailable() { return false; } + template <typename Atomic> + inline bool futexWait(Atomic &, typename Atomic::Type, int = 0) + { Q_UNREACHABLE(); return false; } + template <typename Atomic> inline void futexWakeOne(Atomic &) + { Q_UNREACHABLE(); } + template <typename Atomic> inline void futexWakeAll(Atomic &) + { Q_UNREACHABLE(); } +} + +QT_END_NAMESPACE + +#if defined(Q_OS_LINUX) && !defined(QT_LINUXBASE) +// use Linux mutexes everywhere except for LSB builds +# include <sys/syscall.h> +# include <errno.h> +# include <limits.h> +# include <unistd.h> +# include <asm/unistd.h> +# include <linux/futex.h> +# define QT_ALWAYS_USE_FUTEX + +// if not defined in linux/futex.h +# define FUTEX_PRIVATE_FLAG 128 // added in v2.6.22 + +QT_BEGIN_NAMESPACE +namespace QtLinuxFutex { + constexpr inline bool futexAvailable() { return true; } + inline int _q_futex(int *addr, int op, int val, quintptr val2 = 0, + int *addr2 = nullptr, int val3 = 0) Q_DECL_NOTHROW + { + // we use __NR_futex because some libcs (like Android's bionic) don't + // provide SYS_futex etc. + return syscall(__NR_futex, addr, op | FUTEX_PRIVATE_FLAG, val, val2, addr2, val3); + } + template <typename T> int *addr(T *ptr) + { + int *int_addr = reinterpret_cast<int *>(ptr); +#if Q_BYTE_ORDER == Q_BIG_ENDIAN + if (sizeof(T) > sizeof(int)) + int_addr++; //We want a pointer to the least significant half +#endif + return int_addr; + } + + template <typename Atomic> + inline void futexWait(Atomic &futex, typename Atomic::Type expectedValue) + { + _q_futex(addr(&futex), FUTEX_WAIT, qintptr(expectedValue)); + } + template <typename Atomic> + inline bool futexWait(Atomic &futex, typename Atomic::Type expectedValue, qint64 nstimeout) + { + struct timespec ts; + ts.tv_sec = nstimeout / 1000 / 1000 / 1000; + ts.tv_nsec = nstimeout % (1000 * 1000 * 1000); + int r = _q_futex(addr(&futex), FUTEX_WAIT, qintptr(expectedValue), quintptr(&ts)); + return r == 0 || errno != ETIMEDOUT; + } + template <typename Atomic> inline void futexWakeOne(Atomic &futex) + { + _q_futex(addr(&futex), FUTEX_WAKE, 1); + } + template <typename Atomic> inline void futexWakeAll(Atomic &futex) + { + _q_futex(addr(&futex), FUTEX_WAKE, INT_MAX); + } + template <typename Atomic> inline + void futexWakeOp(Atomic &futex1, int wake1, int wake2, Atomic &futex2, quint32 op) + { + _q_futex(addr(&futex1), FUTEX_WAKE_OP, wake1, wake2, addr(&futex2), op); + } +} +namespace QtFutex = QtLinuxFutex; +QT_END_NAMESPACE + +#else + +QT_BEGIN_NAMESPACE +namespace QtFutex = QtDummyFutex; +QT_END_NAMESPACE +#endif + +#endif // QFUTEX_P_H diff --git a/src/corelib/thread/qfutureinterface.h b/src/corelib/thread/qfutureinterface.h index 7b12f51e3e..320c2d7b33 100644 --- a/src/corelib/thread/qfutureinterface.h +++ b/src/corelib/thread/qfutureinterface.h @@ -291,7 +291,7 @@ public: void reportResult(const void *, int) { } void reportResults(const QVector<void> &, int) { } - void reportFinished(const void * = Q_NULLPTR) { QFutureInterfaceBase::reportFinished(); } + void reportFinished(const void * = nullptr) { QFutureInterfaceBase::reportFinished(); } }; QT_END_NAMESPACE diff --git a/src/corelib/thread/qfuturewatcher.h b/src/corelib/thread/qfuturewatcher.h index 3357e27037..5143db8d2e 100644 --- a/src/corelib/thread/qfuturewatcher.h +++ b/src/corelib/thread/qfuturewatcher.h @@ -58,7 +58,7 @@ class Q_CORE_EXPORT QFutureWatcherBase : public QObject Q_DECLARE_PRIVATE(QFutureWatcherBase) public: - explicit QFutureWatcherBase(QObject *parent = Q_NULLPTR); + explicit QFutureWatcherBase(QObject *parent = nullptr); // de-inline dtor int progressValue() const; @@ -76,7 +76,7 @@ public: void setPendingResultsLimit(int limit); - bool event(QEvent *event) Q_DECL_OVERRIDE; + bool event(QEvent *event) override; Q_SIGNALS: void started(); @@ -98,8 +98,8 @@ public Q_SLOTS: void togglePaused(); protected: - void connectNotify (const QMetaMethod &signal) Q_DECL_OVERRIDE; - void disconnectNotify (const QMetaMethod &signal) Q_DECL_OVERRIDE; + void connectNotify (const QMetaMethod &signal) override; + void disconnectNotify (const QMetaMethod &signal) override; // called from setFuture() implemented in template sub-classes void connectOutputInterface(); @@ -166,8 +166,8 @@ public Q_SLOTS: private: QFuture<T> m_future; - const QFutureInterfaceBase &futureInterface() const Q_DECL_OVERRIDE { return m_future.d; } - QFutureInterfaceBase &futureInterface() Q_DECL_OVERRIDE { return m_future.d; } + const QFutureInterfaceBase &futureInterface() const override { return m_future.d; } + QFutureInterfaceBase &futureInterface() override { return m_future.d; } }; template <typename T> @@ -185,7 +185,7 @@ template <> class QFutureWatcher<void> : public QFutureWatcherBase { public: - explicit QFutureWatcher(QObject *_parent = Q_NULLPTR) + explicit QFutureWatcher(QObject *_parent = nullptr) : QFutureWatcherBase(_parent) { } ~QFutureWatcher() @@ -197,8 +197,8 @@ public: private: QFuture<void> m_future; - const QFutureInterfaceBase &futureInterface() const Q_DECL_OVERRIDE { return m_future.d; } - QFutureInterfaceBase &futureInterface() Q_DECL_OVERRIDE { return m_future.d; } + const QFutureInterfaceBase &futureInterface() const override { return m_future.d; } + QFutureInterfaceBase &futureInterface() override { return m_future.d; } }; Q_INLINE_TEMPLATE void QFutureWatcher<void>::setFuture(const QFuture<void> &_future) diff --git a/src/corelib/thread/qfuturewatcher_p.h b/src/corelib/thread/qfuturewatcher_p.h index e83bdaf45a..25d1ef8d25 100644 --- a/src/corelib/thread/qfuturewatcher_p.h +++ b/src/corelib/thread/qfuturewatcher_p.h @@ -69,8 +69,8 @@ class QFutureWatcherBasePrivate : public QObjectPrivate, public: QFutureWatcherBasePrivate(); - void postCallOutEvent(const QFutureCallOutEvent &callOutEvent) Q_DECL_OVERRIDE; - void callOutInterfaceDisconnected() Q_DECL_OVERRIDE; + void postCallOutEvent(const QFutureCallOutEvent &callOutEvent) override; + void callOutInterfaceDisconnected() override; void sendCallOutEvent(QFutureCallOutEvent *event); diff --git a/src/corelib/thread/qmutex.h b/src/corelib/thread/qmutex.h index 607cc13a2f..541f6af546 100644 --- a/src/corelib/thread/qmutex.h +++ b/src/corelib/thread/qmutex.h @@ -92,16 +92,16 @@ public: private: inline bool fastTryLock() Q_DECL_NOTHROW { - return d_ptr.testAndSetAcquire(Q_NULLPTR, dummyLocked()); + return d_ptr.testAndSetAcquire(nullptr, dummyLocked()); } inline bool fastTryUnlock() Q_DECL_NOTHROW { - return d_ptr.testAndSetRelease(dummyLocked(), Q_NULLPTR); + return d_ptr.testAndSetRelease(dummyLocked(), nullptr); } inline bool fastTryLock(QMutexData *¤t) Q_DECL_NOTHROW { - return d_ptr.testAndSetAcquire(Q_NULLPTR, dummyLocked(), current); + return d_ptr.testAndSetAcquire(nullptr, dummyLocked(), current); } inline bool fastTryUnlock(QMutexData *¤t) Q_DECL_NOTHROW { - return d_ptr.testAndSetRelease(dummyLocked(), Q_NULLPTR, current); + return d_ptr.testAndSetRelease(dummyLocked(), nullptr, current); } void lockInternal() QT_MUTEX_LOCK_NOEXCEPT; @@ -287,7 +287,7 @@ public: inline void unlock() Q_DECL_NOTHROW {} void relock() Q_DECL_NOTHROW {} - inline QMutex *mutex() const Q_DECL_NOTHROW { return Q_NULLPTR; } + inline QMutex *mutex() const Q_DECL_NOTHROW { return nullptr; } private: Q_DISABLE_COPY(QMutexLocker) diff --git a/src/corelib/thread/qmutex_linux.cpp b/src/corelib/thread/qmutex_linux.cpp index 5f6e74ac6f..d3d97ea108 100644 --- a/src/corelib/thread/qmutex_linux.cpp +++ b/src/corelib/thread/qmutex_linux.cpp @@ -44,15 +44,9 @@ #ifndef QT_NO_THREAD #include "qatomic.h" #include "qmutex_p.h" -#include "qelapsedtimer.h" +#include "qfutex_p.h" -#include <linux/futex.h> -#include <sys/syscall.h> -#include <unistd.h> -#include <errno.h> -#include <asm/unistd.h> - -#ifndef QT_LINUX_FUTEX +#ifndef QT_ALWAYS_USE_FUTEX # error "Qt build is broken: qmutex_linux.cpp is being built but futex support is not wanted" #endif @@ -63,6 +57,8 @@ QT_BEGIN_NAMESPACE +using namespace QtFutex; + /* * QBasicMutex implementation on Linux with futexes * @@ -107,20 +103,6 @@ QT_BEGIN_NAMESPACE * waiting in the past. We then set the mutex to 0x0 and perform a FUTEX_WAKE. */ -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); -#if Q_BYTE_ORDER == Q_BIG_ENDIAN && QT_POINTER_SIZE == 8 - int_addr++; //We want a pointer to the 32 least significant bit of QMutex::d -#endif - int *addr2 = 0; - int val2 = 0; - - // we use __NR_futex because some libcs (like Android's bionic) don't - // provide SYS_futex etc. - return syscall(__NR_futex, int_addr, op | FUTEX_PRIVATE_FLAG, val, timeout, addr2, val2); -} - static inline QMutexData *dummyFutexValue() { return reinterpret_cast<QMutexData *>(quintptr(3)); @@ -136,36 +118,38 @@ bool lockInternal_helper(QBasicAtomicPointer<QMutexData> &d_ptr, int timeout = - if (timeout == 0) return false; - struct timespec ts, *pts = 0; - if (IsTimed && timeout > 0) { - ts.tv_sec = timeout / 1000; - ts.tv_nsec = (timeout % 1000) * 1000 * 1000; - } - // the mutex is locked already, set a bit indicating we're waiting - while (d_ptr.fetchAndStoreAcquire(dummyFutexValue()) != 0) { - if (IsTimed && pts == &ts) { - // recalculate the timeout - qint64 xtimeout = qint64(timeout) * 1000 * 1000; - xtimeout -= elapsedTimer->nsecsElapsed(); - if (xtimeout <= 0) { - // timer expired after we returned - return false; - } - ts.tv_sec = xtimeout / Q_INT64_C(1000) / 1000 / 1000; - ts.tv_nsec = xtimeout % (Q_INT64_C(1000) * 1000 * 1000); - } - if (IsTimed && timeout > 0) - pts = &ts; + if (d_ptr.fetchAndStoreAcquire(dummyFutexValue()) == nullptr) + return true; + qint64 nstimeout = timeout * Q_INT64_C(1000) * 1000; + qint64 remainingTime = nstimeout; + forever { // successfully set the waiting bit, now sleep - int r = _q_futex(&d_ptr, FUTEX_WAIT, quintptr(dummyFutexValue()), pts); - if (IsTimed && r != 0 && errno == ETIMEDOUT) - return false; + if (IsTimed && nstimeout >= 0) { + bool r = futexWait(d_ptr, dummyFutexValue(), remainingTime); + if (!r) + return false; + + // we got woken up, so try to acquire the mutex + // note we must set to dummyFutexValue because there could be other threads + // also waiting + if (d_ptr.fetchAndStoreAcquire(dummyFutexValue()) == nullptr) + return true; - // we got woken up, so try to acquire the mutex - // note we must set to dummyFutexValue because there could be other threads - // also waiting + // recalculate the timeout + remainingTime = nstimeout - elapsedTimer->nsecsElapsed(); + if (remainingTime <= 0) + return false; + } else { + futexWait(d_ptr, dummyFutexValue()); + + // we got woken up, so try to acquire the mutex + // note we must set to dummyFutexValue because there could be other threads + // also waiting + if (d_ptr.fetchAndStoreAcquire(dummyFutexValue()) == nullptr) + return true; + } } Q_ASSERT(d_ptr.load()); @@ -195,10 +179,9 @@ void QBasicMutex::unlockInternal() Q_DECL_NOTHROW Q_ASSERT(!isRecursive()); d_ptr.storeRelease(0); - _q_futex(&d_ptr, FUTEX_WAKE, 1, 0); + futexWakeOne(d_ptr); } - QT_END_NAMESPACE #endif // QT_NO_THREAD diff --git a/src/corelib/thread/qreadwritelock.h b/src/corelib/thread/qreadwritelock.h index 777efdb3bf..ecdb98f2f5 100644 --- a/src/corelib/thread/qreadwritelock.h +++ b/src/corelib/thread/qreadwritelock.h @@ -205,7 +205,7 @@ public: static inline void unlock() Q_DECL_NOTHROW { } static inline void relock() Q_DECL_NOTHROW { } - static inline QReadWriteLock *readWriteLock() Q_DECL_NOTHROW { return Q_NULLPTR; } + static inline QReadWriteLock *readWriteLock() Q_DECL_NOTHROW { return nullptr; } private: Q_DISABLE_COPY(QReadLocker) @@ -219,7 +219,7 @@ public: static inline void unlock() Q_DECL_NOTHROW { } static inline void relock() Q_DECL_NOTHROW { } - static inline QReadWriteLock *readWriteLock() Q_DECL_NOTHROW { return Q_NULLPTR; } + static inline QReadWriteLock *readWriteLock() Q_DECL_NOTHROW { return nullptr; } private: Q_DISABLE_COPY(QWriteLocker) diff --git a/src/corelib/thread/qresultstore.h b/src/corelib/thread/qresultstore.h index 6c814ef854..5f0cefa133 100644 --- a/src/corelib/thread/qresultstore.h +++ b/src/corelib/thread/qresultstore.h @@ -67,8 +67,8 @@ class ResultItem public: ResultItem(const void *_result, int _count) : m_count(_count), result(_result) { } // contruct with vector of results ResultItem(const void *_result) : m_count(0), result(_result) { } // construct with result - ResultItem() : m_count(0), result(Q_NULLPTR) { } - bool isValid() const { return result != Q_NULLPTR; } + ResultItem() : m_count(0), result(nullptr) { } + bool isValid() const { return result != nullptr; } bool isVector() const { return m_count != 0; } int count() const { return (m_count == 0) ? 1 : m_count; } int m_count; // result is either a pointer to a result or to a vector of results, diff --git a/src/corelib/thread/qsemaphore.cpp b/src/corelib/thread/qsemaphore.cpp index 96c031eec6..21acc533a1 100644 --- a/src/corelib/thread/qsemaphore.cpp +++ b/src/corelib/thread/qsemaphore.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2017 Intel Corporation. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -41,12 +42,15 @@ #ifndef QT_NO_THREAD #include "qmutex.h" +#include "qfutex_p.h" #include "qwaitcondition.h" #include "qdeadlinetimer.h" #include "qdatetime.h" QT_BEGIN_NAMESPACE +using namespace QtFutex; + /*! \class QSemaphore \inmodule QtCore @@ -97,6 +101,117 @@ QT_BEGIN_NAMESPACE \sa QSemaphoreReleaser, QMutex, QWaitCondition, QThread, {Semaphores Example} */ +/* + QSemaphore futex operation + + QSemaphore stores a 32-bit integer with the counter of currently available + tokens (value between 0 and INT_MAX). When a thread attempts to acquire n + tokens and the counter is larger than that, we perform a compare-and-swap + with the new count. If that succeeds, the acquisition worked; if not, we + loop again because the counter changed. If there were not enough tokens, + we'll perform a futex-wait. + + Before we do, we set the high bit in the futex to indicate that semaphore + is contended: that is, there's a thread waiting for more tokens. On + release() for n tokens, we perform a fetch-and-add of n and then check if + that high bit was set. If it was, then we clear that bit and perform a + futex-wake on the semaphore to indicate the waiting threads can wake up and + acquire tokens. Which ones get woken up is unspecified. + + If the system has the ability to wake up a precise number of threads, has + Linux's FUTEX_WAKE_OP functionality, and is 64-bit, we'll use the high word + as a copy of the low word, but the sign bit indicating the presence of a + thread waiting for multiple tokens. So when releasing n tokens on those + systems, we tell the kernel to wake up n single-token threads and all of + the multi-token ones, then clear that wait bit. Which threads get woken up + is unspecified, but it's likely single-token threads will get woken up + first. + */ +static const quint32 futexContendedBit = 1U << 31; + +static int futexAvailCounter(quintptr v) +{ + // the low 31 bits + return int(v & (futexContendedBit - 1)); +} + +static quintptr futexCounterParcel(int n) +{ + // replicate the 31 bits if we're on 64-bit + quint64 nn = quint32(n); + nn |= (nn << 32); + return quintptr(nn); +} + +static QBasicAtomicInteger<quint32> *futexLow32(QBasicAtomicInteger<quintptr> *ptr) +{ + auto result = reinterpret_cast<QBasicAtomicInteger<quint32> *>(ptr); +#if Q_BYTE_ORDER == Q_BIG_ENDIAN && QT_POINTER_SIZE > 4 + ++result; +#endif + return result; +} + +#ifdef FUTEX_OP +// quintptr might be 32bit, in which case we want this to be 0, without implicitly casting. +static const quintptr futexMultiWaiterBit = static_cast<quintptr>(Q_UINT64_C(1) << 63); +static QBasicAtomicInteger<quint32> *futexHigh32(QBasicAtomicInteger<quintptr> *ptr) +{ + auto result = reinterpret_cast<QBasicAtomicInteger<quint32> *>(ptr); +#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN && QT_POINTER_SIZE > 4 + ++result; +#endif + return result; +} +#endif + +template <bool IsTimed> bool futexSemaphoreTryAcquire(QBasicAtomicInteger<quintptr> &u, int n, int timeout) +{ + QDeadlineTimer timer(IsTimed ? QDeadlineTimer(timeout) : QDeadlineTimer()); + quintptr curValue = u.loadAcquire(); + qint64 remainingTime = timeout * Q_INT64_C(1000) * 1000; + forever { + int available = futexAvailCounter(curValue); + if (available >= n) { + // try to acquire + quintptr newValue = curValue - futexCounterParcel(n); + if (u.testAndSetOrdered(curValue, newValue, curValue)) + return true; // succeeded! + continue; + } + + // not enough tokens available, put us to wait + if (remainingTime == 0) + return false; + + // set the contended and multi-wait bits + quintptr bitsToSet = futexContendedBit; + auto ptr = futexLow32(&u); +#ifdef FUTEX_OP + if (n > 1 && sizeof(curValue) >= sizeof(int)) { + bitsToSet |= futexMultiWaiterBit; + ptr = futexHigh32(&u); + } +#endif + + // the value is the same for either branch + u.fetchAndOrRelaxed(bitsToSet); + curValue |= bitsToSet; + + if (IsTimed && remainingTime > 0) { + bool timedout = !futexWait(*ptr, curValue, remainingTime); + if (timedout) + return false; + } else { + futexWait(*ptr, curValue); + } + + curValue = u.loadAcquire(); + if (IsTimed) + remainingTime = timer.remainingTimeNSecs(); + } +} + class QSemaphorePrivate { public: inline QSemaphorePrivate(int n) : avail(n) { } @@ -116,7 +231,10 @@ public: QSemaphore::QSemaphore(int n) { Q_ASSERT_X(n >= 0, "QSemaphore", "parameter 'n' must be non-negative"); - d = new QSemaphorePrivate(n); + if (futexAvailable()) + u.store(n); + else + d = new QSemaphorePrivate(n); } /*! @@ -126,7 +244,10 @@ QSemaphore::QSemaphore(int n) undefined behavior. */ QSemaphore::~QSemaphore() -{ delete d; } +{ + if (!futexAvailable()) + delete d; +} /*! Tries to acquire \c n resources guarded by the semaphore. If \a n @@ -138,6 +259,12 @@ QSemaphore::~QSemaphore() void QSemaphore::acquire(int n) { Q_ASSERT_X(n >= 0, "QSemaphore::acquire", "parameter 'n' must be non-negative"); + + if (futexAvailable()) { + futexSemaphoreTryAcquire<false>(u, n, -1); + return; + } + QMutexLocker locker(&d->mutex); while (n > d->avail) d->cond.wait(locker.mutex()); @@ -160,6 +287,69 @@ void QSemaphore::acquire(int n) void QSemaphore::release(int n) { Q_ASSERT_X(n >= 0, "QSemaphore::release", "parameter 'n' must be non-negative"); + + if (futexAvailable()) { + quintptr prevValue = u.fetchAndAddRelease(futexCounterParcel(n)); + if (prevValue & futexContendedBit) { +#ifdef FUTEX_OP + if (sizeof(u) == sizeof(int)) { + /* + On 32-bit systems, all waiters are waiting on the same address, + so we'll wake them all and ask the kernel to clear the high bit. + + atomic { + int oldval = u; + u = oldval & ~(1 << 31); + futexWake(u, INT_MAX); + if (oldval == 0) // impossible condition + futexWake(u, INT_MAX); + } + */ + quint32 op = FUTEX_OP_ANDN | FUTEX_OP_OPARG_SHIFT; + quint32 oparg = 31; + quint32 cmp = FUTEX_OP_CMP_EQ; + quint32 cmparg = 0; + futexWakeOp(u, INT_MAX, INT_MAX, u, FUTEX_OP(op, oparg, cmp, cmparg)); + } else { + /* + On 64-bit systems, the single-token waiters wait on the low half + and the multi-token waiters wait on the upper half. So we ask + the kernel to wake up n single-token waiters and all multi-token + waiters (if any), then clear the multi-token wait bit. + + That means we must clear the contention bit ourselves. See + below for handling the race. + + atomic { + int oldval = *upper; + *upper = oldval & ~(1 << 31); + futexWake(lower, n); + if (oldval < 0) // sign bit set + futexWake(upper, INT_MAX); + } + */ + quint32 op = FUTEX_OP_ANDN | FUTEX_OP_OPARG_SHIFT; + quint32 oparg = 31; + quint32 cmp = FUTEX_OP_CMP_LT; + quint32 cmparg = 0; + futexLow32(&u)->fetchAndAndRelease(futexContendedBit - 1); + futexWakeOp(*futexLow32(&u), n, INT_MAX, *futexHigh32(&u), FUTEX_OP(op, oparg, cmp, cmparg)); + } +#else + // Unset the bit and wake everyone. There are two possibibilies + // under which a thread can set the bit between the AND and the + // futexWake: + // 1) it did see the new counter value, but it wasn't enough for + // its acquisition anyway, so it has to wait; + // 2) it did not see the new counter value, in which case its + // futexWait will fail. + u.fetchAndAndRelease(futexContendedBit - 1); + futexWakeAll(u); +#endif + } + return; + } + QMutexLocker locker(&d->mutex); d->avail += n; d->cond.wakeAll(); @@ -173,6 +363,9 @@ void QSemaphore::release(int n) */ int QSemaphore::available() const { + if (futexAvailable()) + return futexAvailCounter(u.load()); + QMutexLocker locker(&d->mutex); return d->avail; } @@ -191,6 +384,10 @@ int QSemaphore::available() const bool QSemaphore::tryAcquire(int n) { Q_ASSERT_X(n >= 0, "QSemaphore::tryAcquire", "parameter 'n' must be non-negative"); + + if (futexAvailable()) + return futexSemaphoreTryAcquire<false>(u, n, 0); + QMutexLocker locker(&d->mutex); if (n > d->avail) return false; @@ -217,8 +414,8 @@ bool QSemaphore::tryAcquire(int n) bool QSemaphore::tryAcquire(int n, int timeout) { Q_ASSERT_X(n >= 0, "QSemaphore::tryAcquire", "parameter 'n' must be non-negative"); - if (timeout < 0) - return tryAcquire(n); + if (futexAvailable()) + return futexSemaphoreTryAcquire<true>(u, n, timeout < 0 ? -1 : timeout); QDeadlineTimer timer(timeout); QMutexLocker locker(&d->mutex); diff --git a/src/corelib/thread/qsemaphore.h b/src/corelib/thread/qsemaphore.h index a92740c8ce..c41f258577 100644 --- a/src/corelib/thread/qsemaphore.h +++ b/src/corelib/thread/qsemaphore.h @@ -66,7 +66,10 @@ public: private: Q_DISABLE_COPY(QSemaphore) - QSemaphorePrivate *d; + union { + QSemaphorePrivate *d; + QBasicAtomicInteger<quintptr> u; // ### Qt6: make 64-bit + }; }; class QSemaphoreReleaser diff --git a/src/corelib/thread/qthread.h b/src/corelib/thread/qthread.h index 03b5424bb6..1f98cb59af 100644 --- a/src/corelib/thread/qthread.h +++ b/src/corelib/thread/qthread.h @@ -76,7 +76,7 @@ public: static int idealThreadCount() Q_DECL_NOTHROW; static void yieldCurrentThread(); - explicit QThread(QObject *parent = Q_NULLPTR); + explicit QThread(QObject *parent = nullptr); ~QThread(); enum Priority { @@ -110,7 +110,7 @@ public: QAbstractEventDispatcher *eventDispatcher() const; void setEventDispatcher(QAbstractEventDispatcher *eventDispatcher); - bool event(QEvent *event) Q_DECL_OVERRIDE; + bool event(QEvent *event) override; int loopLevel() const; #ifdef Q_QDOC @@ -154,7 +154,7 @@ protected: static void setTerminationEnabled(bool enabled = true); protected: - QThread(QThreadPrivate &dd, QObject *parent = Q_NULLPTR); + QThread(QThreadPrivate &dd, QObject *parent = nullptr); private: Q_DECLARE_PRIVATE(QThread) diff --git a/src/corelib/thread/qthread_p.h b/src/corelib/thread/qthread_p.h index f3d4750177..1d38eb0ebf 100644 --- a/src/corelib/thread/qthread_p.h +++ b/src/corelib/thread/qthread_p.h @@ -317,7 +317,7 @@ public: void init(); private: - void run() Q_DECL_OVERRIDE; + void run() override; }; QT_END_NAMESPACE diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp index 6540f02f34..f839e4449b 100644 --- a/src/corelib/thread/qthread_unix.cpp +++ b/src/corelib/thread/qthread_unix.cpp @@ -487,9 +487,6 @@ int QThread::idealThreadCount() Q_DECL_NOTHROW if (sysctl(mib, 2, &cores, &len, NULL, 0) != 0) { perror("sysctl"); } -#elif defined(Q_OS_IRIX) - // IRIX - cores = (int)sysconf(_SC_NPROC_ONLN); #elif defined(Q_OS_INTEGRITY) #if (__INTEGRITY_MAJOR_VERSION >= 10) // Integrity V10+ does support multicore CPUs diff --git a/src/corelib/thread/qthreadpool.cpp b/src/corelib/thread/qthreadpool.cpp index 8eca3b56e4..157cbeaf4d 100644 --- a/src/corelib/thread/qthreadpool.cpp +++ b/src/corelib/thread/qthreadpool.cpp @@ -56,7 +56,7 @@ class QThreadPoolThread : public QThread { public: QThreadPoolThread(QThreadPoolPrivate *manager); - void run() Q_DECL_OVERRIDE; + void run() override; void registerThreadInactive(); QWaitCondition runnableReady; diff --git a/src/corelib/thread/qthreadpool.h b/src/corelib/thread/qthreadpool.h index a65eacc996..606e192768 100644 --- a/src/corelib/thread/qthreadpool.h +++ b/src/corelib/thread/qthreadpool.h @@ -62,7 +62,7 @@ class Q_CORE_EXPORT QThreadPool : public QObject friend class QFutureInterfaceBase; public: - QThreadPool(QObject *parent = Q_NULLPTR); + QThreadPool(QObject *parent = nullptr); ~QThreadPool(); static QThreadPool *globalInstance(); diff --git a/src/corelib/thread/thread.pri b/src/corelib/thread/thread.pri index 0a989cfcaf..a4cb2478c6 100644 --- a/src/corelib/thread/thread.pri +++ b/src/corelib/thread/thread.pri @@ -22,6 +22,7 @@ HEADERS += thread/qmutex.h \ # private headers HEADERS += thread/qmutex_p.h \ thread/qmutexpool_p.h \ + thread/qfutex_p.h \ thread/qfutureinterface_p.h \ thread/qfuturewatcher_p.h \ thread/qorderedmutexlocker_p.h \ diff --git a/src/corelib/tools/qarraydata.h b/src/corelib/tools/qarraydata.h index 88f0cfb0ea..f0cc56e899 100644 --- a/src/corelib/tools/qarraydata.h +++ b/src/corelib/tools/qarraydata.h @@ -139,7 +139,7 @@ struct QTypedArrayData typedef T *pointer; typedef T &reference; - inline iterator() : i(Q_NULLPTR) {} + inline iterator() : i(nullptr) {} inline iterator(T *n) : i(n) {} inline iterator(const iterator &o): i(o.i){} // #### Qt 6: remove, the implicit version is fine inline T &operator*() const { return *i; } @@ -173,7 +173,7 @@ struct QTypedArrayData typedef const T *pointer; typedef const T &reference; - inline const_iterator() : i(Q_NULLPTR) {} + inline const_iterator() : i(nullptr) {} inline const_iterator(const T *n) : i(n) {} inline const_iterator(const const_iterator &o): i(o.i) {} // #### Qt 6: remove, the default version is fine inline explicit const_iterator(const iterator &o): i(o.i) {} diff --git a/src/corelib/tools/qbytearray.h b/src/corelib/tools/qbytearray.h index 732d3afc17..300f795469 100644 --- a/src/corelib/tools/qbytearray.h +++ b/src/corelib/tools/qbytearray.h @@ -340,16 +340,16 @@ public: inline QT_ASCII_CAST_WARN bool operator>=(const QString &s2) const; #endif - short toShort(bool *ok = Q_NULLPTR, int base = 10) const; - ushort toUShort(bool *ok = Q_NULLPTR, int base = 10) const; - int toInt(bool *ok = Q_NULLPTR, int base = 10) const; - uint toUInt(bool *ok = Q_NULLPTR, int base = 10) const; - long toLong(bool *ok = Q_NULLPTR, int base = 10) const; - ulong toULong(bool *ok = Q_NULLPTR, int base = 10) const; - qlonglong toLongLong(bool *ok = Q_NULLPTR, int base = 10) const; - qulonglong toULongLong(bool *ok = Q_NULLPTR, int base = 10) const; - float toFloat(bool *ok = Q_NULLPTR) const; - double toDouble(bool *ok = Q_NULLPTR) const; + short toShort(bool *ok = nullptr, int base = 10) const; + ushort toUShort(bool *ok = nullptr, int base = 10) const; + int toInt(bool *ok = nullptr, int base = 10) const; + uint toUInt(bool *ok = nullptr, int base = 10) const; + long toLong(bool *ok = nullptr, int base = 10) const; + ulong toULong(bool *ok = nullptr, int base = 10) const; + qlonglong toLongLong(bool *ok = nullptr, int base = 10) const; + qulonglong toULongLong(bool *ok = nullptr, int base = 10) const; + float toFloat(bool *ok = nullptr) const; + double toDouble(bool *ok = nullptr) const; QByteArray toBase64(Base64Options options) const; QByteArray toBase64() const; // ### Qt6 merge with previous QByteArray toHex() const; diff --git a/src/corelib/tools/qbytearraylist.h b/src/corelib/tools/qbytearraylist.h index 501bb2e0d5..ed014dd157 100644 --- a/src/corelib/tools/qbytearraylist.h +++ b/src/corelib/tools/qbytearraylist.h @@ -70,7 +70,7 @@ protected: #endif public: inline QByteArray join() const - { return QtPrivate::QByteArrayList_join(self(), Q_NULLPTR, 0); } + { return QtPrivate::QByteArrayList_join(self(), nullptr, 0); } inline QByteArray join(const QByteArray &sep) const { return QtPrivate::QByteArrayList_join(self(), sep.constData(), sep.size()); } inline QByteArray join(char sep) const diff --git a/src/corelib/tools/qcollator.h b/src/corelib/tools/qcollator.h index d81c7c85e3..6fa199cb0f 100644 --- a/src/corelib/tools/qcollator.h +++ b/src/corelib/tools/qcollator.h @@ -89,7 +89,7 @@ public: QCollator &operator=(const QCollator &); #ifdef Q_COMPILER_RVALUE_REFS QCollator(QCollator &&other) Q_DECL_NOTHROW - : d(other.d) { other.d = Q_NULLPTR; } + : d(other.d) { other.d = nullptr; } QCollator &operator=(QCollator &&other) Q_DECL_NOTHROW { swap(other); return *this; } #endif diff --git a/src/corelib/tools/qcollator_win.cpp b/src/corelib/tools/qcollator_win.cpp index bce896278e..5a838c1b50 100644 --- a/src/corelib/tools/qcollator_win.cpp +++ b/src/corelib/tools/qcollator_win.cpp @@ -70,12 +70,8 @@ void QCollatorPrivate::init() if (caseSensitivity == Qt::CaseInsensitive) collator |= NORM_IGNORECASE; - if (numericMode) { - if (QSysInfo::windowsVersion() >= QSysInfo::WV_WINDOWS7) - collator |= SORT_DIGITSASNUMBERS; - else - qWarning("Numeric sorting unsupported on Windows versions older than Windows 7."); - } + if (numericMode) + collator |= SORT_DIGITSASNUMBERS; if (ignorePunctuation) collator |= NORM_IGNORESYMBOLS; diff --git a/src/corelib/tools/qdatetime.h b/src/corelib/tools/qdatetime.h index adab47fc1f..a390bce95f 100644 --- a/src/corelib/tools/qdatetime.h +++ b/src/corelib/tools/qdatetime.h @@ -79,7 +79,7 @@ public: int dayOfYear() const; int daysInMonth() const; int daysInYear() const; - int weekNumber(int *yearNum = Q_NULLPTR) const; + int weekNumber(int *yearNum = nullptr) const; #if QT_DEPRECATED_SINCE(5, 11) && !defined QT_NO_TEXTDATE QT_DEPRECATED_X("Use QLocale::monthName or QLocale::standaloneMonthName") diff --git a/src/corelib/tools/qeasingcurve.cpp b/src/corelib/tools/qeasingcurve.cpp index 03bb1a1411..0b8fa4ca74 100644 --- a/src/corelib/tools/qeasingcurve.cpp +++ b/src/corelib/tools/qeasingcurve.cpp @@ -496,7 +496,7 @@ struct BezierEase : public QEasingCurveFunction } } - QEasingCurveFunction *copy() const Q_DECL_OVERRIDE + QEasingCurveFunction *copy() const override { BezierEase *rv = new BezierEase(); rv->_t = _t; @@ -532,7 +532,7 @@ struct BezierEase : public QEasingCurveFunction return newT; } - qreal value(qreal x) Q_DECL_OVERRIDE + qreal value(qreal x) override { Q_ASSERT(_bezierCurves.count() % 3 == 0); @@ -826,7 +826,7 @@ struct TCBEase : public BezierEase : BezierEase(QEasingCurve::TCBSpline) { } - qreal value(qreal x) Q_DECL_OVERRIDE + qreal value(qreal x) override { Q_ASSERT(_bezierCurves.count() % 3 == 0); @@ -846,7 +846,7 @@ struct ElasticEase : public QEasingCurveFunction : QEasingCurveFunction(type, qreal(0.3), qreal(1.0)) { } - QEasingCurveFunction *copy() const Q_DECL_OVERRIDE + QEasingCurveFunction *copy() const override { ElasticEase *rv = new ElasticEase(_t); rv->_p = _p; @@ -856,7 +856,7 @@ struct ElasticEase : public QEasingCurveFunction return rv; } - qreal value(qreal t) Q_DECL_OVERRIDE + qreal value(qreal t) override { qreal p = (_p < 0) ? qreal(0.3) : _p; qreal a = (_a < 0) ? qreal(1.0) : _a; @@ -881,7 +881,7 @@ struct BounceEase : public QEasingCurveFunction : QEasingCurveFunction(type, qreal(0.3), qreal(1.0)) { } - QEasingCurveFunction *copy() const Q_DECL_OVERRIDE + QEasingCurveFunction *copy() const override { BounceEase *rv = new BounceEase(_t); rv->_a = _a; @@ -890,7 +890,7 @@ struct BounceEase : public QEasingCurveFunction return rv; } - qreal value(qreal t) Q_DECL_OVERRIDE + qreal value(qreal t) override { qreal a = (_a < 0) ? qreal(1.0) : _a; switch(_t) { @@ -914,7 +914,7 @@ struct BackEase : public QEasingCurveFunction : QEasingCurveFunction(type, qreal(0.3), qreal(1.0), qreal(1.70158)) { } - QEasingCurveFunction *copy() const Q_DECL_OVERRIDE + QEasingCurveFunction *copy() const override { BackEase *rv = new BackEase(_t); rv->_o = _o; @@ -923,7 +923,7 @@ struct BackEase : public QEasingCurveFunction return rv; } - qreal value(qreal t) Q_DECL_OVERRIDE + qreal value(qreal t) override { qreal o = (_o < 0) ? qreal(1.70158) : _o; switch(_t) { @@ -1488,7 +1488,7 @@ QDataStream &operator>>(QDataStream &stream, QEasingCurve &easing) bool hasConfig; stream >> hasConfig; delete easing.d_ptr->config; - easing.d_ptr->config = Q_NULLPTR; + easing.d_ptr->config = nullptr; if (hasConfig) { QEasingCurveFunction *config = curveToFunctionObject(type); stream >> config->_p; diff --git a/src/corelib/tools/qeasingcurve.h b/src/corelib/tools/qeasingcurve.h index ba06de8f9e..74bde5825a 100644 --- a/src/corelib/tools/qeasingcurve.h +++ b/src/corelib/tools/qeasingcurve.h @@ -81,7 +81,7 @@ public: QEasingCurve &operator=(const QEasingCurve &other) { if ( this != &other ) { QEasingCurve copy(other); swap(copy); } return *this; } #ifdef Q_COMPILER_RVALUE_REFS - QEasingCurve(QEasingCurve &&other) Q_DECL_NOTHROW : d_ptr(other.d_ptr) { other.d_ptr = Q_NULLPTR; } + QEasingCurve(QEasingCurve &&other) Q_DECL_NOTHROW : d_ptr(other.d_ptr) { other.d_ptr = nullptr; } QEasingCurve &operator=(QEasingCurve &&other) Q_DECL_NOTHROW { qSwap(d_ptr, other.d_ptr); return *this; } #endif diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h index 715acc77ce..e7ce4b658f 100644 --- a/src/corelib/tools/qhash.h +++ b/src/corelib/tools/qhash.h @@ -315,7 +315,7 @@ public: typedef T *pointer; typedef T &reference; - inline iterator() : i(Q_NULLPTR) { } + inline iterator() : i(nullptr) { } explicit inline iterator(void *node) : i(reinterpret_cast<QHashData::Node *>(node)) { } inline const Key &key() const { return concrete(i)->key; } @@ -373,7 +373,7 @@ public: typedef const T *pointer; typedef const T &reference; - Q_DECL_CONSTEXPR inline const_iterator() : i(Q_NULLPTR) { } + Q_DECL_CONSTEXPR inline const_iterator() : i(nullptr) { } explicit inline const_iterator(void *node) : i(reinterpret_cast<QHashData::Node *>(node)) { } #ifdef QT_STRICT_ITERATORS @@ -502,7 +502,7 @@ public: private: void detach_helper(); void freeData(QHashData *d); - Node **findNode(const Key &key, uint *hp = Q_NULLPTR) const; + Node **findNode(const Key &key, uint *hp = nullptr) const; Node **findNode(const Key &key, uint h) const; Node *createNode(uint h, const Key &key, const T &value, Node **nextNode); void deleteNode(Node *node); @@ -550,7 +550,7 @@ template <class Key, class T> Q_INLINE_TEMPLATE void QHash<Key, T>::duplicateNode(QHashData::Node *node, void *newNode) { Node *concreteNode = concrete(node); - new (newNode) Node(concreteNode->key, concreteNode->value, concreteNode->h, Q_NULLPTR); + new (newNode) Node(concreteNode->key, concreteNode->value, concreteNode->h, nullptr); } template <class Key, class T> diff --git a/src/corelib/tools/qlinkedlist.h b/src/corelib/tools/qlinkedlist.h index 9f54ba7825..c8f3f4c8c3 100644 --- a/src/corelib/tools/qlinkedlist.h +++ b/src/corelib/tools/qlinkedlist.h @@ -134,7 +134,7 @@ public: typedef T *pointer; typedef T &reference; Node *i; - inline iterator() : i(Q_NULLPTR) {} + inline iterator() : i(nullptr) {} inline iterator(Node *n) : i(n) {} #if QT_VERSION < QT_VERSION_CHECK(6,0,0) iterator(const iterator &other) Q_DECL_NOTHROW : i(other.i) {} @@ -171,7 +171,7 @@ public: typedef const T *pointer; typedef const T &reference; Node *i; - inline const_iterator() : i(Q_NULLPTR) {} + inline const_iterator() : i(nullptr) {} inline const_iterator(Node *n) : i(n) {} inline const_iterator(iterator ci) : i(ci.i){} #if QT_VERSION < QT_VERSION_CHECK(6,0,0) diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h index 1042c29460..af7659e995 100644 --- a/src/corelib/tools/qlist.h +++ b/src/corelib/tools/qlist.h @@ -231,7 +231,7 @@ public: typedef T *pointer; typedef T &reference; - inline iterator() Q_DECL_NOTHROW : i(Q_NULLPTR) {} + inline iterator() Q_DECL_NOTHROW : i(nullptr) {} inline iterator(Node *n) Q_DECL_NOTHROW : i(n) {} #if QT_VERSION < QT_VERSION_CHECK(6,0,0) // can't remove it in Qt 5, since doing so would make the type trivial, @@ -283,7 +283,7 @@ public: typedef const T *pointer; typedef const T &reference; - inline const_iterator() Q_DECL_NOTHROW : i(Q_NULLPTR) {} + inline const_iterator() Q_DECL_NOTHROW : i(nullptr) {} inline const_iterator(Node *n) Q_DECL_NOTHROW : i(n) {} #if QT_VERSION < QT_VERSION_CHECK(6,0,0) // can't remove it in Qt 5, since doing so would make the type trivial, diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index 723e63114d..c85dcb4358 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -3151,11 +3151,15 @@ QString QLocaleData::longLongToString(const QChar zero, const QChar group, negative = false; // neither are negative numbers } - QString num_str; - if (base == 10) - num_str = qlltoa(l, base, zero); - else - num_str = qulltoa(l, base, zero); +QT_WARNING_PUSH + /* "unary minus operator applied to unsigned type, result still unsigned" */ +QT_WARNING_DISABLE_MSVC(4146) + /* + Negating std::numeric_limits<qlonglong>::min() hits undefined behavior, so + taking an absolute value has to cast to unsigned to change sign. + */ + QString num_str = qulltoa(negative ? -qulonglong(l) : qulonglong(l), base, zero); +QT_WARNING_POP uint cnt_thousand_sep = 0; if (flags & ThousandsGroup && base == 10) { diff --git a/src/corelib/tools/qlocale.h b/src/corelib/tools/qlocale.h index 54b1a32946..ef7a26ea79 100644 --- a/src/corelib/tools/qlocale.h +++ b/src/corelib/tools/qlocale.h @@ -949,23 +949,23 @@ public: QString nativeCountryName() const; #if QT_STRINGVIEW_LEVEL < 2 - short toShort(const QString &s, bool *ok = Q_NULLPTR) const; - ushort toUShort(const QString &s, bool *ok = Q_NULLPTR) const; - int toInt(const QString &s, bool *ok = Q_NULLPTR) const; - uint toUInt(const QString &s, bool *ok = Q_NULLPTR) const; - qlonglong toLongLong(const QString &s, bool *ok = Q_NULLPTR) const; - qulonglong toULongLong(const QString &s, bool *ok = Q_NULLPTR) const; - float toFloat(const QString &s, bool *ok = Q_NULLPTR) const; - double toDouble(const QString &s, bool *ok = Q_NULLPTR) const; + short toShort(const QString &s, bool *ok = nullptr) const; + ushort toUShort(const QString &s, bool *ok = nullptr) const; + int toInt(const QString &s, bool *ok = nullptr) const; + uint toUInt(const QString &s, bool *ok = nullptr) const; + qlonglong toLongLong(const QString &s, bool *ok = nullptr) const; + qulonglong toULongLong(const QString &s, bool *ok = nullptr) const; + float toFloat(const QString &s, bool *ok = nullptr) const; + double toDouble(const QString &s, bool *ok = nullptr) const; - short toShort(const QStringRef &s, bool *ok = Q_NULLPTR) const; - ushort toUShort(const QStringRef &s, bool *ok = Q_NULLPTR) const; - int toInt(const QStringRef &s, bool *ok = Q_NULLPTR) const; - uint toUInt(const QStringRef &s, bool *ok = Q_NULLPTR) const; - qlonglong toLongLong(const QStringRef &s, bool *ok = Q_NULLPTR) const; - qulonglong toULongLong(const QStringRef &s, bool *ok = Q_NULLPTR) const; - float toFloat(const QStringRef &s, bool *ok = Q_NULLPTR) const; - double toDouble(const QStringRef &s, bool *ok = Q_NULLPTR) const; + short toShort(const QStringRef &s, bool *ok = nullptr) const; + ushort toUShort(const QStringRef &s, bool *ok = nullptr) const; + int toInt(const QStringRef &s, bool *ok = nullptr) const; + uint toUInt(const QStringRef &s, bool *ok = nullptr) const; + qlonglong toLongLong(const QStringRef &s, bool *ok = nullptr) const; + qulonglong toULongLong(const QStringRef &s, bool *ok = nullptr) const; + float toFloat(const QStringRef &s, bool *ok = nullptr) const; + double toDouble(const QStringRef &s, bool *ok = nullptr) const; #endif short toShort(QStringView s, bool *ok = nullptr) const; diff --git a/src/corelib/tools/qlocale_tools.cpp b/src/corelib/tools/qlocale_tools.cpp index 3e4f37501e..4d969a4723 100644 --- a/src/corelib/tools/qlocale_tools.cpp +++ b/src/corelib/tools/qlocale_tools.cpp @@ -456,11 +456,6 @@ QString qulltoa(qulonglong l, int base, const QChar _zero) return QString(reinterpret_cast<QChar *>(p), 65 - (p - buff)); } -QString qlltoa(qlonglong l, int base, const QChar zero) -{ - return qulltoa(l < 0 ? -l : l, base, zero); -} - QString &decimalForm(QChar zero, QChar decimal, QChar group, QString &digits, int decpt, int precision, PrecisionMode pm, diff --git a/src/corelib/tools/qlocale_tools_p.h b/src/corelib/tools/qlocale_tools_p.h index 6133f67add..742abb4957 100644 --- a/src/corelib/tools/qlocale_tools_p.h +++ b/src/corelib/tools/qlocale_tools_p.h @@ -83,7 +83,6 @@ void doubleToAscii(double d, QLocaleData::DoubleForm form, int precision, char * bool &sign, int &length, int &decpt); QString qulltoa(qulonglong l, int base, const QChar _zero); -QString qlltoa(qlonglong l, int base, const QChar zero); Q_CORE_EXPORT QString qdtoa(qreal d, int *decpt, int *sign); enum PrecisionMode { diff --git a/src/corelib/tools/qlocale_win.cpp b/src/corelib/tools/qlocale_win.cpp index 1d80320d8e..30aefb71c1 100644 --- a/src/corelib/tools/qlocale_win.cpp +++ b/src/corelib/tools/qlocale_win.cpp @@ -326,9 +326,7 @@ QVariant QSystemLocalePrivate::timeFormat(QLocale::FormatType type) { switch (type) { case QLocale::ShortFormat: - if (QSysInfo::windowsVersion() >= QSysInfo::WV_WINDOWS7) - return winToQtFormat(getLocaleInfo(LOCALE_SSHORTTIME)); - // fall through + return winToQtFormat(getLocaleInfo(LOCALE_SSHORTTIME)); case QLocale::LongFormat: return winToQtFormat(getLocaleInfo(LOCALE_STIMEFORMAT)); case QLocale::NarrowFormat: @@ -367,7 +365,7 @@ QVariant QSystemLocalePrivate::dayName(int day, QLocale::FormatType type) if (type == QLocale::LongFormat) return getLocaleInfo(long_day_map[day]); - else if (type == QLocale::NarrowFormat && QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA) + else if (type == QLocale::NarrowFormat) return getLocaleInfo(narrow_day_map[day]); return getLocaleInfo(short_day_map[day]); } @@ -425,7 +423,7 @@ QVariant QSystemLocalePrivate::toString(const QTime &time, QLocale::FormatType t DWORD flags = 0; // keep the same conditional as timeFormat() above - if (type == QLocale::ShortFormat && QSysInfo::windowsVersion() >= QSysInfo::WV_WINDOWS7) + if (type == QLocale::ShortFormat) flags = TIME_NOSECONDS; wchar_t buf[255]; @@ -656,15 +654,11 @@ QVariant QSystemLocalePrivate::uiLanguages() QVariant QSystemLocalePrivate::nativeLanguageName() { - if (QSysInfo::windowsVersion() < QSysInfo::WV_WINDOWS7) - return getLocaleInfo(LOCALE_SNATIVELANGNAME); return getLocaleInfo(LOCALE_SNATIVELANGUAGENAME); } QVariant QSystemLocalePrivate::nativeCountryName() { - if (QSysInfo::windowsVersion() < QSysInfo::WV_WINDOWS7) - return getLocaleInfo(LOCALE_SNATIVECTRYNAME); return getLocaleInfo(LOCALE_SNATIVECOUNTRYNAME); } diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h index 16442014ff..fc72c6e32c 100644 --- a/src/corelib/tools/qmap.h +++ b/src/corelib/tools/qmap.h @@ -150,7 +150,7 @@ template <class Key, class T> inline QMapNode<Key, T> *QMapNode<Key, T>::lowerBound(const Key &akey) { QMapNode<Key, T> *n = this; - QMapNode<Key, T> *lastNode = Q_NULLPTR; + QMapNode<Key, T> *lastNode = nullptr; while (n) { if (!qMapLessThanKey(n->key, akey)) { lastNode = n; @@ -166,7 +166,7 @@ template <class Key, class T> inline QMapNode<Key, T> *QMapNode<Key, T>::upperBound(const Key &akey) { QMapNode<Key, T> *n = this; - QMapNode<Key, T> *lastNode = Q_NULLPTR; + QMapNode<Key, T> *lastNode = nullptr; while (n) { if (qMapLessThanKey(akey, n->key)) { lastNode = n; @@ -220,7 +220,7 @@ struct QMapData : public QMapDataBase Node *findNode(const Key &akey) const; void nodeRange(const Key &akey, Node **firstNode, Node **lastNode); - Node *createNode(const Key &k, const T &v, Node *parent = Q_NULLPTR, bool left = false) + Node *createNode(const Key &k, const T &v, Node *parent = nullptr, bool left = false) { Node *n = static_cast<Node *>(QMapDataBase::createNode(sizeof(Node), Q_ALIGNOF(Node), parent, left)); @@ -261,13 +261,13 @@ QMapNode<Key, T> *QMapNode<Key, T>::copy(QMapData<Key, T> *d) const n->left = leftNode()->copy(d); n->left->setParent(n); } else { - n->left = Q_NULLPTR; + n->left = nullptr; } if (right) { n->right = rightNode()->copy(d); n->right->setParent(n); } else { - n->right = Q_NULLPTR; + n->right = nullptr; } return n; } @@ -288,7 +288,7 @@ QMapNode<Key, T> *QMapData<Key, T>::findNode(const Key &akey) const if (lb && !qMapLessThanKey(akey, lb->key)) return lb; } - return Q_NULLPTR; + return nullptr; } @@ -304,10 +304,10 @@ void QMapData<Key, T>::nodeRange(const Key &akey, QMapNode<Key, T> **firstNode, } else if (qMapLessThanKey(n->key, akey)) { n = n->rightNode(); } else { - *firstNode = n->leftNode() ? n->leftNode()->lowerBound(akey) : Q_NULLPTR; + *firstNode = n->leftNode() ? n->leftNode()->lowerBound(akey) : nullptr; if (!*firstNode) *firstNode = n; - *lastNode = n->rightNode() ? n->rightNode()->upperBound(akey) : Q_NULLPTR; + *lastNode = n->rightNode() ? n->rightNode()->upperBound(akey) : nullptr; if (!*lastNode) *lastNode = l; return; @@ -416,7 +416,7 @@ public: typedef T *pointer; typedef T &reference; - inline iterator() : i(Q_NULLPTR) { } + inline iterator() : i(nullptr) { } inline iterator(Node *node) : i(node) { } inline const Key &key() const { return i->key; } @@ -473,7 +473,7 @@ public: typedef const T *pointer; typedef const T &reference; - Q_DECL_CONSTEXPR inline const_iterator() : i(Q_NULLPTR) { } + Q_DECL_CONSTEXPR inline const_iterator() : i(nullptr) { } inline const_iterator(const Node *node) : i(node) { } #ifdef QT_STRICT_ITERATORS explicit inline const_iterator(const iterator &o) @@ -695,7 +695,7 @@ Q_INLINE_TEMPLATE int QMap<Key, T>::count(const Key &akey) const template <class Key, class T> Q_INLINE_TEMPLATE bool QMap<Key, T>::contains(const Key &akey) const { - return d->findNode(akey) != Q_NULLPTR; + return d->findNode(akey) != nullptr; } template <class Key, class T> @@ -704,7 +704,7 @@ Q_INLINE_TEMPLATE typename QMap<Key, T>::iterator QMap<Key, T>::insert(const Key detach(); Node *n = d->root(); Node *y = d->end(); - Node *lastNode = Q_NULLPTR; + Node *lastNode = nullptr; bool left = true; while (n) { y = n; @@ -779,15 +779,15 @@ typename QMap<Key, T>::iterator QMap<Key, T>::insert(const_iterator pos, const K } // we need to insert (not overwrite) - if (prev->right == Q_NULLPTR) { + if (prev->right == nullptr) { Node *z = d->createNode(akey, avalue, prev, false); return iterator(z); } - if (next->left == Q_NULLPTR) { + if (next->left == nullptr) { Node *z = d->createNode(akey, avalue, next, true); return iterator(z); } - Q_ASSERT(false); // We should have prev->right == Q_NULLPTR or next->left == Q_NULLPTR. + Q_ASSERT(false); // We should have prev->right == nullptr or next->left == nullptr. return this->insert(akey, avalue); } } @@ -801,7 +801,7 @@ Q_INLINE_TEMPLATE typename QMap<Key, T>::iterator QMap<Key, T>::insertMulti(cons Node* y = d->end(); Node* x = static_cast<Node *>(d->root()); bool left = true; - while (x != Q_NULLPTR) { + while (x != nullptr) { left = !qMapLessThanKey(x->key, akey); y = x; x = left ? x->leftNode() : x->rightNode(); @@ -848,15 +848,15 @@ typename QMap<Key, T>::iterator QMap<Key, T>::insertMulti(const_iterator pos, co return this->insertMulti(akey, avalue); // ignore hint // Hint is ok - do insert - if (prev->right == Q_NULLPTR) { + if (prev->right == nullptr) { Node *z = d->createNode(akey, avalue, prev, false); return iterator(z); } - if (next->left == Q_NULLPTR) { + if (next->left == nullptr) { Node *z = d->createNode(akey, avalue, next, true); return iterator(z); } - Q_ASSERT(false); // We should have prev->right == Q_NULLPTR or next->left == Q_NULLPTR. + Q_ASSERT(false); // We should have prev->right == nullptr or next->left == nullptr. return this->insertMulti(akey, avalue); } } @@ -1102,7 +1102,7 @@ Q_OUTOFLINE_TEMPLATE QList<T> QMap<Key, T>::values(const Key &akey) const template <class Key, class T> Q_INLINE_TEMPLATE typename QMap<Key, T>::const_iterator QMap<Key, T>::lowerBound(const Key &akey) const { - Node *lb = d->root() ? d->root()->lowerBound(akey) : Q_NULLPTR; + Node *lb = d->root() ? d->root()->lowerBound(akey) : nullptr; if (!lb) lb = d->end(); return const_iterator(lb); @@ -1112,7 +1112,7 @@ template <class Key, class T> Q_INLINE_TEMPLATE typename QMap<Key, T>::iterator QMap<Key, T>::lowerBound(const Key &akey) { detach(); - Node *lb = d->root() ? d->root()->lowerBound(akey) : Q_NULLPTR; + Node *lb = d->root() ? d->root()->lowerBound(akey) : nullptr; if (!lb) lb = d->end(); return iterator(lb); @@ -1122,7 +1122,7 @@ template <class Key, class T> Q_INLINE_TEMPLATE typename QMap<Key, T>::const_iterator QMap<Key, T>::upperBound(const Key &akey) const { - Node *ub = d->root() ? d->root()->upperBound(akey) : Q_NULLPTR; + Node *ub = d->root() ? d->root()->upperBound(akey) : nullptr; if (!ub) ub = d->end(); return const_iterator(ub); @@ -1132,7 +1132,7 @@ template <class Key, class T> Q_INLINE_TEMPLATE typename QMap<Key, T>::iterator QMap<Key, T>::upperBound(const Key &akey) { detach(); - Node *ub = d->root() ? d->root()->upperBound(akey) : Q_NULLPTR; + Node *ub = d->root() ? d->root()->upperBound(akey) : nullptr; if (!ub) ub = d->end(); return iterator(ub); diff --git a/src/corelib/tools/qringbuffer_p.h b/src/corelib/tools/qringbuffer_p.h index 558a456515..1f3f2d3fb0 100644 --- a/src/corelib/tools/qringbuffer_p.h +++ b/src/corelib/tools/qringbuffer_p.h @@ -80,7 +80,7 @@ public: } inline const char *readPointer() const { - return bufferSize == 0 ? Q_NULLPTR : (buffers.first().constData() + head); + return bufferSize == 0 ? nullptr : (buffers.first().constData() + head); } Q_CORE_EXPORT const char *readPointerAtPosition(qint64 pos, qint64 &length) const; diff --git a/src/corelib/tools/qscopedpointer.cpp b/src/corelib/tools/qscopedpointer.cpp index 8d84b3beca..f3a4f0ca1f 100644 --- a/src/corelib/tools/qscopedpointer.cpp +++ b/src/corelib/tools/qscopedpointer.cpp @@ -146,6 +146,13 @@ QT_BEGIN_NAMESPACE */ /*! + \fn T *QScopedPointer::get() const + \since 5.11 + + Same as data(). +*/ + +/*! \fn T &QScopedPointer::operator*() const Provides access to the scoped pointer's object. diff --git a/src/corelib/tools/qscopedpointer.h b/src/corelib/tools/qscopedpointer.h index 141a3f8c70..2a4083466b 100644 --- a/src/corelib/tools/qscopedpointer.h +++ b/src/corelib/tools/qscopedpointer.h @@ -97,7 +97,7 @@ class QScopedPointer { typedef T *QScopedPointer:: *RestrictedBool; public: - explicit QScopedPointer(T *p = Q_NULLPTR) Q_DECL_NOTHROW : d(p) + explicit QScopedPointer(T *p = nullptr) Q_DECL_NOTHROW : d(p) { } @@ -126,12 +126,12 @@ public: #if defined(Q_QDOC) inline operator bool() const { - return isNull() ? Q_NULLPTR : &QScopedPointer::d; + return isNull() ? nullptr : &QScopedPointer::d; } #else operator RestrictedBool() const Q_DECL_NOTHROW { - return isNull() ? Q_NULLPTR : &QScopedPointer::d; + return isNull() ? nullptr : &QScopedPointer::d; } #endif @@ -140,12 +140,17 @@ public: return d; } + T *get() const Q_DECL_NOTHROW + { + return d; + } + bool isNull() const Q_DECL_NOTHROW { return !d; } - void reset(T *other = Q_NULLPTR) Q_DECL_NOEXCEPT_EXPR(noexcept(Cleanup::cleanup(std::declval<T *>()))) + void reset(T *other = nullptr) Q_DECL_NOEXCEPT_EXPR(noexcept(Cleanup::cleanup(std::declval<T *>()))) { if (d == other) return; @@ -157,7 +162,7 @@ public: T *take() Q_DECL_NOTHROW { T *oldD = d; - d = Q_NULLPTR; + d = nullptr; return oldD; } @@ -221,7 +226,7 @@ class QScopedArrayPointer : public QScopedPointer<T, Cleanup> template <typename Ptr> using if_same_type = typename std::enable_if<std::is_same<typename std::remove_cv<T>::type, Ptr>::value, bool>::type; public: - inline QScopedArrayPointer() : QScopedPointer<T, Cleanup>(Q_NULLPTR) {} + inline QScopedArrayPointer() : QScopedPointer<T, Cleanup>(nullptr) {} template <typename D, if_same_type<D> = true> explicit QScopedArrayPointer(D *p) diff --git a/src/corelib/tools/qshareddata.h b/src/corelib/tools/qshareddata.h index 13b0032605..dbf0907a0f 100644 --- a/src/corelib/tools/qshareddata.h +++ b/src/corelib/tools/qshareddata.h @@ -85,7 +85,7 @@ public: inline bool operator==(const QSharedDataPointer<T> &other) const { return d == other.d; } inline bool operator!=(const QSharedDataPointer<T> &other) const { return d != other.d; } - inline QSharedDataPointer() { d = Q_NULLPTR; } + inline QSharedDataPointer() { d = nullptr; } inline ~QSharedDataPointer() { if (d && !d->ref.deref()) delete d; } explicit QSharedDataPointer(T *data) Q_DECL_NOTHROW; @@ -113,7 +113,7 @@ public: return *this; } #ifdef Q_COMPILER_RVALUE_REFS - QSharedDataPointer(QSharedDataPointer &&o) Q_DECL_NOTHROW : d(o.d) { o.d = Q_NULLPTR; } + QSharedDataPointer(QSharedDataPointer &&o) Q_DECL_NOTHROW : d(o.d) { o.d = nullptr; } inline QSharedDataPointer<T> &operator=(QSharedDataPointer<T> &&other) Q_DECL_NOTHROW { qSwap(d, other.d); return *this; } #endif @@ -151,17 +151,17 @@ public: if(d && !d->ref.deref()) delete d; - d = Q_NULLPTR; + d = nullptr; } - inline operator bool () const { return d != Q_NULLPTR; } + inline operator bool () const { return d != nullptr; } inline bool operator==(const QExplicitlySharedDataPointer<T> &other) const { return d == other.d; } inline bool operator!=(const QExplicitlySharedDataPointer<T> &other) const { return d != other.d; } inline bool operator==(const T *ptr) const { return d == ptr; } inline bool operator!=(const T *ptr) const { return d != ptr; } - inline QExplicitlySharedDataPointer() { d = Q_NULLPTR; } + inline QExplicitlySharedDataPointer() { d = nullptr; } inline ~QExplicitlySharedDataPointer() { if (d && !d->ref.deref()) delete d; } explicit QExplicitlySharedDataPointer(T *data) Q_DECL_NOTHROW; @@ -202,7 +202,7 @@ public: return *this; } #ifdef Q_COMPILER_RVALUE_REFS - inline QExplicitlySharedDataPointer(QExplicitlySharedDataPointer &&o) Q_DECL_NOTHROW : d(o.d) { o.d = Q_NULLPTR; } + inline QExplicitlySharedDataPointer(QExplicitlySharedDataPointer &&o) Q_DECL_NOTHROW : d(o.d) { o.d = nullptr; } inline QExplicitlySharedDataPointer<T> &operator=(QExplicitlySharedDataPointer<T> &&other) Q_DECL_NOTHROW { qSwap(d, other.d); return *this; } #endif diff --git a/src/corelib/tools/qsharedpointer.cpp b/src/corelib/tools/qsharedpointer.cpp index af09ef6f40..7f1e9ed798 100644 --- a/src/corelib/tools/qsharedpointer.cpp +++ b/src/corelib/tools/qsharedpointer.cpp @@ -577,6 +577,15 @@ */ /*! + \fn T *QSharedPointer::get() const + \since 5.11 + + Same as data(). + + This function is provided for API compatibility with \c{std::shared_ptr}. +*/ + +/*! \fn T &QSharedPointer::operator *() const Provides access to the shared pointer's members. diff --git a/src/corelib/tools/qsharedpointer.h b/src/corelib/tools/qsharedpointer.h index 3b86eb238b..98b38b97d3 100644 --- a/src/corelib/tools/qsharedpointer.h +++ b/src/corelib/tools/qsharedpointer.h @@ -59,6 +59,7 @@ class QSharedPointer public: // basic accessor functions T *data() const; + T *get() const; bool isNull() const; operator bool() const; bool operator!() const; diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h index ede54c155d..a0e408b94a 100644 --- a/src/corelib/tools/qsharedpointer_impl.h +++ b/src/corelib/tools/qsharedpointer_impl.h @@ -303,8 +303,9 @@ public: typedef qptrdiff difference_type; T *data() const Q_DECL_NOTHROW { return value; } + T *get() const Q_DECL_NOTHROW { return value; } bool isNull() const Q_DECL_NOTHROW { return !data(); } - operator RestrictedBool() const Q_DECL_NOTHROW { return isNull() ? Q_NULLPTR : &QSharedPointer::value; } + operator RestrictedBool() const Q_DECL_NOTHROW { return isNull() ? nullptr : &QSharedPointer::value; } bool operator !() const Q_DECL_NOTHROW { return isNull(); } T &operator*() const { return *data(); } T *operator->() const Q_DECL_NOTHROW { return data(); } @@ -337,8 +338,8 @@ public: QSharedPointer(QSharedPointer &&other) Q_DECL_NOTHROW : value(other.value), d(other.d) { - other.d = Q_NULLPTR; - other.value = Q_NULLPTR; + other.d = nullptr; + other.value = nullptr; } QSharedPointer &operator=(QSharedPointer &&other) Q_DECL_NOTHROW { @@ -351,8 +352,8 @@ public: QSharedPointer(QSharedPointer<X> &&other) Q_DECL_NOTHROW : value(other.value), d(other.d) { - other.d = Q_NULLPTR; - other.value = Q_NULLPTR; + other.d = nullptr; + other.value = nullptr; } template <class X> @@ -378,7 +379,7 @@ public: } template <class X> - inline QSharedPointer(const QWeakPointer<X> &other) : value(Q_NULLPTR), d(Q_NULLPTR) + inline QSharedPointer(const QWeakPointer<X> &other) : value(nullptr), d(nullptr) { *this = other; } template <class X> @@ -476,7 +477,7 @@ private: inline void internalConstruct(X *ptr, Deleter deleter) { if (!ptr) { - d = Q_NULLPTR; + d = nullptr; return; } @@ -527,14 +528,14 @@ public: o->weakref.ref(); } else { o->checkQObjectShared(actual); - o = Q_NULLPTR; + o = nullptr; } } qSwap(d, o); qSwap(this->value, actual); if (!d || d->strongref.load() == 0) - this->value = Q_NULLPTR; + this->value = nullptr; // dereference saved data deref(o); @@ -559,19 +560,19 @@ public: typedef const value_type &const_reference; typedef qptrdiff difference_type; - bool isNull() const Q_DECL_NOTHROW { return d == Q_NULLPTR || d->strongref.load() == 0 || value == Q_NULLPTR; } - operator RestrictedBool() const Q_DECL_NOTHROW { return isNull() ? Q_NULLPTR : &QWeakPointer::value; } + bool isNull() const Q_DECL_NOTHROW { return d == nullptr || d->strongref.load() == 0 || value == nullptr; } + operator RestrictedBool() const Q_DECL_NOTHROW { return isNull() ? nullptr : &QWeakPointer::value; } bool operator !() const Q_DECL_NOTHROW { return isNull(); } - T *data() const Q_DECL_NOTHROW { return d == Q_NULLPTR || d->strongref.load() == 0 ? Q_NULLPTR : value; } + T *data() const Q_DECL_NOTHROW { return d == nullptr || d->strongref.load() == 0 ? nullptr : value; } - inline QWeakPointer() Q_DECL_NOTHROW : d(Q_NULLPTR), value(Q_NULLPTR) { } + inline QWeakPointer() Q_DECL_NOTHROW : d(nullptr), value(nullptr) { } inline ~QWeakPointer() { if (d && !d->weakref.deref()) delete d; } #ifndef QT_NO_QOBJECT // special constructor that is enabled only if X derives from QObject #if QT_DEPRECATED_SINCE(5, 0) template <class X> - QT_DEPRECATED inline QWeakPointer(X *ptr) : d(ptr ? Data::getAndRef(ptr) : Q_NULLPTR), value(ptr) + QT_DEPRECATED inline QWeakPointer(X *ptr) : d(ptr ? Data::getAndRef(ptr) : nullptr), value(ptr) { } #endif #endif @@ -588,8 +589,8 @@ public: QWeakPointer(QWeakPointer &&other) Q_DECL_NOTHROW : d(other.d), value(other.value) { - other.d = Q_NULLPTR; - other.value = Q_NULLPTR; + other.d = nullptr; + other.value = nullptr; } QWeakPointer &operator=(QWeakPointer &&other) Q_DECL_NOTHROW { QWeakPointer moved(std::move(other)); swap(moved); return *this; } @@ -616,7 +617,7 @@ public: } template <class X> - inline QWeakPointer(const QWeakPointer<X> &o) : d(Q_NULLPTR), value(Q_NULLPTR) + inline QWeakPointer(const QWeakPointer<X> &o) : d(nullptr), value(nullptr) { *this = o; } template <class X> @@ -637,7 +638,7 @@ public: { return !(*this == o); } template <class X> - inline QWeakPointer(const QSharedPointer<X> &o) : d(Q_NULLPTR), value(Q_NULLPTR) + inline QWeakPointer(const QSharedPointer<X> &o) : d(nullptr), value(nullptr) { *this = o; } template <class X> @@ -681,7 +682,7 @@ public: #ifndef QT_NO_QOBJECT template <class X> - inline QWeakPointer(X *ptr, bool) : d(ptr ? Data::getAndRef(ptr) : Q_NULLPTR), value(ptr) + inline QWeakPointer(X *ptr, bool) : d(ptr ? Data::getAndRef(ptr) : nullptr), value(ptr) { } #endif diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index c10987a5fe..78b7e69d9c 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -4058,7 +4058,7 @@ int QString::count(const QRegExp& rx) const */ int QString::indexOf(const QRegularExpression& re, int from) const { - return indexOf(re, from, Q_NULLPTR); + return indexOf(re, from, nullptr); } /*! @@ -4109,7 +4109,7 @@ int QString::indexOf(const QRegularExpression &re, int from, QRegularExpressionM */ int QString::lastIndexOf(const QRegularExpression &re, int from) const { - return lastIndexOf(re, from, Q_NULLPTR); + return lastIndexOf(re, from, nullptr); } /*! @@ -4161,7 +4161,7 @@ int QString::lastIndexOf(const QRegularExpression &re, int from, QRegularExpress */ bool QString::contains(const QRegularExpression &re) const { - return contains(re, Q_NULLPTR); + return contains(re, nullptr); } /*! diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index fe7e9b050b..b411bdac5a 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -91,7 +91,7 @@ template <typename T> class QVector; class QLatin1String { public: - Q_DECL_CONSTEXPR inline QLatin1String() Q_DECL_NOTHROW : m_size(0), m_data(Q_NULLPTR) {} + Q_DECL_CONSTEXPR inline QLatin1String() Q_DECL_NOTHROW : m_size(0), m_data(nullptr) {} Q_DECL_CONSTEXPR inline explicit QLatin1String(const char *s) Q_DECL_NOTHROW : m_size(s ? int(strlen(s)) : 0), m_data(s) {} Q_DECL_CONSTEXPR explicit QLatin1String(const char *f, const char *l) : QLatin1String(f, int(l - f)) {} @@ -624,16 +624,16 @@ public: static int localeAwareCompare(const QString& s1, const QStringRef& s2); // ### Qt6: make inline except for the long long versions - short toShort(bool *ok=Q_NULLPTR, int base=10) const; - ushort toUShort(bool *ok=Q_NULLPTR, int base=10) const; - int toInt(bool *ok=Q_NULLPTR, int base=10) const; - uint toUInt(bool *ok=Q_NULLPTR, int base=10) const; - long toLong(bool *ok=Q_NULLPTR, int base=10) const; - ulong toULong(bool *ok=Q_NULLPTR, int base=10) const; - qlonglong toLongLong(bool *ok=Q_NULLPTR, int base=10) const; - qulonglong toULongLong(bool *ok=Q_NULLPTR, int base=10) const; - float toFloat(bool *ok=Q_NULLPTR) const; - double toDouble(bool *ok=Q_NULLPTR) const; + short toShort(bool *ok=nullptr, int base=10) const; + ushort toUShort(bool *ok=nullptr, int base=10) const; + int toInt(bool *ok=nullptr, int base=10) const; + uint toUInt(bool *ok=nullptr, int base=10) const; + long toLong(bool *ok=nullptr, int base=10) const; + ulong toULong(bool *ok=nullptr, int base=10) const; + qlonglong toLongLong(bool *ok=nullptr, int base=10) const; + qulonglong toULongLong(bool *ok=nullptr, int base=10) const; + float toFloat(bool *ok=nullptr) const; + double toDouble(bool *ok=nullptr) const; QString &setNum(short, int base=10); QString &setNum(ushort, int base=10); @@ -1417,7 +1417,7 @@ public: typedef QString::const_reference const_reference; // ### Qt 6: make this constructor constexpr, after the destructor is made trivial - inline QStringRef() : m_string(Q_NULLPTR), m_position(0), m_size(0) {} + inline QStringRef() : m_string(nullptr), m_position(0), m_size(0) {} inline QStringRef(const QString *string, int position, int size); inline QStringRef(const QString *string); @@ -1533,10 +1533,10 @@ public: Q_REQUIRED_RESULT QByteArray toLocal8Bit() const; Q_REQUIRED_RESULT QVector<uint> toUcs4() const; - inline void clear() { m_string = Q_NULLPTR; m_position = m_size = 0; } + inline void clear() { m_string = nullptr; m_position = m_size = 0; } QString toString() const; inline bool isEmpty() const { return m_size == 0; } - inline bool isNull() const { return m_string == Q_NULLPTR || m_string->isNull(); } + inline bool isNull() const { return m_string == nullptr || m_string->isNull(); } QStringRef appendTo(QString *string) const; @@ -1576,16 +1576,16 @@ public: static int localeAwareCompare(const QStringRef &s1, const QStringRef &s2); Q_REQUIRED_RESULT QStringRef trimmed() const; - short toShort(bool *ok = Q_NULLPTR, int base = 10) const; - ushort toUShort(bool *ok = Q_NULLPTR, int base = 10) const; - int toInt(bool *ok = Q_NULLPTR, int base = 10) const; - uint toUInt(bool *ok = Q_NULLPTR, int base = 10) const; - long toLong(bool *ok = Q_NULLPTR, int base = 10) const; - ulong toULong(bool *ok = Q_NULLPTR, int base = 10) const; - qlonglong toLongLong(bool *ok = Q_NULLPTR, int base = 10) const; - qulonglong toULongLong(bool *ok = Q_NULLPTR, int base = 10) const; - float toFloat(bool *ok = Q_NULLPTR) const; - double toDouble(bool *ok = Q_NULLPTR) const; + short toShort(bool *ok = nullptr, int base = 10) const; + ushort toUShort(bool *ok = nullptr, int base = 10) const; + int toInt(bool *ok = nullptr, int base = 10) const; + uint toUInt(bool *ok = nullptr, int base = 10) const; + long toLong(bool *ok = nullptr, int base = 10) const; + ulong toULong(bool *ok = nullptr, int base = 10) const; + qlonglong toLongLong(bool *ok = nullptr, int base = 10) const; + qulonglong toULongLong(bool *ok = nullptr, int base = 10) const; + float toFloat(bool *ok = nullptr) const; + double toDouble(bool *ok = nullptr) const; }; Q_DECLARE_TYPEINFO(QStringRef, Q_PRIMITIVE_TYPE); diff --git a/src/corelib/tools/qtextboundaryfinder.h b/src/corelib/tools/qtextboundaryfinder.h index d021df3f2c..b1e5008f54 100644 --- a/src/corelib/tools/qtextboundaryfinder.h +++ b/src/corelib/tools/qtextboundaryfinder.h @@ -74,7 +74,7 @@ public: Q_DECLARE_FLAGS( BoundaryReasons, BoundaryReason ) QTextBoundaryFinder(BoundaryType type, const QString &string); - QTextBoundaryFinder(BoundaryType type, const QChar *chars, int length, unsigned char *buffer = Q_NULLPTR, int bufferSize = 0); + QTextBoundaryFinder(BoundaryType type, const QChar *chars, int length, unsigned char *buffer = nullptr, int bufferSize = 0); inline bool isValid() const { return d; } diff --git a/src/corelib/tools/qtimeline.h b/src/corelib/tools/qtimeline.h index f0e9a32e4d..d9982bdb58 100644 --- a/src/corelib/tools/qtimeline.h +++ b/src/corelib/tools/qtimeline.h @@ -76,7 +76,7 @@ public: CosineCurve }; - explicit QTimeLine(int duration = 1000, QObject *parent = Q_NULLPTR); + explicit QTimeLine(int duration = 1000, QObject *parent = nullptr); virtual ~QTimeLine(); State state() const; @@ -127,7 +127,7 @@ Q_SIGNALS: void finished(QPrivateSignal); protected: - void timerEvent(QTimerEvent *event) Q_DECL_OVERRIDE; + void timerEvent(QTimerEvent *event) override; private: Q_DISABLE_COPY(QTimeLine) diff --git a/src/corelib/tools/qtimezoneprivate_p.h b/src/corelib/tools/qtimezoneprivate_p.h index 74b79dce16..592fcceeef 100644 --- a/src/corelib/tools/qtimezoneprivate_p.h +++ b/src/corelib/tools/qtimezoneprivate_p.h @@ -171,7 +171,7 @@ Q_DECLARE_TYPEINFO(QTimeZonePrivate::Data, Q_MOVABLE_TYPE); template<> QTimeZonePrivate *QSharedDataPointer<QTimeZonePrivate>::clone(); -class Q_AUTOTEST_EXPORT QUtcTimeZonePrivate Q_DECL_FINAL : public QTimeZonePrivate +class Q_AUTOTEST_EXPORT QUtcTimeZonePrivate final : public QTimeZonePrivate { public: // Create default UTC time zone @@ -189,26 +189,26 @@ public: QUtcTimeZonePrivate *clone() const override; - Data data(qint64 forMSecsSinceEpoch) const Q_DECL_OVERRIDE; + Data data(qint64 forMSecsSinceEpoch) const override; - QLocale::Country country() const Q_DECL_OVERRIDE; - QString comment() const Q_DECL_OVERRIDE; + QLocale::Country country() const override; + QString comment() const override; QString displayName(QTimeZone::TimeType timeType, QTimeZone::NameType nameType, - const QLocale &locale) const Q_DECL_OVERRIDE; - QString abbreviation(qint64 atMSecsSinceEpoch) const Q_DECL_OVERRIDE; + const QLocale &locale) const override; + QString abbreviation(qint64 atMSecsSinceEpoch) const override; - int standardTimeOffset(qint64 atMSecsSinceEpoch) const Q_DECL_OVERRIDE; - int daylightTimeOffset(qint64 atMSecsSinceEpoch) const Q_DECL_OVERRIDE; + int standardTimeOffset(qint64 atMSecsSinceEpoch) const override; + int daylightTimeOffset(qint64 atMSecsSinceEpoch) const override; - QByteArray systemTimeZoneId() const Q_DECL_OVERRIDE; + QByteArray systemTimeZoneId() const override; - QList<QByteArray> availableTimeZoneIds() const Q_DECL_OVERRIDE; - QList<QByteArray> availableTimeZoneIds(QLocale::Country country) const Q_DECL_OVERRIDE; - QList<QByteArray> availableTimeZoneIds(int utcOffset) const Q_DECL_OVERRIDE; + QList<QByteArray> availableTimeZoneIds() const override; + QList<QByteArray> availableTimeZoneIds(QLocale::Country country) const override; + QList<QByteArray> availableTimeZoneIds(int utcOffset) const override; - void serialize(QDataStream &ds) const Q_DECL_OVERRIDE; + void serialize(QDataStream &ds) const override; private: void init(const QByteArray &zoneId); @@ -224,7 +224,7 @@ private: }; #if QT_CONFIG(icu) -class Q_AUTOTEST_EXPORT QIcuTimeZonePrivate Q_DECL_FINAL : public QTimeZonePrivate +class Q_AUTOTEST_EXPORT QIcuTimeZonePrivate final : public QTimeZonePrivate { public: // Create default time zone @@ -237,27 +237,27 @@ public: QIcuTimeZonePrivate *clone() const override; QString displayName(QTimeZone::TimeType timeType, QTimeZone::NameType nameType, - const QLocale &locale) const Q_DECL_OVERRIDE; - QString abbreviation(qint64 atMSecsSinceEpoch) const Q_DECL_OVERRIDE; + const QLocale &locale) const override; + QString abbreviation(qint64 atMSecsSinceEpoch) const override; - int offsetFromUtc(qint64 atMSecsSinceEpoch) const Q_DECL_OVERRIDE; - int standardTimeOffset(qint64 atMSecsSinceEpoch) const Q_DECL_OVERRIDE; - int daylightTimeOffset(qint64 atMSecsSinceEpoch) const Q_DECL_OVERRIDE; + int offsetFromUtc(qint64 atMSecsSinceEpoch) const override; + int standardTimeOffset(qint64 atMSecsSinceEpoch) const override; + int daylightTimeOffset(qint64 atMSecsSinceEpoch) const override; - bool hasDaylightTime() const Q_DECL_OVERRIDE; - bool isDaylightTime(qint64 atMSecsSinceEpoch) const Q_DECL_OVERRIDE; + bool hasDaylightTime() const override; + bool isDaylightTime(qint64 atMSecsSinceEpoch) const override; - Data data(qint64 forMSecsSinceEpoch) const Q_DECL_OVERRIDE; + Data data(qint64 forMSecsSinceEpoch) const override; - bool hasTransitions() const Q_DECL_OVERRIDE; - Data nextTransition(qint64 afterMSecsSinceEpoch) const Q_DECL_OVERRIDE; - Data previousTransition(qint64 beforeMSecsSinceEpoch) const Q_DECL_OVERRIDE; + bool hasTransitions() const override; + Data nextTransition(qint64 afterMSecsSinceEpoch) const override; + Data previousTransition(qint64 beforeMSecsSinceEpoch) const override; - QByteArray systemTimeZoneId() const Q_DECL_OVERRIDE; + QByteArray systemTimeZoneId() const override; - QList<QByteArray> availableTimeZoneIds() const Q_DECL_OVERRIDE; - QList<QByteArray> availableTimeZoneIds(QLocale::Country country) const Q_DECL_OVERRIDE; - QList<QByteArray> availableTimeZoneIds(int offsetFromUtc) const Q_DECL_OVERRIDE; + QList<QByteArray> availableTimeZoneIds() const override; + QList<QByteArray> availableTimeZoneIds(QLocale::Country country) const override; + QList<QByteArray> availableTimeZoneIds(int offsetFromUtc) const override; private: void init(const QByteArray &ianaId); @@ -285,7 +285,7 @@ Q_DECL_CONSTEXPR inline bool operator==(const QTzTransitionRule &lhs, const QTzT Q_DECL_CONSTEXPR inline bool operator!=(const QTzTransitionRule &lhs, const QTzTransitionRule &rhs) Q_DECL_NOTHROW { return !operator==(lhs, rhs); } -class Q_AUTOTEST_EXPORT QTzTimeZonePrivate Q_DECL_FINAL : public QTimeZonePrivate +class Q_AUTOTEST_EXPORT QTzTimeZonePrivate final : public QTimeZonePrivate { QTzTimeZonePrivate(const QTzTimeZonePrivate &) = default; public: @@ -297,34 +297,34 @@ public: QTzTimeZonePrivate *clone() const override; - QLocale::Country country() const Q_DECL_OVERRIDE; - QString comment() const Q_DECL_OVERRIDE; + QLocale::Country country() const override; + QString comment() const override; QString displayName(qint64 atMSecsSinceEpoch, QTimeZone::NameType nameType, - const QLocale &locale) const Q_DECL_OVERRIDE; + const QLocale &locale) const override; QString displayName(QTimeZone::TimeType timeType, QTimeZone::NameType nameType, - const QLocale &locale) const Q_DECL_OVERRIDE; - QString abbreviation(qint64 atMSecsSinceEpoch) const Q_DECL_OVERRIDE; + const QLocale &locale) const override; + QString abbreviation(qint64 atMSecsSinceEpoch) const override; - int offsetFromUtc(qint64 atMSecsSinceEpoch) const Q_DECL_OVERRIDE; - int standardTimeOffset(qint64 atMSecsSinceEpoch) const Q_DECL_OVERRIDE; - int daylightTimeOffset(qint64 atMSecsSinceEpoch) const Q_DECL_OVERRIDE; + int offsetFromUtc(qint64 atMSecsSinceEpoch) const override; + int standardTimeOffset(qint64 atMSecsSinceEpoch) const override; + int daylightTimeOffset(qint64 atMSecsSinceEpoch) const override; - bool hasDaylightTime() const Q_DECL_OVERRIDE; - bool isDaylightTime(qint64 atMSecsSinceEpoch) const Q_DECL_OVERRIDE; + bool hasDaylightTime() const override; + bool isDaylightTime(qint64 atMSecsSinceEpoch) const override; - Data data(qint64 forMSecsSinceEpoch) const Q_DECL_OVERRIDE; + Data data(qint64 forMSecsSinceEpoch) const override; - bool hasTransitions() const Q_DECL_OVERRIDE; - Data nextTransition(qint64 afterMSecsSinceEpoch) const Q_DECL_OVERRIDE; - Data previousTransition(qint64 beforeMSecsSinceEpoch) const Q_DECL_OVERRIDE; + bool hasTransitions() const override; + Data nextTransition(qint64 afterMSecsSinceEpoch) const override; + Data previousTransition(qint64 beforeMSecsSinceEpoch) const override; - QByteArray systemTimeZoneId() const Q_DECL_OVERRIDE; + QByteArray systemTimeZoneId() const override; - QList<QByteArray> availableTimeZoneIds() const Q_DECL_OVERRIDE; - QList<QByteArray> availableTimeZoneIds(QLocale::Country country) const Q_DECL_OVERRIDE; + QList<QByteArray> availableTimeZoneIds() const override; + QList<QByteArray> availableTimeZoneIds(QLocale::Country country) const override; private: void init(const QByteArray &ianaId); @@ -341,7 +341,7 @@ private: #endif // Q_OS_UNIX #ifdef Q_OS_MAC -class Q_AUTOTEST_EXPORT QMacTimeZonePrivate Q_DECL_FINAL : public QTimeZonePrivate +class Q_AUTOTEST_EXPORT QMacTimeZonePrivate final : public QTimeZonePrivate { public: // Create default time zone @@ -353,28 +353,28 @@ public: QMacTimeZonePrivate *clone() const override; - QString comment() const Q_DECL_OVERRIDE; + QString comment() const override; QString displayName(QTimeZone::TimeType timeType, QTimeZone::NameType nameType, - const QLocale &locale) const Q_DECL_OVERRIDE; - QString abbreviation(qint64 atMSecsSinceEpoch) const Q_DECL_OVERRIDE; + const QLocale &locale) const override; + QString abbreviation(qint64 atMSecsSinceEpoch) const override; - int offsetFromUtc(qint64 atMSecsSinceEpoch) const Q_DECL_OVERRIDE; - int standardTimeOffset(qint64 atMSecsSinceEpoch) const Q_DECL_OVERRIDE; - int daylightTimeOffset(qint64 atMSecsSinceEpoch) const Q_DECL_OVERRIDE; + int offsetFromUtc(qint64 atMSecsSinceEpoch) const override; + int standardTimeOffset(qint64 atMSecsSinceEpoch) const override; + int daylightTimeOffset(qint64 atMSecsSinceEpoch) const override; - bool hasDaylightTime() const Q_DECL_OVERRIDE; - bool isDaylightTime(qint64 atMSecsSinceEpoch) const Q_DECL_OVERRIDE; + bool hasDaylightTime() const override; + bool isDaylightTime(qint64 atMSecsSinceEpoch) const override; - Data data(qint64 forMSecsSinceEpoch) const Q_DECL_OVERRIDE; + Data data(qint64 forMSecsSinceEpoch) const override; - bool hasTransitions() const Q_DECL_OVERRIDE; - Data nextTransition(qint64 afterMSecsSinceEpoch) const Q_DECL_OVERRIDE; - Data previousTransition(qint64 beforeMSecsSinceEpoch) const Q_DECL_OVERRIDE; + bool hasTransitions() const override; + Data nextTransition(qint64 afterMSecsSinceEpoch) const override; + Data previousTransition(qint64 beforeMSecsSinceEpoch) const override; - QByteArray systemTimeZoneId() const Q_DECL_OVERRIDE; + QByteArray systemTimeZoneId() const override; - QList<QByteArray> availableTimeZoneIds() const Q_DECL_OVERRIDE; + QList<QByteArray> availableTimeZoneIds() const override; NSTimeZone *nsTimeZone() const; @@ -386,7 +386,7 @@ private: #endif // Q_OS_MAC #ifdef Q_OS_WIN -class Q_AUTOTEST_EXPORT QWinTimeZonePrivate Q_DECL_FINAL : public QTimeZonePrivate +class Q_AUTOTEST_EXPORT QWinTimeZonePrivate final : public QTimeZonePrivate { public: struct QWinTransitionRule { @@ -406,28 +406,28 @@ public: QWinTimeZonePrivate *clone() const override; - QString comment() const Q_DECL_OVERRIDE; + QString comment() const override; QString displayName(QTimeZone::TimeType timeType, QTimeZone::NameType nameType, - const QLocale &locale) const Q_DECL_OVERRIDE; - QString abbreviation(qint64 atMSecsSinceEpoch) const Q_DECL_OVERRIDE; + const QLocale &locale) const override; + QString abbreviation(qint64 atMSecsSinceEpoch) const override; - int offsetFromUtc(qint64 atMSecsSinceEpoch) const Q_DECL_OVERRIDE; - int standardTimeOffset(qint64 atMSecsSinceEpoch) const Q_DECL_OVERRIDE; - int daylightTimeOffset(qint64 atMSecsSinceEpoch) const Q_DECL_OVERRIDE; + int offsetFromUtc(qint64 atMSecsSinceEpoch) const override; + int standardTimeOffset(qint64 atMSecsSinceEpoch) const override; + int daylightTimeOffset(qint64 atMSecsSinceEpoch) const override; - bool hasDaylightTime() const Q_DECL_OVERRIDE; - bool isDaylightTime(qint64 atMSecsSinceEpoch) const Q_DECL_OVERRIDE; + bool hasDaylightTime() const override; + bool isDaylightTime(qint64 atMSecsSinceEpoch) const override; - Data data(qint64 forMSecsSinceEpoch) const Q_DECL_OVERRIDE; + Data data(qint64 forMSecsSinceEpoch) const override; - bool hasTransitions() const Q_DECL_OVERRIDE; - Data nextTransition(qint64 afterMSecsSinceEpoch) const Q_DECL_OVERRIDE; - Data previousTransition(qint64 beforeMSecsSinceEpoch) const Q_DECL_OVERRIDE; + bool hasTransitions() const override; + Data nextTransition(qint64 afterMSecsSinceEpoch) const override; + Data previousTransition(qint64 beforeMSecsSinceEpoch) const override; - QByteArray systemTimeZoneId() const Q_DECL_OVERRIDE; + QByteArray systemTimeZoneId() const override; - QList<QByteArray> availableTimeZoneIds() const Q_DECL_OVERRIDE; + QList<QByteArray> availableTimeZoneIds() const override; private: void init(const QByteArray &ianaId); @@ -444,7 +444,7 @@ private: #endif // Q_OS_WIN #ifdef Q_OS_ANDROID -class QAndroidTimeZonePrivate Q_DECL_FINAL : public QTimeZonePrivate +class QAndroidTimeZonePrivate final : public QTimeZonePrivate { public: // Create default time zone @@ -457,25 +457,25 @@ public: QAndroidTimeZonePrivate *clone() const override; QString displayName(QTimeZone::TimeType timeType, QTimeZone::NameType nameType, - const QLocale &locale) const Q_DECL_OVERRIDE; - QString abbreviation(qint64 atMSecsSinceEpoch) const Q_DECL_OVERRIDE; + const QLocale &locale) const override; + QString abbreviation(qint64 atMSecsSinceEpoch) const override; - int offsetFromUtc(qint64 atMSecsSinceEpoch) const Q_DECL_OVERRIDE; - int standardTimeOffset(qint64 atMSecsSinceEpoch) const Q_DECL_OVERRIDE; - int daylightTimeOffset(qint64 atMSecsSinceEpoch) const Q_DECL_OVERRIDE; + int offsetFromUtc(qint64 atMSecsSinceEpoch) const override; + int standardTimeOffset(qint64 atMSecsSinceEpoch) const override; + int daylightTimeOffset(qint64 atMSecsSinceEpoch) const override; - bool hasDaylightTime() const Q_DECL_OVERRIDE; - bool isDaylightTime(qint64 atMSecsSinceEpoch) const Q_DECL_OVERRIDE; + bool hasDaylightTime() const override; + bool isDaylightTime(qint64 atMSecsSinceEpoch) const override; - Data data(qint64 forMSecsSinceEpoch) const Q_DECL_OVERRIDE; + Data data(qint64 forMSecsSinceEpoch) const override; - bool hasTransitions() const Q_DECL_OVERRIDE; - Data nextTransition(qint64 afterMSecsSinceEpoch) const Q_DECL_OVERRIDE; - Data previousTransition(qint64 beforeMSecsSinceEpoch) const Q_DECL_OVERRIDE; + bool hasTransitions() const override; + Data nextTransition(qint64 afterMSecsSinceEpoch) const override; + Data previousTransition(qint64 beforeMSecsSinceEpoch) const override; - QByteArray systemTimeZoneId() const Q_DECL_OVERRIDE; + QByteArray systemTimeZoneId() const override; - QList<QByteArray> availableTimeZoneIds() const Q_DECL_OVERRIDE; + QList<QByteArray> availableTimeZoneIds() const override; private: void init(const QByteArray &zoneId); diff --git a/src/corelib/tools/qversionnumber.h b/src/corelib/tools/qversionnumber.h index 3836bc2119..1bfb4aab39 100644 --- a/src/corelib/tools/qversionnumber.h +++ b/src/corelib/tools/qversionnumber.h @@ -281,7 +281,7 @@ public: Q_REQUIRED_RESULT Q_CORE_EXPORT QString toString() const; #if QT_STRINGVIEW_LEVEL < 2 - Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(const QString &string, int *suffixIndex = Q_NULLPTR); + Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(const QString &string, int *suffixIndex = nullptr); #endif Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QLatin1String string, int *suffixIndex = nullptr); Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QStringView string, int *suffixIndex = nullptr); diff --git a/src/corelib/xml/qxmlstream.cpp b/src/corelib/xml/qxmlstream.cpp index f6ae3571ab..c1ed410de7 100644 --- a/src/corelib/xml/qxmlstream.cpp +++ b/src/corelib/xml/qxmlstream.cpp @@ -2980,7 +2980,8 @@ public: uint inEmptyElement :1; uint lastWasStartElement :1; uint wroteSomething :1; - uint hasError :1; + uint hasIoError :1; + uint hasEncodingError :1; uint autoFormatting :1; uint isCodecASCIICompatible :1; QByteArray autoFormattingIndent; @@ -3016,7 +3017,8 @@ QXmlStreamWriterPrivate::QXmlStreamWriterPrivate(QXmlStreamWriter *q) checkIfASCIICompatibleCodec(); inStartElement = inEmptyElement = false; wroteSomething = false; - hasError = false; + hasIoError = false; + hasEncodingError = false; lastWasStartElement = false; lastNamespaceDeclaration = 1; autoFormatting = false; @@ -3043,15 +3045,19 @@ void QXmlStreamWriterPrivate::checkIfASCIICompatibleCodec() void QXmlStreamWriterPrivate::write(const QStringRef &s) { if (device) { - if (hasError) + if (hasIoError) return; #ifdef QT_NO_TEXTCODEC QByteArray bytes = s.toLatin1(); #else QByteArray bytes = encoder->fromUnicode(s.constData(), s.size()); + if (encoder->hasFailure()) { + hasEncodingError = true; + return; + } #endif if (device->write(bytes) != bytes.size()) - hasError = true; + hasIoError = true; } else if (stringDevice) s.appendTo(stringDevice); @@ -3062,15 +3068,19 @@ void QXmlStreamWriterPrivate::write(const QStringRef &s) void QXmlStreamWriterPrivate::write(const QString &s) { if (device) { - if (hasError) + if (hasIoError) return; #ifdef QT_NO_TEXTCODEC QByteArray bytes = s.toLatin1(); #else QByteArray bytes = encoder->fromUnicode(s); + if (encoder->hasFailure()) { + hasEncodingError = true; + return; + } #endif if (device->write(bytes) != bytes.size()) - hasError = true; + hasIoError = true; } else if (stringDevice) stringDevice->append(s); @@ -3084,25 +3094,47 @@ void QXmlStreamWriterPrivate::writeEscaped(const QString &s, bool escapeWhitespa escaped.reserve(s.size()); for ( int i = 0; i < s.size(); ++i ) { QChar c = s.at(i); - if (c.unicode() == '<' ) + switch (c.unicode()) { + case '<': escaped.append(QLatin1String("<")); - else if (c.unicode() == '>' ) + break; + case '>': escaped.append(QLatin1String(">")); - else if (c.unicode() == '&' ) + break; + case '&': escaped.append(QLatin1String("&")); - else if (c.unicode() == '\"' ) + break; + case '\"': escaped.append(QLatin1String(""")); - else if (escapeWhitespace && c.isSpace()) { - if (c.unicode() == '\n') + break; + case '\t': + if (escapeWhitespace) + escaped.append(QLatin1String("	")); + else + escaped += c; + break; + case '\n': + if (escapeWhitespace) escaped.append(QLatin1String(" ")); - else if (c.unicode() == '\r') + else + escaped += c; + break; + case '\v': + case '\f': + hasEncodingError = true; + break; + case '\r': + if (escapeWhitespace) escaped.append(QLatin1String(" ")); - else if (c.unicode() == '\t') - escaped.append(QLatin1String("	")); else escaped += c; - } else { - escaped += QChar(c); + break; + default: + if (c.unicode() > 0x1f && c.unicode() < 0xfffe) + escaped += c; + else + hasEncodingError = true; + break; } } write(escaped); @@ -3112,11 +3144,11 @@ void QXmlStreamWriterPrivate::writeEscaped(const QString &s, bool escapeWhitespa void QXmlStreamWriterPrivate::write(const char *s, int len) { if (device) { - if (hasError) + if (hasIoError) return; if (isCodecASCIICompatible) { if (device->write(s, len) != len) - hasError = true; + hasIoError = true; return; } } @@ -3400,15 +3432,18 @@ int QXmlStreamWriter::autoFormattingIndent() const } /*! - Returns \c true if the stream failed to write to the underlying device. + Returns \c true if writing failed. + + This can happen if the stream failed to write to the underlying + device or if the data to be written contained invalid characters. The error status is never reset. Writes happening after the error - occurred are ignored, even if the error condition is cleared. + occurred may be ignored, even if the error condition is cleared. */ bool QXmlStreamWriter::hasError() const { Q_D(const QXmlStreamWriter); - return d->hasError; + return d->hasIoError || d->hasEncodingError; } /*! diff --git a/src/corelib/xml/qxmlstream.h b/src/corelib/xml/qxmlstream.h index bf6ddefcdd..2350d12dd6 100644 --- a/src/corelib/xml/qxmlstream.h +++ b/src/corelib/xml/qxmlstream.h @@ -120,7 +120,7 @@ public: reserved(other.reserved), m_isDefault(other.m_isDefault) { - other.reserved = Q_NULLPTR; + other.reserved = nullptr; } QXmlStreamAttribute &operator=(QXmlStreamAttribute &&other) Q_DECL_NOTHROW // = default; { |