summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/animation/qabstractanimation.h10
-rw-r--r--src/corelib/animation/qabstractanimation_p.h10
-rw-r--r--src/corelib/animation/qanimationgroup.h4
-rw-r--r--src/corelib/animation/qparallelanimationgroup.h12
-rw-r--r--src/corelib/animation/qparallelanimationgroup_p.h2
-rw-r--r--src/corelib/animation/qpauseanimation.h10
-rw-r--r--src/corelib/animation/qpropertyanimation.h10
-rw-r--r--src/corelib/animation/qsequentialanimationgroup.h12
-rw-r--r--src/corelib/animation/qsequentialanimationgroup_p.h4
-rw-r--r--src/corelib/animation/qvariantanimation.h12
-rw-r--r--src/corelib/arch/qatomic_cxx11.h8
-rw-r--r--src/corelib/codecs/qiconvcodec.cpp4
-rw-r--r--src/corelib/codecs/qicucodec_p.h10
-rw-r--r--src/corelib/codecs/qisciicodec_p.h8
-rw-r--r--src/corelib/codecs/qlatincodec_p.h20
-rw-r--r--src/corelib/codecs/qtextcodec.cpp4
-rw-r--r--src/corelib/codecs/qtextcodec.h6
-rw-r--r--src/corelib/codecs/qtsciicodec_p.h8
-rw-r--r--src/corelib/codecs/qutfcodec_p.h52
-rw-r--r--src/corelib/corelib.pro7
-rw-r--r--src/corelib/global/global.pri21
-rw-r--r--src/corelib/global/qcompilerdetection.h33
-rw-r--r--src/corelib/global/qconfig-bootstrapped.h1
-rw-r--r--src/corelib/global/qendian.h4
-rw-r--r--src/corelib/global/qendian.qdoc84
-rw-r--r--src/corelib/global/qflags.h48
-rw-r--r--src/corelib/global/qfloat16.cpp97
-rw-r--r--src/corelib/global/qfloat16.h3
-rw-r--r--src/corelib/global/qfloat16_f16c.c89
-rw-r--r--src/corelib/global/qglobal.cpp341
-rw-r--r--src/corelib/global/qglobal.h70
-rw-r--r--src/corelib/global/qglobalstatic.qdoc12
-rw-r--r--src/corelib/global/qlogging.h17
-rw-r--r--src/corelib/global/qnamespace.h2
-rw-r--r--src/corelib/global/qnamespace.qdoc5
-rw-r--r--src/corelib/global/qnumeric_p.h3
-rw-r--r--src/corelib/global/qrandom.cpp142
-rw-r--r--src/corelib/global/qsysinfo.h2
-rw-r--r--src/corelib/global/qsystemdetection.h35
-rw-r--r--src/corelib/global/qversiontagging.cpp10
-rw-r--r--src/corelib/io/qbuffer.cpp4
-rw-r--r--src/corelib/io/qbuffer.h26
-rw-r--r--src/corelib/io/qdatastream.cpp5
-rw-r--r--src/corelib/io/qdatastream.h5
-rw-r--r--src/corelib/io/qdebug.cpp123
-rw-r--r--src/corelib/io/qdir.cpp1
-rw-r--r--src/corelib/io/qfile.h14
-rw-r--r--src/corelib/io/qfiledevice.h20
-rw-r--r--src/corelib/io/qfiledevice_p.h2
-rw-r--r--src/corelib/io/qfileselector.h2
-rw-r--r--src/corelib/io/qfilesystemiterator_unix.cpp17
-rw-r--r--src/corelib/io/qfilesystemwatcher.h4
-rw-r--r--src/corelib/io/qfilesystemwatcher_fsevents.mm2
-rw-r--r--src/corelib/io/qfilesystemwatcher_inotify_p.h4
-rw-r--r--src/corelib/io/qfilesystemwatcher_polling_p.h4
-rw-r--r--src/corelib/io/qfsfileengine.cpp12
-rw-r--r--src/corelib/io/qfsfileengine_iterator_p.h8
-rw-r--r--src/corelib/io/qfsfileengine_p.h70
-rw-r--r--src/corelib/io/qiodevice.h2
-rw-r--r--src/corelib/io/qiodevice_p.h4
-rw-r--r--src/corelib/io/qlockfile.cpp31
-rw-r--r--src/corelib/io/qlockfile_p.h16
-rw-r--r--src/corelib/io/qlockfile_unix.cpp2
-rw-r--r--src/corelib/io/qlockfile_win.cpp4
-rw-r--r--src/corelib/io/qnoncontiguousbytedevice_p.h58
-rw-r--r--src/corelib/io/qprocess.cpp9
-rw-r--r--src/corelib/io/qprocess.h26
-rw-r--r--src/corelib/io/qprocess_p.h2
-rw-r--r--src/corelib/io/qprocess_unix.cpp2
-rw-r--r--src/corelib/io/qprocess_win.cpp4
-rw-r--r--src/corelib/io/qresource.cpp6
-rw-r--r--src/corelib/io/qresource_iterator_p.h6
-rw-r--r--src/corelib/io/qresource_p.h60
-rw-r--r--src/corelib/io/qsavefile.h10
-rw-r--r--src/corelib/io/qsettings.h12
-rw-r--r--src/corelib/io/qsettings_mac.cpp2
-rw-r--r--src/corelib/io/qsettings_p.h18
-rw-r--r--src/corelib/io/qstandardpaths_mac.mm29
-rw-r--r--src/corelib/io/qstandardpaths_unix.cpp4
-rw-r--r--src/corelib/io/qstorageinfo_mac.cpp6
-rw-r--r--src/corelib/io/qstorageinfo_unix.cpp239
-rw-r--r--src/corelib/io/qstorageinfo_win.cpp4
-rw-r--r--src/corelib/io/qtemporarydir.cpp6
-rw-r--r--src/corelib/io/qtemporarydir.h2
-rw-r--r--src/corelib/io/qtemporaryfile.h4
-rw-r--r--src/corelib/io/qtextstream.h4
-rw-r--r--src/corelib/io/qurl.h2
-rw-r--r--src/corelib/itemmodels/qabstractitemmodel.cpp16
-rw-r--r--src/corelib/itemmodels/qabstractitemmodel.h42
-rw-r--r--src/corelib/itemmodels/qabstractproxymodel.h46
-rw-r--r--src/corelib/itemmodels/qidentityproxymodel.h40
-rw-r--r--src/corelib/itemmodels/qitemselectionmodel.cpp10
-rw-r--r--src/corelib/itemmodels/qitemselectionmodel.h2
-rw-r--r--src/corelib/itemmodels/qsortfilterproxymodel.cpp7
-rw-r--r--src/corelib/itemmodels/qsortfilterproxymodel.h62
-rw-r--r--src/corelib/itemmodels/qstringlistmodel.h22
-rw-r--r--src/corelib/json/qjsonarray.h4
-rw-r--r--src/corelib/json/qjsondocument.cpp4
-rw-r--r--src/corelib/json/qjsondocument.h6
-rw-r--r--src/corelib/json/qjsonobject.h4
-rw-r--r--src/corelib/json/qjsonvalue.h2
-rw-r--r--src/corelib/kernel/qabstracteventdispatcher.cpp4
-rw-r--r--src/corelib/kernel/qabstracteventdispatcher.h10
-rw-r--r--src/corelib/kernel/qcore_unix.cpp2
-rw-r--r--src/corelib/kernel/qcore_unix_p.h2
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp8
-rw-r--r--src/corelib/kernel/qcoreapplication.h10
-rw-r--r--src/corelib/kernel/qeventdispatcher_glib_p.h24
-rw-r--r--src/corelib/kernel/qeventdispatcher_unix_p.h26
-rw-r--r--src/corelib/kernel/qeventloop.h4
-rw-r--r--src/corelib/kernel/qfunctions_vxworks.h3
-rw-r--r--src/corelib/kernel/qjni.cpp2
-rw-r--r--src/corelib/kernel/qjnihelpers.cpp14
-rw-r--r--src/corelib/kernel/qjnionload.cpp2
-rw-r--r--src/corelib/kernel/qmetaobject.cpp46
-rw-r--r--src/corelib/kernel/qmetaobject.h38
-rw-r--r--src/corelib/kernel/qmetatype.h92
-rw-r--r--src/corelib/kernel/qobject.cpp11
-rw-r--r--src/corelib/kernel/qobject.h46
-rw-r--r--src/corelib/kernel/qobject_impl.h4
-rw-r--r--src/corelib/kernel/qobject_p.h16
-rw-r--r--src/corelib/kernel/qobjectdefs.h34
-rw-r--r--src/corelib/kernel/qobjectdefs_impl.h6
-rw-r--r--src/corelib/kernel/qpointer.cpp44
-rw-r--r--src/corelib/kernel/qsharedmemory.cpp8
-rw-r--r--src/corelib/kernel/qsharedmemory.h4
-rw-r--r--src/corelib/kernel/qsocketnotifier.h4
-rw-r--r--src/corelib/kernel/qsystemerror_p.h52
-rw-r--r--src/corelib/kernel/qtimer.cpp2
-rw-r--r--src/corelib/kernel/qtimer.h4
-rw-r--r--src/corelib/kernel/qtranslator.cpp2
-rw-r--r--src/corelib/kernel/qtranslator.h4
-rw-r--r--src/corelib/kernel/qvariant.h16
-rw-r--r--src/corelib/kernel/qvariant_p.h6
-rw-r--r--src/corelib/kernel/qwineventnotifier.h4
-rw-r--r--src/corelib/mimetypes/mimetypes.qrc2
-rw-r--r--src/corelib/mimetypes/qmimedatabase.cpp235
-rw-r--r--src/corelib/mimetypes/qmimedatabase_p.h27
-rw-r--r--src/corelib/mimetypes/qmimeglobpattern.cpp5
-rw-r--r--src/corelib/mimetypes/qmimeglobpattern_p.h2
-rw-r--r--src/corelib/mimetypes/qmimemagicrule.cpp2
-rw-r--r--src/corelib/mimetypes/qmimemagicrule_p.h2
-rw-r--r--src/corelib/mimetypes/qmimeprovider.cpp521
-rw-r--r--src/corelib/mimetypes/qmimeprovider_p.h80
-rw-r--r--src/corelib/mimetypes/qmimetype.cpp23
-rw-r--r--src/corelib/mimetypes/qmimetype_p.h3
-rw-r--r--src/corelib/mimetypes/qmimetypeparser.cpp1
-rw-r--r--src/corelib/plugin/qlibrary.h8
-rw-r--r--src/corelib/plugin/qpluginloader.h4
-rw-r--r--src/corelib/plugin/quuid.h12
-rw-r--r--src/corelib/statemachine/qabstractstate.h4
-rw-r--r--src/corelib/statemachine/qabstracttransition.cpp2
-rw-r--r--src/corelib/statemachine/qabstracttransition.h4
-rw-r--r--src/corelib/statemachine/qeventtransition.h10
-rw-r--r--src/corelib/statemachine/qfinalstate.h8
-rw-r--r--src/corelib/statemachine/qhistorystate.cpp2
-rw-r--r--src/corelib/statemachine/qhistorystate.h10
-rw-r--r--src/corelib/statemachine/qsignaltransition.h14
-rw-r--r--src/corelib/statemachine/qsignaltransition_p.h2
-rw-r--r--src/corelib/statemachine/qstate.cpp6
-rw-r--r--src/corelib/statemachine/qstate.h10
-rw-r--r--src/corelib/statemachine/qstatemachine.cpp14
-rw-r--r--src/corelib/statemachine/qstatemachine.h12
-rw-r--r--src/corelib/thread/qatomic.cpp182
-rw-r--r--src/corelib/thread/qatomic.h8
-rw-r--r--src/corelib/thread/qbasicatomic.h1
-rw-r--r--src/corelib/thread/qexception.cpp12
-rw-r--r--src/corelib/thread/qexception.h16
-rw-r--r--src/corelib/thread/qfutex_p.h142
-rw-r--r--src/corelib/thread/qfuture.h11
-rw-r--r--src/corelib/thread/qfuture.qdoc124
-rw-r--r--src/corelib/thread/qfutureinterface.cpp5
-rw-r--r--src/corelib/thread/qfutureinterface.h8
-rw-r--r--src/corelib/thread/qfutureinterface_p.h2
-rw-r--r--src/corelib/thread/qfuturesynchronizer.h3
-rw-r--r--src/corelib/thread/qfuturesynchronizer.qdoc20
-rw-r--r--src/corelib/thread/qfuturewatcher.cpp69
-rw-r--r--src/corelib/thread/qfuturewatcher.h24
-rw-r--r--src/corelib/thread/qfuturewatcher_p.h9
-rw-r--r--src/corelib/thread/qmutex.h10
-rw-r--r--src/corelib/thread/qmutex_linux.cpp83
-rw-r--r--src/corelib/thread/qreadwritelock.h4
-rw-r--r--src/corelib/thread/qresultstore.cpp4
-rw-r--r--src/corelib/thread/qresultstore.h12
-rw-r--r--src/corelib/thread/qsemaphore.cpp206
-rw-r--r--src/corelib/thread/qsemaphore.h5
-rw-r--r--src/corelib/thread/qthread.cpp20
-rw-r--r--src/corelib/thread/qthread.h6
-rw-r--r--src/corelib/thread/qthread_p.h5
-rw-r--r--src/corelib/thread/qthread_unix.cpp57
-rw-r--r--src/corelib/thread/qthreadpool.cpp2
-rw-r--r--src/corelib/thread/qthreadpool.h2
-rw-r--r--src/corelib/thread/thread.pri31
-rw-r--r--src/corelib/tools/qalgorithms.qdoc58
-rw-r--r--src/corelib/tools/qarraydata.h4
-rw-r--r--src/corelib/tools/qbytearray.h20
-rw-r--r--src/corelib/tools/qbytearraylist.h2
-rw-r--r--src/corelib/tools/qbytearraymatcher.cpp2
-rw-r--r--src/corelib/tools/qcache.qdoc32
-rw-r--r--src/corelib/tools/qcollator.h2
-rw-r--r--src/corelib/tools/qcollator_win.cpp8
-rw-r--r--src/corelib/tools/qcontiguouscache.cpp76
-rw-r--r--src/corelib/tools/qdatetime.h2
-rw-r--r--src/corelib/tools/qdatetimeparser.cpp26
-rw-r--r--src/corelib/tools/qdatetimeparser_p.h2
-rw-r--r--src/corelib/tools/qeasingcurve.cpp20
-rw-r--r--src/corelib/tools/qeasingcurve.h2
-rw-r--r--src/corelib/tools/qhash.cpp252
-rw-r--r--src/corelib/tools/qhash.h8
-rw-r--r--src/corelib/tools/qhashfunctions.h2
-rw-r--r--src/corelib/tools/qiterator.qdoc472
-rw-r--r--src/corelib/tools/qlinkedlist.cpp211
-rw-r--r--src/corelib/tools/qlinkedlist.h4
-rw-r--r--src/corelib/tools/qlist.cpp294
-rw-r--r--src/corelib/tools/qlist.h4
-rw-r--r--src/corelib/tools/qlocale.cpp86
-rw-r--r--src/corelib/tools/qlocale.h32
-rw-r--r--src/corelib/tools/qlocale_tools.cpp5
-rw-r--r--src/corelib/tools/qlocale_tools_p.h1
-rw-r--r--src/corelib/tools/qlocale_win.cpp12
-rw-r--r--src/corelib/tools/qmap.cpp280
-rw-r--r--src/corelib/tools/qmap.h46
-rw-r--r--src/corelib/tools/qpair.qdoc34
-rw-r--r--src/corelib/tools/qringbuffer.cpp196
-rw-r--r--src/corelib/tools/qringbuffer_p.h143
-rw-r--r--src/corelib/tools/qscopedpointer.cpp53
-rw-r--r--src/corelib/tools/qscopedpointer.h17
-rw-r--r--src/corelib/tools/qset.qdoc196
-rw-r--r--src/corelib/tools/qshareddata.cpp126
-rw-r--r--src/corelib/tools/qshareddata.h12
-rw-r--r--src/corelib/tools/qsharedpointer.cpp187
-rw-r--r--src/corelib/tools/qsharedpointer.h1
-rw-r--r--src/corelib/tools/qsharedpointer_impl.h39
-rw-r--r--src/corelib/tools/qsimd_p.h17
-rw-r--r--src/corelib/tools/qstring.cpp6
-rw-r--r--src/corelib/tools/qstring.h52
-rw-r--r--src/corelib/tools/qtextboundaryfinder.h2
-rw-r--r--src/corelib/tools/qtimeline.h4
-rw-r--r--src/corelib/tools/qtimezoneprivate.cpp4
-rw-r--r--src/corelib/tools/qtimezoneprivate_p.h185
-rw-r--r--src/corelib/tools/qtimezoneprivate_win.cpp560
-rw-r--r--src/corelib/tools/qvarlengtharray.qdoc150
-rw-r--r--src/corelib/tools/qvector.h4
-rw-r--r--src/corelib/tools/qvector.qdoc220
-rw-r--r--src/corelib/tools/qversionnumber.h2
-rw-r--r--src/corelib/tools/tools.pri1
-rw-r--r--src/corelib/xml/qxmlstream.cpp79
-rw-r--r--src/corelib/xml/qxmlstream.h2
248 files changed, 5324 insertions, 3991 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..a0d41396dd 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
+CONFIG += simd 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/global.pri b/src/corelib/global/global.pri
index 0f8935d4b5..2b4fd6d661 100644
--- a/src/corelib/global/global.pri
+++ b/src/corelib/global/global.pri
@@ -39,6 +39,27 @@ SOURCES += \
global/qrandom.cpp \
global/qhooks.cpp
+# Only add global/qfloat16_f16c.c if qfloat16.cpp can't #include it.
+# Any compiler: if it is already generating F16C code, let qfloat16.cpp do it
+# Clang: ICE if not generating F16C code, so use qfloat16_f16c.c
+# ICC: miscompiles if not generating F16C code, so use qfloat16_f16c.c
+# GCC: if it can use F16C intrinsics, let qfloat16.cpp do it
+# MSVC: if it is already generating AVX code, let qfloat16.cpp do it
+# MSVC: otherwise, it generates poorly-performing code, so use qfloat16_f16c.c
+contains(QT_CPU_FEATURES.$$QT_ARCH, f16c): \
+ f16c_cxx = true
+else: clang|intel_icl|intel_icc: \
+ f16c_cxx = false
+else: gcc:f16c:x86SimdAlways: \
+ f16c_cxx = true
+else: msvc:contains(QT_CPU_FEATURES.$$QT_ARCH, avx): \
+ f16c_cxx = true
+else: \
+ f16c_cxx = false
+$$f16c_cxx: DEFINES += QFLOAT16_INCLUDE_FAST
+else: F16C_SOURCES += global/qfloat16_f16c.c
+unset(f16c_cxx)
+
VERSIONTAGGING_SOURCES = global/qversiontagging.cpp
darwin: SOURCES += global/qoperatingsystemversion_darwin.mm
diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h
index 231ac2c9b0..885cb96c1a 100644
--- a/src/corelib/global/qcompilerdetection.h
+++ b/src/corelib/global/qcompilerdetection.h
@@ -243,6 +243,7 @@
# define Q_REQUIRED_RESULT __attribute__ ((__warn_unused_result__))
# define Q_DECL_PURE_FUNCTION __attribute__((pure))
# define Q_DECL_CONST_FUNCTION __attribute__((const))
+# define Q_DECL_COLD_FUNCTION __attribute__((cold))
# if !defined(QT_MOC_CPP)
# define Q_PACKED __attribute__ ((__packed__))
# ifndef __ARM_EABI__
@@ -651,6 +652,12 @@
# undef Q_COMPILER_CONSTEXPR
# endif
# endif
+# elif defined(__STDC_VERSION__) && __STDC_VERSION__ > 199901L s
+// C11 features supported. Only tested with ICC 17 and up.
+# define Q_COMPILER_STATIC_ASSERT
+# if __has_include(<threads.h>)
+# define Q_COMPILER_THREAD_LOCAL
+# endif
# endif
#endif
@@ -803,6 +810,17 @@
# endif
# endif
+# if defined(__STDC_VERSION__)
+# if __has_feature(c_static_assert)
+# define Q_COMPILER_STATIC_ASSERT
+# endif
+# if __has_feature(c_thread_local) && __has_include(<threads.h>)
+# if !defined(__FreeBSD__) /* FreeBSD clang fails on __cxa_thread_atexit */
+# define Q_COMPILER_THREAD_LOCAL
+# endif
+# endif
+# endif
+
# if defined(__has_warning)
# if __has_warning("-Wunused-private-field")
# define Q_DECL_UNUSED_MEMBER Q_DECL_UNUSED
@@ -898,6 +916,18 @@
# define Q_COMPILER_RETURN_TYPE_DEDUCTION
# endif
# endif
+# if defined(__STDC_VERSION__) && __STDC_VERSION__ > 199901L
+# if Q_CC_GNU >= 407
+ /* C11 features supported in GCC 4.7: */
+# define Q_COMPILER_STATIC_ASSERT
+# endif
+# if Q_CC_GNU >= 409
+ /* C11 features supported in GCC 4.9: */
+# if __has_include(<threads.h>)
+# define Q_COMPILER_THREAD_LOCAL
+# endif
+# endif
+# endif
#endif
#if defined(Q_CC_MSVC)
@@ -1246,6 +1276,9 @@
#ifndef Q_DECL_CONST_FUNCTION
# define Q_DECL_CONST_FUNCTION Q_DECL_PURE_FUNCTION
#endif
+#ifndef Q_DECL_COLD_FUNCTION
+# define Q_DECL_COLD_FUNCTION
+#endif
#ifndef QT_MAKE_UNCHECKED_ARRAY_ITERATOR
# define QT_MAKE_UNCHECKED_ARRAY_ITERATOR(x) (x)
#endif
diff --git a/src/corelib/global/qconfig-bootstrapped.h b/src/corelib/global/qconfig-bootstrapped.h
index dabb715607..0df593941d 100644
--- a/src/corelib/global/qconfig-bootstrapped.h
+++ b/src/corelib/global/qconfig-bootstrapped.h
@@ -94,6 +94,7 @@
#endif
#define QT_NO_QOBJECT
#define QT_FEATURE_process -1
+#define QT_FEATURE_regularexpression -1
#define QT_FEATURE_renameat2 -1
#define QT_FEATURE_sharedmemory -1
#define QT_FEATURE_slog2 -1
diff --git a/src/corelib/global/qendian.h b/src/corelib/global/qendian.h
index 3337829de0..a14fce23f8 100644
--- a/src/corelib/global/qendian.h
+++ b/src/corelib/global/qendian.h
@@ -272,7 +272,8 @@ public:
static Q_DECL_CONSTEXPR T fromSpecial(T source) { return qFromBigEndian(source); }
};
-#ifdef Q_QDOC
+#ifdef Q_CLANG_QDOC
+template<typename T>
class QLEInteger {
public:
explicit Q_DECL_CONSTEXPR QLEInteger(T i);
@@ -292,6 +293,7 @@ public:
QLEInteger &operator ^=(T i);
};
+template<typename T>
class QBEInteger {
public:
explicit Q_DECL_CONSTEXPR QBEInteger(T i);
diff --git a/src/corelib/global/qendian.qdoc b/src/corelib/global/qendian.qdoc
index 2ccdea5979..65df25a205 100644
--- a/src/corelib/global/qendian.qdoc
+++ b/src/corelib/global/qendian.qdoc
@@ -34,8 +34,8 @@
*/
/*!
+ \fn template <typename T> T qFromUnaligned(const void *ptr)
\internal
- \fn T qFromUnaligned(const void *ptr)
\since 5.5
Loads a \c{T} from address \a ptr, which may be misaligned.
@@ -45,8 +45,8 @@
*/
/*!
+ \fn template <typename T> void qToUnaligned(const T t, void *ptr)
\internal
- \fn void qToUnaligned(T t, void *ptr)
\since 4.5
Stores \a t to address \a ptr, which may be misaligned.
@@ -57,7 +57,7 @@
/*!
- \fn T qFromBigEndian(const void *src)
+ \fn template <typename T> T qFromBigEndian(const void *src)
\since 4.3
\relates <QtEndian>
@@ -78,7 +78,7 @@
\sa qToLittleEndian()
*/
/*!
- \fn T qFromBigEndian(T src)
+ \fn template <typename T> T qFromBigEndian(T src)
\since 4.3
\relates <QtEndian>
\overload
@@ -90,7 +90,7 @@
unmodified.
*/
/*!
- \fn T qFromLittleEndian(const void *src)
+ \fn template <typename T> T qFromLittleEndian(const void *src)
\since 4.3
\relates <QtEndian>
@@ -111,7 +111,7 @@
\sa qToLittleEndian()
*/
/*!
- \fn T qFromLittleEndian(T src)
+ \fn template <typename T> T qFromLittleEndian(T src)
\since 4.3
\relates <QtEndian>
\overload
@@ -123,7 +123,7 @@
unmodified.
*/
/*!
- \fn void qToBigEndian(T src, void *dest)
+ \fn template <typename T> void qToBigEndian(T src, void *dest)
\since 4.3
\relates <QtEndian>
@@ -141,7 +141,7 @@
\sa qToLittleEndian()
*/
/*!
- \fn T qToBigEndian(T src)
+ \fn template <typename T> T qToBigEndian(T src)
\since 4.3
\relates <QtEndian>
\overload
@@ -153,7 +153,7 @@
unmodified.
*/
/*!
- \fn void qToLittleEndian(T src, void *dest)
+ \fn template <typename T> void qToLittleEndian(T src, void *dest)
\since 4.3
\relates <QtEndian>
@@ -171,7 +171,7 @@
\sa qToBigEndian()
*/
/*!
- \fn T qToLittleEndian(T src)
+ \fn template <typename T> T qToLittleEndian(T src)
\since 4.3
\relates <QtEndian>
\overload
@@ -203,100 +203,100 @@
an exact endian is needed.
*/
-/*! \fn QLEInteger::QLEInteger(T value)
+/*! \fn template <typename T> QLEInteger<T>::QLEInteger(T value)
Constructs a QLEInteger with the given \a value.
*/
-/*! \fn QLEInteger &QLEInteger::operator=(T value)
+/*! \fn template <typename T> QLEInteger &QLEInteger<T>::operator=(T i)
- Assigns \a value to this QLEInteger and returns a reference to
+ Assigns \a i to this QLEInteger and returns a reference to
this QLEInteger.
*/
/*!
- \fn QLEInteger::operator T() const
+ \fn template <typename T> QLEInteger<T>::operator T() const
Returns the value of this QLEInteger as a native integer.
*/
/*!
- \fn bool QLEInteger::operator==(QLEInteger other) const
+ \fn template <typename T> bool QLEInteger<T>::operator==(QLEInteger other) const
Returns \c true if the value of this QLEInteger is equal to the value of \a other.
*/
/*!
- \fn bool QLEInteger::operator!=(QLEInteger other) const
+ \fn template <typename T> bool QLEInteger<T>::operator!=(QLEInteger other) const
Returns \c true if the value of this QLEInteger is not equal to the value of \a other.
*/
/*!
- \fn QLEInteger &QLEInteger::operator+=(T i)
+ \fn template <typename T> QLEInteger &QLEInteger<T>::operator+=(T i)
Adds \a i to this QLEInteger and returns a reference to
this object.
*/
/*!
- \fn QLEInteger &QLEInteger::operator-=(T i)
+ \fn template <typename T> QLEInteger &QLEInteger<T>::operator-=(T i)
Subtracts \a i from this QLEInteger and returns a reference to
this object.
*/
/*!
- \fn QLEInteger &QLEInteger::operator*=(T i)
+ \fn template <typename T> QLEInteger &QLEInteger<T>::operator*=(T i)
Multiplies \a i with this QLEInteger and returns a reference to
this object.
*/
/*!
- \fn QLEInteger &QLEInteger::operator/=(T i)
+ \fn template <typename T> QLEInteger &QLEInteger<T>::operator/=(T i)
Divides this QLEInteger with \a i and returns a reference to
this object.
*/
/*!
- \fn QLEInteger &QLEInteger::operator%=(T i)
+ \fn template <typename T> QLEInteger &QLEInteger<T>::operator%=(T i)
Sets this QLEInteger to the remainder of a division by \a i and
returns a reference to this object.
*/
/*!
- \fn QLEInteger &QLEInteger::operator>>=(T i)
+ \fn template <typename T> QLEInteger &QLEInteger<T>::operator>>=(T i)
Performs a left-shift by \a i on this QLEInteger and returns a
reference to this object.
*/
/*!
- \fn QLEInteger &QLEInteger::operator<<=(T i)
+ \fn template <typename T> QLEInteger &QLEInteger<T>::operator<<=(T i)
Performs a right-shift by \a i on this QLEInteger and returns a
reference to this object.
*/
/*!
- \fn QLEInteger &QLEInteger::operator|=(T i)
+ \fn template <typename T> QLEInteger &QLEInteger<T>::operator|=(T i)
Performs a bitwise OR with \a i onto this QLEInteger and returns a reference to
this object.
*/
/*!
- \fn QLEInteger &QLEInteger::operator&=(T i)
+ \fn template <typename T> QLEInteger &QLEInteger<T>::operator&=(T i)
Performs a bitwise AND with \a i onto this QLEInteger and returns a reference to
this object.
*/
/*!
- \fn QLEInteger &QLEInteger::operator^=(T i)
+ \fn template <typename T> QLEInteger &QLEInteger<T>::operator^=(T i)
Performs a bitwise XOR with \a i onto this QLEInteger and returns a reference to
this object.
@@ -322,100 +322,100 @@
an exact endian is needed.
*/
-/*! \fn QBEInteger::QBEInteger(T value)
+/*! \fn template <typename T> QBEInteger<T>::QBEInteger(T value)
Constructs a QBEInteger with the given \a value.
*/
-/*! \fn QBEInteger &QBEInteger::operator=(T value)
+/*! \fn template <typename T> QBEInteger &QBEInteger<T>::operator=(T i)
- Assigns \a value to this QBEInteger and returns a reference to
+ Assigns \a i to this QBEInteger and returns a reference to
this QBEInteger.
*/
/*!
- \fn QBEInteger::operator T() const
+ \fn template <typename T> QBEInteger<T>::operator T() const
Returns the value of this QBEInteger as a native integer.
*/
/*!
- \fn bool QBEInteger::operator==(QBEInteger other) const
+ \fn template <typename T> bool QBEInteger<T>::operator==(QBEInteger other) const
Returns \c true if the value of this QBEInteger is equal to the value of \a other.
*/
/*!
- \fn bool QBEInteger::operator!=(QBEInteger other) const
+ \fn template <typename T> bool QBEInteger<T>::operator!=(QBEInteger other) const
Returns \c true if the value of this QBEInteger is not equal to the value of \a other.
*/
/*!
- \fn QBEInteger &QBEInteger::operator+=(T i)
+ \fn template <typename T> QBEInteger &QBEInteger<T>::operator+=(T i)
Adds \a i to this QBEInteger and returns a reference to
this object.
*/
/*!
- \fn QBEInteger &QBEInteger::operator-=(T i)
+ \fn template <typename T> QBEInteger &QBEInteger<T>::operator-=(T i)
Subtracts \a i from this QBEInteger and returns a reference to
this object.
*/
/*!
- \fn QBEInteger &QBEInteger::operator*=(T i)
+ \fn template <typename T> QBEInteger &QBEInteger<T>::operator*=(T i)
Multiplies \a i with this QBEInteger and returns a reference to
this object.
*/
/*!
- \fn QBEInteger &QBEInteger::operator/=(T i)
+ \fn template <typename T> QBEInteger &QBEInteger<T>::operator/=(T i)
Divides this QBEInteger with \a i and returns a reference to
this object.
*/
/*!
- \fn QBEInteger &QBEInteger::operator%=(T i)
+ \fn template <typename T> QBEInteger &QBEInteger<T>::operator%=(T i)
Sets this QBEInteger to the remainder of a division by \a i and
returns a reference to this object.
*/
/*!
- \fn QBEInteger &QBEInteger::operator>>=(T i)
+ \fn template <typename T> QBEInteger &QBEInteger<T>::operator>>=(T i)
Performs a left-shift by \a i on this QBEInteger and returns a
reference to this object.
*/
/*!
- \fn QBEInteger &QBEInteger::operator<<=(T i)
+ \fn template <typename T> QBEInteger &QBEInteger<T>::operator<<=(T i)
Performs a right-shift by \a i on this QBEInteger and returns a
reference to this object.
*/
/*!
- \fn QBEInteger &QBEInteger::operator|=(T i)
+ \fn template <typename T> QBEInteger &QBEInteger<T>::operator|=(T i)
Performs a bitwise OR with \a i onto this QBEInteger and returns a reference to
this object.
*/
/*!
- \fn QBEInteger &QBEInteger::operator&=(T i)
+ \fn template <typename T> QBEInteger &QBEInteger<T>::operator&=(T i)
Performs a bitwise AND with \a i onto this QBEInteger and returns a reference to
this object.
*/
/*!
- \fn QBEInteger &QBEInteger::operator^=(T i)
+ \fn template <typename T> QBEInteger &QBEInteger<T>::operator^=(T i)
Performs a bitwise XOR with \a i onto this QBEInteger and returns a reference to
this object.
diff --git a/src/corelib/global/qflags.h b/src/corelib/global/qflags.h
index 72b0a689ff..e9fee5f23e 100644
--- a/src/corelib/global/qflags.h
+++ b/src/corelib/global/qflags.h
@@ -54,20 +54,20 @@ class QFlag
{
int i;
public:
- Q_DECL_CONSTEXPR inline QFlag(int ai) Q_DECL_NOTHROW : i(ai) {}
+ Q_DECL_CONSTEXPR inline QFlag(int value) Q_DECL_NOTHROW : i(value) {}
Q_DECL_CONSTEXPR inline operator int() const Q_DECL_NOTHROW { return i; }
#if !defined(Q_CC_MSVC)
// Microsoft Visual Studio has buggy behavior when it comes to
// unsigned enums: even if the enum is unsigned, the enum tags are
// always signed
-# if !defined(__LP64__) && !defined(Q_QDOC)
- Q_DECL_CONSTEXPR inline QFlag(long ai) Q_DECL_NOTHROW : i(int(ai)) {}
- Q_DECL_CONSTEXPR inline QFlag(ulong ai) Q_DECL_NOTHROW : i(int(long(ai))) {}
+# if !defined(__LP64__) && !defined(Q_CLANG_QDOC)
+ Q_DECL_CONSTEXPR inline QFlag(long value) Q_DECL_NOTHROW : i(int(value)) {}
+ Q_DECL_CONSTEXPR inline QFlag(ulong value) Q_DECL_NOTHROW : i(int(long(value))) {}
# endif
- Q_DECL_CONSTEXPR inline QFlag(uint ai) Q_DECL_NOTHROW : i(int(ai)) {}
- Q_DECL_CONSTEXPR inline QFlag(short ai) Q_DECL_NOTHROW : i(int(ai)) {}
- Q_DECL_CONSTEXPR inline QFlag(ushort ai) Q_DECL_NOTHROW : i(int(uint(ai))) {}
+ Q_DECL_CONSTEXPR inline QFlag(uint value) Q_DECL_NOTHROW : i(int(value)) {}
+ Q_DECL_CONSTEXPR inline QFlag(short value) Q_DECL_NOTHROW : i(int(value)) {}
+ Q_DECL_CONSTEXPR inline QFlag(ushort value) Q_DECL_NOTHROW : i(int(uint(value))) {}
Q_DECL_CONSTEXPR inline operator uint() const Q_DECL_NOTHROW { return uint(i); }
#endif
};
@@ -82,7 +82,7 @@ public:
};
Q_DECLARE_TYPEINFO(QIncompatibleFlag, Q_PRIMITIVE_TYPE);
-Q_DECL_CONSTEXPR inline QIncompatibleFlag::QIncompatibleFlag(int ai) Q_DECL_NOTHROW : i(ai) {}
+Q_DECL_CONSTEXPR inline QIncompatibleFlag::QIncompatibleFlag(int value) Q_DECL_NOTHROW : i(value) {}
#ifndef Q_NO_TYPESAFE_FLAGS
@@ -100,7 +100,7 @@ class QFlags
template <typename E> friend QDataStream &operator>>(QDataStream &, QFlags<E> &);
template <typename E> friend QDataStream &operator<<(QDataStream &, QFlags<E>);
public:
-#if defined(Q_CC_MSVC) || defined(Q_QDOC)
+#if defined(Q_CC_MSVC) || defined(Q_CLANG_QDOC)
// see above for MSVC
// the definition below is too complex for qdoc
typedef int Int;
@@ -113,13 +113,13 @@ public:
#endif
typedef Enum enum_type;
// compiler-generated copy/move ctor/assignment operators are fine!
-#ifdef Q_QDOC
+#ifdef Q_CLANG_QDOC
Q_DECL_CONSTEXPR inline QFlags(const QFlags &other);
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(Enum flags) Q_DECL_NOTHROW : i(Int(flags)) {}
Q_DECL_CONSTEXPR inline QFlags(Zero = Q_NULLPTR) Q_DECL_NOTHROW : i(0) {}
- Q_DECL_CONSTEXPR inline QFlags(QFlag f) Q_DECL_NOTHROW : i(f) {}
+ Q_DECL_CONSTEXPR inline QFlags(QFlag flag) Q_DECL_NOTHROW : i(flag) {}
#ifdef Q_COMPILER_INITIALIZER_LISTS
Q_DECL_CONSTEXPR inline QFlags(std::initializer_list<Enum> flags) Q_DECL_NOTHROW
@@ -129,28 +129,28 @@ public:
Q_DECL_RELAXED_CONSTEXPR inline QFlags &operator&=(int mask) Q_DECL_NOTHROW { i &= mask; return *this; }
Q_DECL_RELAXED_CONSTEXPR inline QFlags &operator&=(uint mask) Q_DECL_NOTHROW { i &= mask; return *this; }
Q_DECL_RELAXED_CONSTEXPR inline QFlags &operator&=(Enum mask) Q_DECL_NOTHROW { i &= Int(mask); return *this; }
- Q_DECL_RELAXED_CONSTEXPR inline QFlags &operator|=(QFlags f) Q_DECL_NOTHROW { i |= f.i; return *this; }
- Q_DECL_RELAXED_CONSTEXPR inline QFlags &operator|=(Enum f) Q_DECL_NOTHROW { i |= Int(f); return *this; }
- Q_DECL_RELAXED_CONSTEXPR inline QFlags &operator^=(QFlags f) Q_DECL_NOTHROW { i ^= f.i; return *this; }
- Q_DECL_RELAXED_CONSTEXPR inline QFlags &operator^=(Enum f) Q_DECL_NOTHROW { i ^= Int(f); return *this; }
+ Q_DECL_RELAXED_CONSTEXPR inline QFlags &operator|=(QFlags other) Q_DECL_NOTHROW { i |= other.i; return *this; }
+ Q_DECL_RELAXED_CONSTEXPR inline QFlags &operator|=(Enum other) Q_DECL_NOTHROW { i |= Int(other); return *this; }
+ Q_DECL_RELAXED_CONSTEXPR inline QFlags &operator^=(QFlags other) Q_DECL_NOTHROW { i ^= other.i; return *this; }
+ Q_DECL_RELAXED_CONSTEXPR inline QFlags &operator^=(Enum other) Q_DECL_NOTHROW { i ^= Int(other); return *this; }
Q_DECL_CONSTEXPR inline operator Int() const Q_DECL_NOTHROW { return i; }
- Q_DECL_CONSTEXPR inline QFlags operator|(QFlags f) const Q_DECL_NOTHROW { return QFlags(QFlag(i | f.i)); }
- Q_DECL_CONSTEXPR inline QFlags operator|(Enum f) const Q_DECL_NOTHROW { return QFlags(QFlag(i | Int(f))); }
- Q_DECL_CONSTEXPR inline QFlags operator^(QFlags f) const Q_DECL_NOTHROW { return QFlags(QFlag(i ^ f.i)); }
- Q_DECL_CONSTEXPR inline QFlags operator^(Enum f) const Q_DECL_NOTHROW { return QFlags(QFlag(i ^ Int(f))); }
+ Q_DECL_CONSTEXPR inline QFlags operator|(QFlags other) const Q_DECL_NOTHROW { return QFlags(QFlag(i | other.i)); }
+ Q_DECL_CONSTEXPR inline QFlags operator|(Enum other) const Q_DECL_NOTHROW { return QFlags(QFlag(i | Int(other))); }
+ Q_DECL_CONSTEXPR inline QFlags operator^(QFlags other) const Q_DECL_NOTHROW { return QFlags(QFlag(i ^ other.i)); }
+ Q_DECL_CONSTEXPR inline QFlags operator^(Enum other) const Q_DECL_NOTHROW { return QFlags(QFlag(i ^ Int(other))); }
Q_DECL_CONSTEXPR inline QFlags operator&(int mask) const Q_DECL_NOTHROW { return QFlags(QFlag(i & mask)); }
Q_DECL_CONSTEXPR inline QFlags operator&(uint mask) const Q_DECL_NOTHROW { return QFlags(QFlag(i & mask)); }
- Q_DECL_CONSTEXPR inline QFlags operator&(Enum f) const Q_DECL_NOTHROW { return QFlags(QFlag(i & Int(f))); }
+ Q_DECL_CONSTEXPR inline QFlags operator&(Enum other) const Q_DECL_NOTHROW { return QFlags(QFlag(i & Int(other))); }
Q_DECL_CONSTEXPR inline QFlags operator~() const Q_DECL_NOTHROW { return QFlags(QFlag(~i)); }
Q_DECL_CONSTEXPR inline bool operator!() const Q_DECL_NOTHROW { return !i; }
- Q_DECL_CONSTEXPR inline bool testFlag(Enum f) const Q_DECL_NOTHROW { return (i & Int(f)) == Int(f) && (Int(f) != 0 || i == Int(f) ); }
- Q_DECL_RELAXED_CONSTEXPR inline QFlags &setFlag(Enum f, bool on = true) Q_DECL_NOTHROW
+ Q_DECL_CONSTEXPR inline bool testFlag(Enum flag) const Q_DECL_NOTHROW { return (i & Int(flag)) == Int(flag) && (Int(flag) != 0 || i == Int(flag) ); }
+ Q_DECL_RELAXED_CONSTEXPR inline QFlags &setFlag(Enum flag, bool on = true) Q_DECL_NOTHROW
{
- return on ? (*this |= f) : (*this &= ~Int(f));
+ return on ? (*this |= flag) : (*this &= ~Int(flag));
}
private:
diff --git a/src/corelib/global/qfloat16.cpp b/src/corelib/global/qfloat16.cpp
index 89edfc8787..3046a47292 100644
--- a/src/corelib/global/qfloat16.cpp
+++ b/src/corelib/global/qfloat16.cpp
@@ -38,6 +38,7 @@
****************************************************************************/
#include "qfloat16_p.h"
+#include "private/qsimd_p.h"
QT_BEGIN_NAMESPACE
@@ -113,4 +114,100 @@ Q_REQUIRED_RESULT bool qIsFinite(qfloat16 f) Q_DECL_NOTHROW { return qt_is_finit
exactness is stronger the smaller the numbers are.
*/
+#if QT_COMPILER_SUPPORTS(F16C)
+static inline bool hasFastF16()
+{
+ // All processors with F16C also support AVX, but YMM registers
+ // might not be supported by the OS, or they might be disabled.
+ return qCpuHasFeature(F16C) && qCpuHasFeature(AVX);
+}
+
+extern "C" {
+#ifdef QFLOAT16_INCLUDE_FAST
+# define f16cextern static
+#else
+# define f16cextern extern
+#endif
+
+f16cextern void qFloatToFloat16_fast(quint16 *out, const float *in, qsizetype len) Q_DECL_NOTHROW;
+f16cextern void qFloatFromFloat16_fast(float *out, const quint16 *in, qsizetype len) Q_DECL_NOTHROW;
+
+#undef f16cextern
+}
+
+#elif defined(__ARM_FP16_FORMAT_IEEE) && defined(__ARM_NEON__)
+static inline bool hasFastF16()
+{
+ return true;
+}
+
+static void qFloatToFloat16_fast(quint16 *out, const float *in, qsizetype len) Q_DECL_NOTHROW
+{
+ __fp16 *out_f16 = reinterpret_cast<__fp16 *>(out);
+ qsizetype i = 0;
+ for (; i < len - 3; i += 4)
+ vst1_f16(out_f16 + i, vcvt_f16_f32(vld1q_f32(in + i)));
+ SIMD_EPILOGUE(i, len, 3)
+ out_f16[i] = __fp16(in[i]);
+}
+
+static void qFloatFromFloat16_fast(float *out, const quint16 *in, qsizetype len) Q_DECL_NOTHROW
+{
+ const __fp16 *in_f16 = reinterpret_cast<const __fp16 *>(in);
+ qsizetype i = 0;
+ for (; i < len - 3; i += 4)
+ vst1q_f32(out + i, vcvt_f32_f16(vld1_f16(in_f16 + i)));
+ SIMD_EPILOGUE(i, len, 3)
+ out[i] = float(in_f16[i]);
+}
+#else
+static inline bool hasFastF16()
+{
+ return false;
+}
+
+static void qFloatToFloat16_fast(quint16 *, const float *, qsizetype) Q_DECL_NOTHROW
+{
+ Q_UNREACHABLE();
+}
+
+static void qFloatFromFloat16_fast(float *, const quint16 *, qsizetype) Q_DECL_NOTHROW
+{
+ Q_UNREACHABLE();
+}
+#endif
+/*!
+ \since 5.11
+
+ Converts \a len floats from \a in to qfloat16 and stores them in \a out.
+ Both \a in and \a out must have \a len allocated entries.
+*/
+Q_CORE_EXPORT void qFloatToFloat16(qfloat16 *out, const float *in, qsizetype len) Q_DECL_NOTHROW
+{
+ if (hasFastF16())
+ return qFloatToFloat16_fast(reinterpret_cast<quint16 *>(out), in, len);
+
+ for (qsizetype i = 0; i < len; ++i)
+ out[i] = qfloat16(in[i]);
+}
+
+/*!
+ \since 5.11
+
+ Converts \a len qfloat16 from \a in to floats and stores them in \a out.
+ Both \a in and \a out must have \a len allocated entries.
+*/
+Q_CORE_EXPORT void qFloatFromFloat16(float *out, const qfloat16 *in, qsizetype len) Q_DECL_NOTHROW
+{
+ if (hasFastF16())
+ return qFloatFromFloat16_fast(out, reinterpret_cast<const quint16 *>(in), len);
+
+ for (qsizetype i = 0; i < len; ++i)
+ out[i] = float(in[i]);
+}
+
QT_END_NAMESPACE
+
+#ifdef QFLOAT16_INCLUDE_FAST
+# include "qfloat16_f16c.c"
+#endif
diff --git a/src/corelib/global/qfloat16.h b/src/corelib/global/qfloat16.h
index 72e28edf63..a8befd7adb 100644
--- a/src/corelib/global/qfloat16.h
+++ b/src/corelib/global/qfloat16.h
@@ -88,6 +88,9 @@ private:
Q_DECLARE_TYPEINFO(qfloat16, Q_PRIMITIVE_TYPE);
+Q_CORE_EXPORT void qFloatToFloat16(qfloat16 *, const float *, qsizetype length) Q_DECL_NOTHROW;
+Q_CORE_EXPORT void qFloatFromFloat16(float *, const qfloat16 *, qsizetype length) Q_DECL_NOTHROW;
+
Q_REQUIRED_RESULT Q_CORE_EXPORT bool qIsInf(qfloat16 f) Q_DECL_NOTHROW; // complements qnumeric.h
Q_REQUIRED_RESULT Q_CORE_EXPORT bool qIsNaN(qfloat16 f) Q_DECL_NOTHROW; // complements qnumeric.h
Q_REQUIRED_RESULT Q_CORE_EXPORT bool qIsFinite(qfloat16 f) Q_DECL_NOTHROW; // complements qnumeric.h
diff --git a/src/corelib/global/qfloat16_f16c.c b/src/corelib/global/qfloat16_f16c.c
new file mode 100644
index 0000000000..31dff0b154
--- /dev/null
+++ b/src/corelib/global/qfloat16_f16c.c
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** 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$
+**
+****************************************************************************/
+
+#include "private/qsimd_p.h"
+
+// The x86 F16C instructions operate on AVX registers, so AVX support is
+// required. We don't need to check for __F16C__ because we this file wouldn't
+// have been compiled if the support was missing in the first place, and not
+// all compilers define it. Technically, we didn't need to check for __AVX__
+// either.
+#if !QT_COMPILER_SUPPORTS_HERE(AVX)
+# error "AVX support required"
+#endif
+
+#ifdef __cplusplus
+QT_BEGIN_NAMESPACE
+extern "C" {
+#endif
+
+QT_FUNCTION_TARGET(F16C)
+void qFloatToFloat16_fast(quint16 *out, const float *in, qsizetype len) Q_DECL_NOTHROW
+{
+ qsizetype i = 0;
+ for (; i < len - 7; i += 8)
+ _mm_storeu_si128((__m128i *)(out + i), _mm256_cvtps_ph(_mm256_loadu_ps(in + i), 0));
+ if (i < len - 3) {
+ _mm_storel_epi64((__m128i *)(out + i), _mm_cvtps_ph(_mm_loadu_ps(in + i), 0));
+ i += 4;
+ }
+ // Inlining "qfloat16::qfloat16(float f)":
+ SIMD_EPILOGUE(i, len, 3)
+ out[i] = _mm_extract_epi16(_mm_cvtps_ph(_mm_set_ss(in[i]), 0), 0);
+}
+
+QT_FUNCTION_TARGET(F16C)
+void qFloatFromFloat16_fast(float *out, const quint16 *in, qsizetype len) Q_DECL_NOTHROW
+{
+ qsizetype i = 0;
+ for (; i < len - 7; i += 8)
+ _mm256_storeu_ps(out + i, _mm256_cvtph_ps(_mm_loadu_si128((const __m128i *)(in + i))));
+ if (i < len - 3) {
+ _mm_storeu_ps(out + i, _mm_cvtph_ps(_mm_loadl_epi64((const __m128i *)(in + i))));
+ i += 4;
+ }
+ // Inlining "qfloat16::operator float()":
+ SIMD_EPILOGUE(i, len, 3)
+ out[i] = _mm_cvtss_f32(_mm_cvtph_ps(_mm_cvtsi32_si128(in[i])));
+}
+
+#ifdef __cplusplus
+} // extern "C"
+QT_END_NAMESPACE
+#endif
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index 0444926df5..a8fa7654ba 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
-** Copyright (C) 2016 Intel Corporation.
+** Copyright (C) 2017 Intel Corporation.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -76,6 +76,10 @@
#include <Ws2tcpip.h>
#endif // Q_OS_WINRT
+#ifdef Q_OS_WIN
+# include <qt_windows.h>
+#endif
+
#if defined(Q_OS_VXWORKS) && defined(_WRS_KERNEL)
# include <envLib.h>
#endif
@@ -181,28 +185,28 @@ Q_STATIC_ASSERT((std::is_same<qsizetype, qptrdiff>::value));
/*!
\fn QFlag::QFlag(int value)
- Constructs a QFlag object that stores the given \a value.
+ Constructs a QFlag object that stores the \a value.
*/
/*!
\fn QFlag::QFlag(uint value)
\since 5.3
- Constructs a QFlag object that stores the given \a value.
+ Constructs a QFlag object that stores the \a value.
*/
/*!
\fn QFlag::QFlag(short value)
\since 5.3
- Constructs a QFlag object that stores the given \a value.
+ Constructs a QFlag object that stores the \a value.
*/
/*!
\fn QFlag::QFlag(ushort value)
\since 5.3
- Constructs a QFlag object that stores the given \a value.
+ Constructs a QFlag object that stores the \a value.
*/
/*!
@@ -297,29 +301,28 @@ Q_STATIC_ASSERT((std::is_same<qsizetype, qptrdiff>::value));
*/
/*!
- \fn QFlags::QFlags(const QFlags &other)
+ \fn template<typename Enum> QFlags<Enum>::QFlags(const QFlags &other)
Constructs a copy of \a other.
*/
/*!
- \fn QFlags::QFlags(Enum flag)
+ \fn template <typename Enum> QFlags<Enum>::QFlags(Enum flags)
- Constructs a QFlags object storing the given \a flag.
+ Constructs a QFlags object storing the \a flags.
*/
/*!
- \fn QFlags::QFlags(Zero zero)
+ \fn template <typename Enum> QFlags<Enum>::QFlags(Zero)
- Constructs a QFlags object with no flags set. \a zero must be a
+ Constructs a QFlags object with no flags set. The parameter must be a
literal 0 value.
*/
/*!
- \fn QFlags::QFlags(QFlag value)
+ \fn template <typename Enum> QFlags<Enum>::QFlags(QFlag flag)
- Constructs a QFlags object initialized with the given integer \a
- value.
+ Constructs a QFlags object initialized with the integer \a flag.
The QFlag type is a helper type. By using it here instead of \c
int, we effectively ensure that arbitrary enum values cannot be
@@ -328,7 +331,7 @@ Q_STATIC_ASSERT((std::is_same<qsizetype, qptrdiff>::value));
*/
/*!
- \fn QFlags::QFlags(std::initializer_list<Enum> flags)
+ \fn template <typename Enum> QFlags<Enum>::QFlags(std::initializer_list<Enum> flags)
\since 5.4
Constructs a QFlags object initialized with all \a flags
@@ -338,14 +341,14 @@ Q_STATIC_ASSERT((std::is_same<qsizetype, qptrdiff>::value));
*/
/*!
- \fn QFlags &QFlags::operator=(const QFlags &other)
+ \fn template <typename Enum> QFlags &QFlags<Enum>::operator=(const QFlags &other)
Assigns \a other to this object and returns a reference to this
object.
*/
/*!
- \fn QFlags &QFlags::operator&=(int mask)
+ \fn template <typename Enum> QFlags &QFlags<Enum>::operator&=(int mask)
Performs a bitwise AND operation with \a mask and stores the
result in this QFlags object. Returns a reference to this object.
@@ -354,19 +357,19 @@ Q_STATIC_ASSERT((std::is_same<qsizetype, qptrdiff>::value));
*/
/*!
- \fn QFlags &QFlags::operator&=(uint mask)
+ \fn template <typename Enum> QFlags &QFlags<Enum>::operator&=(uint mask)
\overload
*/
/*!
- \fn QFlags &QFlags::operator&=(Enum mask)
+ \fn template <typename Enum> QFlags &QFlags<Enum>::operator&=(Enum mask)
\overload
*/
/*!
- \fn QFlags &QFlags::operator|=(QFlags other)
+ \fn template <typename Enum> QFlags &QFlags<Enum>::operator|=(QFlags other)
Performs a bitwise OR operation with \a other and stores the
result in this QFlags object. Returns a reference to this object.
@@ -375,13 +378,13 @@ Q_STATIC_ASSERT((std::is_same<qsizetype, qptrdiff>::value));
*/
/*!
- \fn QFlags &QFlags::operator|=(Enum other)
+ \fn template <typename Enum> QFlags &QFlags<Enum>::operator|=(Enum other)
\overload
*/
/*!
- \fn QFlags &QFlags::operator^=(QFlags other)
+ \fn template <typename Enum> QFlags &QFlags<Enum>::operator^=(QFlags other)
Performs a bitwise XOR operation with \a other and stores the
result in this QFlags object. Returns a reference to this object.
@@ -390,13 +393,13 @@ Q_STATIC_ASSERT((std::is_same<qsizetype, qptrdiff>::value));
*/
/*!
- \fn QFlags &QFlags::operator^=(Enum other)
+ \fn template <typename Enum> QFlags &QFlags<Enum>::operator^=(Enum other)
\overload
*/
/*!
- \fn QFlags::operator Int() const
+ \fn template <typename Enum> QFlags<Enum>::operator Int() const
Returns the value stored in the QFlags object as an integer.
@@ -404,7 +407,7 @@ Q_STATIC_ASSERT((std::is_same<qsizetype, qptrdiff>::value));
*/
/*!
- \fn QFlags QFlags::operator|(QFlags other) const
+ \fn template <typename Enum> QFlags QFlags<Enum>::operator|(QFlags other) const
Returns a QFlags object containing the result of the bitwise OR
operation on this object and \a other.
@@ -413,13 +416,13 @@ Q_STATIC_ASSERT((std::is_same<qsizetype, qptrdiff>::value));
*/
/*!
- \fn QFlags QFlags::operator|(Enum other) const
+ \fn template <typename Enum> QFlags QFlags<Enum>::operator|(Enum other) const
\overload
*/
/*!
- \fn QFlags QFlags::operator^(QFlags other) const
+ \fn template <typename Enum> QFlags QFlags<Enum>::operator^(QFlags other) const
Returns a QFlags object containing the result of the bitwise XOR
operation on this object and \a other.
@@ -428,13 +431,13 @@ Q_STATIC_ASSERT((std::is_same<qsizetype, qptrdiff>::value));
*/
/*!
- \fn QFlags QFlags::operator^(Enum other) const
+ \fn template <typename Enum> QFlags QFlags<Enum>::operator^(Enum other) const
\overload
*/
/*!
- \fn QFlags QFlags::operator&(int mask) const
+ \fn template <typename Enum> QFlags QFlags<Enum>::operator&(int mask) const
Returns a QFlags object containing the result of the bitwise AND
operation on this object and \a mask.
@@ -443,19 +446,19 @@ Q_STATIC_ASSERT((std::is_same<qsizetype, qptrdiff>::value));
*/
/*!
- \fn QFlags QFlags::operator&(uint mask) const
+ \fn template <typename Enum> QFlags QFlags<Enum>::operator&(uint mask) const
\overload
*/
/*!
- \fn QFlags QFlags::operator&(Enum mask) const
+ \fn template <typename Enum> QFlags QFlags<Enum>::operator&(Enum mask) const
\overload
*/
/*!
- \fn QFlags QFlags::operator~() const
+ \fn template <typename Enum> QFlags QFlags<Enum>::operator~() const
Returns a QFlags object that contains the bitwise negation of
this object.
@@ -464,24 +467,24 @@ Q_STATIC_ASSERT((std::is_same<qsizetype, qptrdiff>::value));
*/
/*!
- \fn bool QFlags::operator!() const
+ \fn template <typename Enum> bool QFlags<Enum>::operator!() const
Returns \c true if no flag is set (i.e., if the value stored by the
QFlags object is 0); otherwise returns \c false.
*/
/*!
- \fn bool QFlags::testFlag(Enum flag) const
+ \fn template <typename Enum> bool QFlags<Enum>::testFlag(Enum flag) const
\since 4.2
- Returns \c true if the \a flag is set, otherwise \c false.
+ Returns \c true if the flag \a flag is set, otherwise \c false.
*/
/*!
- \fn QFlags QFlags::setFlag(Enum flag, bool on)
+ \fn template <typename Enum> QFlags QFlags<Enum>::setFlag(Enum flag, bool on)
\since 5.7
- Sets the indicated \a flag if \a on is \c true or unsets it if
+ Sets the flag \a flag if \a on is \c true or unsets it if
\a on is \c false. Returns a reference to this object.
*/
@@ -919,11 +922,11 @@ Q_STATIC_ASSERT((std::is_same<qsizetype, qptrdiff>::value));
\sa quint64, qlonglong
*/
-/*! \fn T qAbs(const T &value)
+/*! \fn template <typename T> T qAbs(const T &t)
\relates <QtGlobal>
- Compares \a value to the 0 of type T and returns the absolute
- value. Thus if T is \e {double}, then \a value is compared to
+ Compares \a t to the 0 of type T and returns the absolute
+ value. Thus if T is \e {double}, then \a t is compared to
\e{(double) 0}.
Example:
@@ -931,50 +934,50 @@ Q_STATIC_ASSERT((std::is_same<qsizetype, qptrdiff>::value));
\snippet code/src_corelib_global_qglobal.cpp 10
*/
-/*! \fn int qRound(double value)
+/*! \fn int qRound(double d)
\relates <QtGlobal>
- Rounds \a value to the nearest integer.
+ Rounds \a d to the nearest integer.
Example:
\snippet code/src_corelib_global_qglobal.cpp 11A
*/
-/*! \fn int qRound(float value)
+/*! \fn int qRound(float d)
\relates <QtGlobal>
- Rounds \a value to the nearest integer.
+ Rounds \a d to the nearest integer.
Example:
\snippet code/src_corelib_global_qglobal.cpp 11B
*/
-/*! \fn qint64 qRound64(double value)
+/*! \fn qint64 qRound64(double d)
\relates <QtGlobal>
- Rounds \a value to the nearest 64-bit integer.
+ Rounds \a d to the nearest 64-bit integer.
Example:
\snippet code/src_corelib_global_qglobal.cpp 12A
*/
-/*! \fn qint64 qRound64(float value)
+/*! \fn qint64 qRound64(float d)
\relates <QtGlobal>
- Rounds \a value to the nearest 64-bit integer.
+ Rounds \a d to the nearest 64-bit integer.
Example:
\snippet code/src_corelib_global_qglobal.cpp 12B
*/
-/*! \fn const T &qMin(const T &value1, const T &value2)
+/*! \fn template <typename T> const T &qMin(const T &a, const T &b)
\relates <QtGlobal>
- Returns the minimum of \a value1 and \a value2.
+ Returns the minimum of \a a and \a b.
Example:
@@ -983,10 +986,10 @@ Q_STATIC_ASSERT((std::is_same<qsizetype, qptrdiff>::value));
\sa qMax(), qBound()
*/
-/*! \fn const T &qMax(const T &value1, const T &value2)
+/*! \fn template <typename T> const T &qMax(const T &a, const T &b)
\relates <QtGlobal>
- Returns the maximum of \a value1 and \a value2.
+ Returns the maximum of \a a and \a b.
Example:
@@ -995,11 +998,11 @@ Q_STATIC_ASSERT((std::is_same<qsizetype, qptrdiff>::value));
\sa qMin(), qBound()
*/
-/*! \fn const T &qBound(const T &min, const T &value, const T &max)
+/*! \fn template <typename T> const T &qBound(const T &min, const T &val, const T &max)
\relates <QtGlobal>
- Returns \a value bounded by \a min and \a max. This is equivalent
- to qMax(\a min, qMin(\a value, \a max)).
+ Returns \a val bounded by \a min and \a max. This is equivalent
+ to qMax(\a min, qMin(\a val, \a max)).
Example:
@@ -1008,7 +1011,7 @@ Q_STATIC_ASSERT((std::is_same<qsizetype, qptrdiff>::value));
\sa qMin(), qMax()
*/
-/*! \fn auto qOverload(T functionPointer)
+/*! \fn template <typename T> auto qOverload(T functionPointer)
\relates <QtGlobal>
\since 5.7
@@ -1030,7 +1033,7 @@ Q_STATIC_ASSERT((std::is_same<qsizetype, qptrdiff>::value));
and Functor-Based Connections}
*/
-/*! \fn auto qConstOverload(T memberFunctionPointer)
+/*! \fn template <typename T> auto qConstOverload(T memberFunctionPointer)
\relates <QtGlobal>
\since 5.7
@@ -1042,7 +1045,7 @@ Q_STATIC_ASSERT((std::is_same<qsizetype, qptrdiff>::value));
and Functor-Based Connections}
*/
-/*! \fn auto qNonConstOverload(T memberFunctionPointer)
+/*! \fn template <typename T> auto qNonConstOverload(T memberFunctionPointer)
\relates <QtGlobal>
\since 5.7
@@ -1431,13 +1434,6 @@ bool qSharedBuild() Q_DECL_NOTHROW
*/
/*!
- \macro Q_OS_ULTRIX
- \relates <QtGlobal>
-
- Defined on DEC Ultrix.
-*/
-
-/*!
\macro Q_OS_LINUX
\relates <QtGlobal>
@@ -1473,41 +1469,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>
@@ -1522,27 +1483,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>
@@ -2884,10 +2824,11 @@ QString QSysInfo::prettyProductName()
This function returns the same as QHostInfo::localHostName().
- \sa QHostInfo::localDomainName
+ \sa QHostInfo::localDomainName, machineUniqueId()
*/
QString QSysInfo::machineHostName()
{
+ // the hostname can change, so we can't cache it
#if defined(Q_OS_LINUX)
// gethostname(3) on Linux just calls uname(2), so do it ourselves
// and avoid a memcpy
@@ -2910,6 +2851,119 @@ QString QSysInfo::machineHostName()
}
#endif // QT_BOOTSTRAPPED
+enum {
+ UuidStringLen = sizeof("00000000-0000-0000-0000-000000000000") - 1
+};
+
+/*!
+ \since 5.10
+
+ Returns a unique ID for this machine, if one can be determined. If no
+ unique ID could be determined, this function returns an empty byte array.
+ Unlike machineHostName(), the value returned by this function is likely
+ globally unique.
+
+ A unique ID is useful in network operations to identify this machine for an
+ extended period of time, when the IP address could change or if this
+ machine could have more than one IP address. For example, the ID could be
+ used when communicating with a server or when storing device-specific data
+ in shared network storage.
+
+ Note that on some systems, this value will persist across reboots and on
+ some it will not. Applications should not blindly depend on this fact
+ without verifying the OS capabilities. In particular, on Linux systems,
+ this ID is usually permanent and it matches the D-Bus machine ID, except
+ for nodes without their own storage (replicated nodes).
+
+ \sa machineHostName(), bootUniqueId()
+*/
+QByteArray QSysInfo::machineUniqueId()
+{
+#ifdef Q_OS_BSD4
+ char uuid[UuidStringLen];
+ size_t uuidlen = sizeof(uuid);
+# ifdef KERN_HOSTUUID
+ int name[] = { CTL_KERN, KERN_HOSTUUID };
+ if (sysctl(name, sizeof name / sizeof name[0], &uuid, &uuidlen, nullptr, 0) == 0
+ && uuidlen == sizeof(uuid))
+ return QByteArray(uuid, uuidlen);
+
+# else
+ // Darwin: no fixed value, we need to search by name
+ if (sysctlbyname("kern.uuid", uuid, &uuidlen, nullptr, 0) == 0 && uuidlen == sizeof(uuid))
+ return QByteArray(uuid, uuidlen);
+# endif
+#elif defined(Q_OS_UNIX)
+ // The modern name on Linux is /etc/machine-id, but that path is
+ // unlikely to exist on non-Linux (non-systemd) systems. The old
+ // path is more than enough.
+ static const char fullfilename[] = "/usr/local/var/lib/dbus/machine-id";
+ const char *firstfilename = fullfilename + sizeof("/usr/local") - 1;
+ int fd = qt_safe_open(firstfilename, O_RDONLY);
+ if (fd == -1 && errno == ENOENT)
+ fd = qt_safe_open(fullfilename, O_RDONLY);
+
+ if (fd != -1) {
+ char buffer[32]; // 128 bits, hex-encoded
+ qint64 len = qt_safe_read(fd, buffer, sizeof(buffer));
+ qt_safe_close(fd);
+
+ if (len != -1)
+ return QByteArray(buffer, len);
+ }
+#elif defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
+ // Let's poke at the registry
+ HKEY key = NULL;
+ if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Cryptography", 0, KEY_READ, &key)
+ == ERROR_SUCCESS) {
+ wchar_t buffer[UuidStringLen + 1];
+ DWORD size = sizeof(buffer);
+ bool ok = (RegQueryValueEx(key, L"MachineGuid", NULL, NULL, (LPBYTE)buffer, &size) ==
+ ERROR_SUCCESS);
+ RegCloseKey(key);
+ if (ok)
+ return QStringView(buffer, (size - 1) / 2).toLatin1();
+ }
+#endif
+ return QByteArray();
+}
+
+/*!
+ \since 5.10
+
+ Returns a unique ID for this machine's boot, if one can be determined. If
+ no unique ID could be determined, this function returns an empty byte
+ array. This value is expected to change after every boot and can be
+ considered globally unique.
+
+ This function is currently only implemented for Linux and Apple operating
+ systems.
+
+ \sa machineUniqueId()
+*/
+QByteArray QSysInfo::bootUniqueId()
+{
+#ifdef Q_OS_LINUX
+ // use low-level API here for simplicity
+ int fd = qt_safe_open("/proc/sys/kernel/random/boot_id", O_RDONLY);
+ if (fd != -1) {
+ char uuid[UuidStringLen];
+ qint64 len = qt_safe_read(fd, uuid, sizeof(uuid));
+ qt_safe_close(fd);
+ if (len == UuidStringLen)
+ return QByteArray(uuid, UuidStringLen);
+ }
+#elif defined(Q_OS_DARWIN)
+ // "kern.bootsessionuuid" is only available by name
+ char uuid[UuidStringLen];
+ size_t uuidlen = sizeof(uuid);
+ if (sysctlbyname("kern.bootsessionuuid", uuid, &uuidlen, nullptr, 0) == 0
+ && uuidlen == sizeof(uuid))
+ return QByteArray(uuid, uuidlen);
+#endif
+ return QByteArray();
+};
+
/*!
\macro void Q_ASSERT(bool test)
\relates <QtGlobal>
@@ -3053,10 +3107,10 @@ QString QSysInfo::machineHostName()
*/
/*!
- \fn T *q_check_ptr(T *pointer)
+ \fn template <typename T> T *q_check_ptr(T *p)
\relates <QtGlobal>
- Uses Q_CHECK_PTR on \a pointer, then returns \a pointer.
+ Uses Q_CHECK_PTR on \a p, then returns \a p.
This can be used as an inline version of Q_CHECK_PTR.
*/
@@ -3551,7 +3605,7 @@ bool qunsetenv(const char *varName)
*/
/*!
- \fn qAsConst(T &t)
+ \fn template <typename T> qAsConst(T &t)
\relates <QtGlobal>
\since 5.7
@@ -3603,7 +3657,7 @@ bool qunsetenv(const char *varName)
*/
/*!
- \fn qAsConst(const T &&t)
+ \fn template <typename T> qAsConst(const T &&t)
\relates <QtGlobal>
\since 5.7
\overload
@@ -4015,43 +4069,6 @@ bool QInternal::activateCallbacks(Callback cb, void **parameters)
*/
/*!
- \macro Q_GLOBAL_STATIC(type, name)
- \internal
-
- Declares a global static variable with the given \a type and \a name.
-
- Use this macro to instantiate an object in a thread-safe way, creating
- a global pointer that can be used to refer to it.
-
- \warning This macro is subject to a race condition that can cause the object
- to be constructed twice. However, if this occurs, the second instance will
- be immediately deleted.
-
- See also
- \l{http://www.aristeia.com/publications.html}{"C++ and the perils of Double-Checked Locking"}
- by Scott Meyers and Andrei Alexandrescu.
-*/
-
-/*!
- \macro Q_GLOBAL_STATIC_WITH_ARGS(type, name, arguments)
- \internal
-
- Declares a global static variable with the specified \a type and \a name.
-
- Use this macro to instantiate an object using the \a arguments specified
- in a thread-safe way, creating a global pointer that can be used to refer
- to it.
-
- \warning This macro is subject to a race condition that can cause the object
- to be constructed twice. However, if this occurs, the second instance will
- be immediately deleted.
-
- See also
- \l{http://www.aristeia.com/publications.html}{"C++ and the perils of Double-Checked Locking"}
- by Scott Meyers and Andrei Alexandrescu.
-*/
-
-/*!
\macro QT_NAMESPACE
\internal
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index 4e7c1b59be..7873ab2b43 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -47,6 +47,7 @@
# include <utility>
#endif
#ifndef __ASSEMBLER__
+# include <assert.h>
# include <stddef.h>
#endif
@@ -105,6 +106,32 @@
# define Q_OF_MACH_O
#endif
+/*
+ Avoid "unused parameter" warnings
+*/
+#define Q_UNUSED(x) (void)x;
+
+#if defined(__cplusplus) && defined(Q_COMPILER_STATIC_ASSERT)
+# define Q_STATIC_ASSERT(Condition) static_assert(bool(Condition), #Condition)
+# define Q_STATIC_ASSERT_X(Condition, Message) static_assert(bool(Condition), Message)
+#elif defined(Q_COMPILER_STATIC_ASSERT)
+// C11 mode - using the _S version in case <assert.h> doesn't do the right thing
+# define Q_STATIC_ASSERT(Condition) _Static_assert(!!(Condition), #Condition)
+# define Q_STATIC_ASSERT_X(Condition, Message) _Static_assert(!!(Condition), Message)
+#else
+// C89 & C99 version
+# define Q_STATIC_ASSERT_PRIVATE_JOIN(A, B) Q_STATIC_ASSERT_PRIVATE_JOIN_IMPL(A, B)
+# define Q_STATIC_ASSERT_PRIVATE_JOIN_IMPL(A, B) A ## B
+# ifdef __COUNTER__
+# define Q_STATIC_ASSERT(Condition) \
+ typedef char Q_STATIC_ASSERT_PRIVATE_JOIN(q_static_assert_result, __COUNTER__) [(Condition) ? 1 : -1];
+# else
+# define Q_STATIC_ASSERT(Condition) \
+ typedef char Q_STATIC_ASSERT_PRIVATE_JOIN(q_static_assert_result, __LINE__) [(Condition) ? 1 : -1];
+# endif /* __COUNTER__ */
+# define Q_STATIC_ASSERT_X(Condition, Message) Q_STATIC_ASSERT(Condition)
+#endif
+
#ifdef __cplusplus
#include <algorithm>
@@ -219,6 +246,15 @@ typedef unsigned long long quint64; /* 64 bit unsigned */
typedef qint64 qlonglong;
typedef quint64 qulonglong;
+#ifndef __cplusplus
+// In C++ mode, we define below using QIntegerForSize template
+Q_STATIC_ASSERT_X(sizeof(ptrdiff_t) == sizeof(size_t), "Weird ptrdiff_t and size_t definitions");
+typedef ptrdiff_t qptrdiff;
+typedef ptrdiff_t qsizetype;
+typedef ptrdiff_t qintptr;
+typedef size_t quintptr;
+#endif
+
/*
Useful type definitions for Qt
*/
@@ -670,7 +706,7 @@ inline void qt_noop(void) {}
# define QT_CATCH(A) catch (A)
# define QT_THROW(A) throw A
# define QT_RETHROW throw
-Q_NORETURN Q_CORE_EXPORT void qTerminate() Q_DECL_NOTHROW;
+Q_NORETURN Q_DECL_COLD_FUNCTION Q_CORE_EXPORT void qTerminate() Q_DECL_NOTHROW;
# ifdef Q_COMPILER_NOEXCEPT
# define QT_TERMINATE_ON_EXCEPTION(expr) do { expr; } while (false)
# else
@@ -688,11 +724,6 @@ Q_CORE_EXPORT Q_DECL_CONST_FUNCTION bool qSharedBuild() Q_DECL_NOTHROW;
#endif
/*
- Avoid "unused parameter" warnings
-*/
-#define Q_UNUSED(x) (void)x;
-
-/*
Debugging and error handling
*/
@@ -718,11 +749,13 @@ Q_CORE_EXPORT Q_DECL_CONST_FUNCTION bool qSharedBuild() Q_DECL_NOTHROW;
#endif
class QString;
+Q_DECL_COLD_FUNCTION
Q_CORE_EXPORT QString qt_error_string(int errorCode = -1);
#ifndef Q_CC_MSVC
Q_NORETURN
#endif
+Q_DECL_COLD_FUNCTION
Q_CORE_EXPORT void qt_assert(const char *assertion, const char *file, int line) Q_DECL_NOTHROW;
#if !defined(Q_ASSERT)
@@ -740,6 +773,7 @@ Q_CORE_EXPORT void qt_assert(const char *assertion, const char *file, int line)
#ifndef Q_CC_MSVC
Q_NORETURN
#endif
+Q_DECL_COLD_FUNCTION
Q_CORE_EXPORT void qt_assert_x(const char *where, const char *what, const char *file, int line) Q_DECL_NOTHROW;
#if !defined(Q_ASSERT_X)
@@ -750,28 +784,8 @@ Q_CORE_EXPORT void qt_assert_x(const char *where, const char *what, const char *
# endif
#endif
-
-#ifdef Q_COMPILER_STATIC_ASSERT
-#define Q_STATIC_ASSERT(Condition) static_assert(bool(Condition), #Condition)
-#define Q_STATIC_ASSERT_X(Condition, Message) static_assert(bool(Condition), Message)
-#else
-// Intentionally undefined
-template <bool Test> class QStaticAssertFailure;
-template <> class QStaticAssertFailure<true> {};
-
-#define Q_STATIC_ASSERT_PRIVATE_JOIN(A, B) Q_STATIC_ASSERT_PRIVATE_JOIN_IMPL(A, B)
-#define Q_STATIC_ASSERT_PRIVATE_JOIN_IMPL(A, B) A ## B
-#ifdef __COUNTER__
-#define Q_STATIC_ASSERT(Condition) \
- enum {Q_STATIC_ASSERT_PRIVATE_JOIN(q_static_assert_result, __COUNTER__) = sizeof(QStaticAssertFailure<!!(Condition)>)}
-#else
-#define Q_STATIC_ASSERT(Condition) \
- enum {Q_STATIC_ASSERT_PRIVATE_JOIN(q_static_assert_result, __LINE__) = sizeof(QStaticAssertFailure<!!(Condition)>)}
-#endif /* __COUNTER__ */
-#define Q_STATIC_ASSERT_X(Condition, Message) Q_STATIC_ASSERT(Condition)
-#endif
-
Q_NORETURN Q_CORE_EXPORT void qt_check_pointer(const char *, int) Q_DECL_NOTHROW;
+Q_DECL_COLD_FUNCTION
Q_CORE_EXPORT void qBadAlloc();
#ifdef QT_NO_EXCEPTIONS
@@ -1138,7 +1152,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/qglobalstatic.qdoc b/src/corelib/global/qglobalstatic.qdoc
index 8c34739d38..63cc968d1c 100644
--- a/src/corelib/global/qglobalstatic.qdoc
+++ b/src/corelib/global/qglobalstatic.qdoc
@@ -368,7 +368,7 @@
*/
/*!
- \fn bool QGlobalStatic::isDestroyed() const
+ \fn template <typename T, T *(&innerFunction)(), QBasicAtomicInt &guard> bool QGlobalStatic<T, innerFunction, guard>::isDestroyed() const
This function returns \c true if the global static object has already
completed destruction (that is, if the destructor for the type has already
@@ -398,7 +398,7 @@
*/
/*!
- \fn bool QGlobalStatic::exists() const
+ \fn template <typename T, T *(&innerFunction)(), QBasicAtomicInt &guard> bool QGlobalStatic<T, innerFunction, guard>::exists() const
This function returns \c true if the global static object has already
completed initialization (that is, if the constructor for the type has
@@ -447,7 +447,7 @@
*/
/*!
- \fn QGlobalStatic::operator Type*()
+ \fn template <typename T, T *(&innerFunction)(), QBasicAtomicInt &guard> QGlobalStatic<T, innerFunction, guard>::operator Type*()
This function returns the address of the contents of this global static. If
the contents have not yet been created, they will be created thread-safely
@@ -480,7 +480,7 @@
*/
/*!
- \fn Type *QGlobalStatic::operator()()
+ \fn template <typename T, T *(&innerFunction)(), QBasicAtomicInt &guard> Type *QGlobalStatic<T, innerFunction, guard>::operator()()
\deprecated
This function returns the address of the contents of this global static. If
@@ -495,7 +495,7 @@
*/
/*!
- \fn Type *QGlobalStatic::operator->()
+ \fn template <typename T, T *(&innerFunction)(), QBasicAtomicInt &guard> Type *QGlobalStatic<T, innerFunction, guard>::operator->()
This function returns the address of the contents of this global static. If
the contents have not yet been created, they will be created thread-safely
@@ -508,7 +508,7 @@
*/
/*!
- \fn Type &QGlobalStatic::operator*()
+ \fn template <typename T, T *(&innerFunction)(), QBasicAtomicInt &guard> Type &QGlobalStatic<T, innerFunction, guard>::operator*()
This function returns a reference to the contents of this global static. If
the contents have not yet been created, they will be created thread-safely
diff --git a/src/corelib/global/qlogging.h b/src/corelib/global/qlogging.h
index ec21198784..16e01183bd 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) {}
@@ -97,7 +97,9 @@ public:
void noDebug(const char *, ...) const Q_ATTRIBUTE_FORMAT_PRINTF(2, 3)
{}
void info(const char *msg, ...) const Q_ATTRIBUTE_FORMAT_PRINTF(2, 3);
+ Q_DECL_COLD_FUNCTION
void warning(const char *msg, ...) const Q_ATTRIBUTE_FORMAT_PRINTF(2, 3);
+ Q_DECL_COLD_FUNCTION
void critical(const char *msg, ...) const Q_ATTRIBUTE_FORMAT_PRINTF(2, 3);
typedef const QLoggingCategory &(*CategoryFunction)();
@@ -106,14 +108,19 @@ public:
void debug(CategoryFunction catFunc, const char *msg, ...) const Q_ATTRIBUTE_FORMAT_PRINTF(3, 4);
void info(const QLoggingCategory &cat, const char *msg, ...) const Q_ATTRIBUTE_FORMAT_PRINTF(3, 4);
void info(CategoryFunction catFunc, const char *msg, ...) const Q_ATTRIBUTE_FORMAT_PRINTF(3, 4);
+ Q_DECL_COLD_FUNCTION
void warning(const QLoggingCategory &cat, const char *msg, ...) const Q_ATTRIBUTE_FORMAT_PRINTF(3, 4);
+ Q_DECL_COLD_FUNCTION
void warning(CategoryFunction catFunc, const char *msg, ...) const Q_ATTRIBUTE_FORMAT_PRINTF(3, 4);
+ Q_DECL_COLD_FUNCTION
void critical(const QLoggingCategory &cat, const char *msg, ...) const Q_ATTRIBUTE_FORMAT_PRINTF(3, 4);
+ Q_DECL_COLD_FUNCTION
void critical(CategoryFunction catFunc, const char *msg, ...) const Q_ATTRIBUTE_FORMAT_PRINTF(3, 4);
#ifndef Q_CC_MSVC
Q_NORETURN
#endif
+ Q_DECL_COLD_FUNCTION
void fatal(const char *msg, ...) const Q_DECL_NOTHROW Q_ATTRIBUTE_FORMAT_PRINTF(2, 3);
#ifndef QT_NO_DEBUG_STREAM
@@ -150,9 +157,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
@@ -179,8 +186,8 @@ private:
Q_CORE_EXPORT void qt_message_output(QtMsgType, const QMessageLogContext &context,
const QString &message);
-Q_CORE_EXPORT void qErrnoWarning(int code, const char *msg, ...);
-Q_CORE_EXPORT void qErrnoWarning(const char *msg, ...);
+Q_CORE_EXPORT Q_DECL_COLD_FUNCTION void qErrnoWarning(int code, const char *msg, ...);
+Q_CORE_EXPORT Q_DECL_COLD_FUNCTION void qErrnoWarning(const char *msg, ...);
#if QT_DEPRECATED_SINCE(5, 0)// deprecated. Use qInstallMessageHandler instead!
typedef void (*QtMsgHandler)(QtMsgType, const char *);
diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h
index 2a8345195d..2773992b47 100644
--- a/src/corelib/global/qnamespace.h
+++ b/src/corelib/global/qnamespace.h
@@ -243,7 +243,7 @@ public:
// size of a multi-variant string.
TextLongestVariant = 0x80000
-#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+#if QT_DEPRECATED_SINCE(5, 11) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
, TextBypassShaping = 0x100000
#endif
};
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/qnumeric_p.h b/src/corelib/global/qnumeric_p.h
index 37eddfa9b5..dd249f8cc8 100644
--- a/src/corelib/global/qnumeric_p.h
+++ b/src/corelib/global/qnumeric_p.h
@@ -163,6 +163,7 @@ Q_DECL_CONST_FUNCTION static inline bool qt_is_finite(float f)
return qnumeric_std_wrapper::isfinite(f);
}
+#ifndef Q_CLANG_QDOC
//
// Unsigned overflow math
//
@@ -355,7 +356,7 @@ inline bool mul_overflow(int v1, int v2, int *r)
return t > std::numeric_limits<int>::max() || t < std::numeric_limits<int>::min();
}
#endif
-
+#endif // Q_CLANG_QDOC
}
QT_END_NAMESPACE
diff --git a/src/corelib/global/qrandom.cpp b/src/corelib/global/qrandom.cpp
index 0ee6ac9f38..f5c01aeaa6 100644
--- a/src/corelib/global/qrandom.cpp
+++ b/src/corelib/global/qrandom.cpp
@@ -1285,20 +1285,56 @@ void QRandomGenerator::_fillRange(void *buffer, void *bufferEnd)
std::generate(begin, end, [this]() { return storage.engine()(); });
}
-#if defined(Q_OS_ANDROID) && (__ANDROID_API__ < 21)
-typedef QThreadStorage<QJNIObjectPrivate> AndroidRandomStorage;
-Q_GLOBAL_STATIC(AndroidRandomStorage, randomTLS)
+namespace {
+struct QRandEngine
+{
+ std::minstd_rand engine;
+ QRandEngine() : engine(1) {}
+
+ int generate()
+ {
+ std::minstd_rand::result_type v = engine();
+ if (std::numeric_limits<int>::max() != RAND_MAX)
+ v %= uint(RAND_MAX) + 1;
+
+ return int(v);
+ }
-#elif defined(Q_OS_UNIX) && !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && (_POSIX_THREAD_SAFE_FUNCTIONS - 0 > 0)
-using SeedStorageType = QtPrivate::FunctionPointer<decltype(&srand)>::Arguments::Car;
+ void seed(std::minstd_rand::result_type q)
+ {
+ engine.seed(q);
+ }
+};
+}
-typedef QThreadStorage<SeedStorageType *> SeedStorage;
-Q_GLOBAL_STATIC(SeedStorage, randTLS) // Thread Local Storage for seed value
+#if defined(QT_NO_THREAD) || defined(Q_OS_WIN)
+// On Windows srand() and rand() already use Thread-Local-Storage
+// to store the seed between calls
+static inline QRandEngine *randTLS()
+{
+ return nullptr;
+}
+#elif defined(Q_COMPILER_THREAD_LOCAL)
+static inline QRandEngine *randTLS()
+{
+ thread_local QRandEngine r;
+ return &r;
+}
+#else
+Q_GLOBAL_STATIC(QThreadStorage<QRandEngine>, g_randTLS)
+static inline QRandEngine *randTLS()
+{
+ auto tls = g_randTLS();
+ if (!tls)
+ return nullptr;
+ return &tls->localData();
+}
#endif
/*!
\relates <QtGlobal>
+ \deprecated
\since 4.2
Thread-safe version of the standard C++ \c srand() function.
@@ -1310,49 +1346,23 @@ Q_GLOBAL_STATIC(SeedStorage, randTLS) // Thread Local Storage for seed value
if two threads call qsrand(1) and subsequently call qrand(), the threads will get
the same random number sequence.
+ \note This function is deprecated. In new applications, use
+ QRandomGenerator instead.
+
\sa qrand(), QRandomGenerator
*/
void qsrand(uint seed)
{
-#if defined(Q_OS_ANDROID) && (__ANDROID_API__ < 21)
- if (randomTLS->hasLocalData()) {
- randomTLS->localData().callMethod<void>("setSeed", "(J)V", jlong(seed));
- return;
- }
-
- QJNIObjectPrivate random("java/util/Random",
- "(J)V",
- jlong(seed));
- if (!random.isValid()) {
+ auto prng = randTLS();
+ if (prng)
+ prng->seed(seed);
+ else
srand(seed);
- return;
- }
-
- randomTLS->setLocalData(random);
-#elif defined(Q_OS_UNIX) && !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && (_POSIX_THREAD_SAFE_FUNCTIONS - 0 > 0)
- SeedStorage *seedStorage = randTLS();
- if (seedStorage) {
- SeedStorageType *pseed = seedStorage->localData();
- if (!pseed)
- seedStorage->setLocalData(pseed = new SeedStorageType);
- *pseed = seed;
- } else {
- //global static seed storage should always exist,
- //except after being deleted by QGlobalStaticDeleter.
- //But since it still can be called from destructor of another
- //global static object, fallback to srand(seed)
- srand(seed);
- }
-#else
- // On Windows srand() and rand() already use Thread-Local-Storage
- // to store the seed between calls
- // this is also valid for QT_NO_THREAD
- srand(seed);
-#endif
}
/*!
\relates <QtGlobal>
+ \deprecated
\since 4.2
Thread-safe version of the standard C++ \c rand() function.
@@ -1366,52 +1376,18 @@ void qsrand(uint seed)
step is skipped, then the sequence will be pre-seeded with a constant
value.
- \sa qsrand(), QRandomGenerator
+ \note This function is deprecated. In new applications, use
+ QRandomGenerator instead.
+
+ \sa qrand(), QRandomGenerator
*/
int qrand()
{
-#if defined(Q_OS_ANDROID) && (__ANDROID_API__ < 21)
- AndroidRandomStorage *randomStorage = randomTLS();
- if (!randomStorage)
- return rand();
-
- if (randomStorage->hasLocalData()) {
- return randomStorage->localData().callMethod<jint>("nextInt",
- "(I)I",
- RAND_MAX);
- }
-
- QJNIObjectPrivate random("java/util/Random",
- "(J)V",
- jlong(1));
-
- if (!random.isValid())
- return rand();
-
- randomStorage->setLocalData(random);
- return random.callMethod<jint>("nextInt", "(I)I", RAND_MAX);
-#elif defined(Q_OS_UNIX) && !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && (_POSIX_THREAD_SAFE_FUNCTIONS - 0 > 0)
- SeedStorage *seedStorage = randTLS();
- if (seedStorage) {
- SeedStorageType *pseed = seedStorage->localData();
- if (!pseed) {
- seedStorage->setLocalData(pseed = new SeedStorageType);
- *pseed = 1;
- }
- return rand_r(pseed);
- } else {
- //global static seed storage should always exist,
- //except after being deleted by QGlobalStaticDeleter.
- //But since it still can be called from destructor of another
- //global static object, fallback to rand()
+ auto prng = randTLS();
+ if (prng)
+ return prng->generate();
+ else
return rand();
- }
-#else
- // On Windows srand() and rand() already use Thread-Local-Storage
- // to store the seed between calls
- // this is also valid for QT_NO_THREAD
- return rand();
-#endif
}
QT_END_NAMESPACE
diff --git a/src/corelib/global/qsysinfo.h b/src/corelib/global/qsysinfo.h
index 6b73a17dc5..a3fa0fcb27 100644
--- a/src/corelib/global/qsysinfo.h
+++ b/src/corelib/global/qsysinfo.h
@@ -240,6 +240,8 @@ QT_WARNING_POP
static QString prettyProductName();
static QString machineHostName();
+ static QByteArray machineUniqueId();
+ static QByteArray bootUniqueId();
};
#undef QT_SYSINFO_DEPRECATED_X
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..8f419a4a46 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()
@@ -772,7 +773,7 @@ int QDataStream::readBlock(char *data, int len)
}
/*!
- \fn QDataStream &QDataStream::operator>>(std::nullptr &ptr)
+ \fn QDataStream &QDataStream::operator>>(std::nullptr_t &ptr)
\since 5.9
\overload
@@ -1097,7 +1098,7 @@ int QDataStream::readRawData(char *s, int len)
*****************************************************************************/
/*!
- \fn QDataStream &QDataStream::operator<<(std::nullptr ptr)
+ \fn QDataStream &QDataStream::operator<<(std::nullptr_t ptr)
\since 5.9
\overload
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/qdebug.cpp b/src/corelib/io/qdebug.cpp
index 341400fd93..0d9a6c8749 100644
--- a/src/corelib/io/qdebug.cpp
+++ b/src/corelib/io/qdebug.cpp
@@ -121,15 +121,15 @@ using QtMiscUtils::fromHex;
*/
/*!
- \fn QDebug::QDebug(QtMsgType type)
+ \fn QDebug::QDebug(QtMsgType t)
- Constructs a debug stream that writes to the handler for the message type specified by \a type.
+ Constructs a debug stream that writes to the handler for the message type \a t.
*/
/*!
- \fn QDebug::QDebug(const QDebug &other)
+ \fn QDebug::QDebug(const QDebug &o)
- Constructs a copy of the \a other debug stream.
+ Constructs a copy of the other debug stream \a o.
*/
/*!
@@ -501,79 +501,79 @@ QDebug &QDebug::resetFormat()
*/
/*!
- \fn QDebug &QDebug::operator<<(signed short i)
+ \fn QDebug &QDebug::operator<<(signed short t)
- Writes the signed short integer, \a i, to the stream and returns a reference
+ Writes the signed short integer, \a t, to the stream and returns a reference
to the stream.
*/
/*!
- \fn QDebug &QDebug::operator<<(unsigned short i)
+ \fn QDebug &QDebug::operator<<(unsigned short t)
- Writes then unsigned short integer, \a i, to the stream and returns a
+ Writes then unsigned short integer, \a t, to the stream and returns a
reference to the stream.
*/
/*!
- \fn QDebug &QDebug::operator<<(signed int i)
+ \fn QDebug &QDebug::operator<<(signed int t)
- Writes the signed integer, \a i, to the stream and returns a reference
+ Writes the signed integer, \a t, to the stream and returns a reference
to the stream.
*/
/*!
- \fn QDebug &QDebug::operator<<(unsigned int i)
+ \fn QDebug &QDebug::operator<<(unsigned int t)
- Writes then unsigned integer, \a i, to the stream and returns a reference to
+ Writes then unsigned integer, \a t, to the stream and returns a reference to
the stream.
*/
/*!
- \fn QDebug &QDebug::operator<<(signed long l)
+ \fn QDebug &QDebug::operator<<(signed long t)
- Writes the signed long integer, \a l, to the stream and returns a reference
+ Writes the signed long integer, \a t, to the stream and returns a reference
to the stream.
*/
/*!
- \fn QDebug &QDebug::operator<<(unsigned long l)
+ \fn QDebug &QDebug::operator<<(unsigned long t)
- Writes then unsigned long integer, \a l, to the stream and returns a reference
+ Writes then unsigned long integer, \a t, to the stream and returns a reference
to the stream.
*/
/*!
- \fn QDebug &QDebug::operator<<(qint64 i)
+ \fn QDebug &QDebug::operator<<(qint64 t)
- Writes the signed 64-bit integer, \a i, to the stream and returns a reference
+ Writes the signed 64-bit integer, \a t, to the stream and returns a reference
to the stream.
*/
/*!
- \fn QDebug &QDebug::operator<<(quint64 i)
+ \fn QDebug &QDebug::operator<<(quint64 t)
- Writes then unsigned 64-bit integer, \a i, to the stream and returns a
+ Writes then unsigned 64-bit integer, \a t, to the stream and returns a
reference to the stream.
*/
/*!
- \fn QDebug &QDebug::operator<<(float f)
+ \fn QDebug &QDebug::operator<<(float t)
- Writes the 32-bit floating point number, \a f, to the stream and returns a
+ Writes the 32-bit floating point number, \a t, to the stream and returns a
reference to the stream.
*/
/*!
- \fn QDebug &QDebug::operator<<(double f)
+ \fn QDebug &QDebug::operator<<(double t)
- Writes the 64-bit floating point number, \a f, to the stream and returns a
+ Writes the 64-bit floating point number, \a t, to the stream and returns a
reference to the stream.
*/
/*!
- \fn QDebug &QDebug::operator<<(const char *s)
+ \fn QDebug &QDebug::operator<<(const char *t)
- Writes the '\\0'-terminated string, \a s, to the stream and returns a
+ Writes the '\\0'-terminated string, \a t, to the stream and returns a
reference to the stream. The string is never quoted nor transformed to the
output, but note that some QDebug backends might not be 8-bit clean.
*/
@@ -595,9 +595,9 @@ QDebug &QDebug::resetFormat()
*/
/*!
- \fn QDebug &QDebug::operator<<(const QString &s)
+ \fn QDebug &QDebug::operator<<(const QString &t)
- Writes the string, \a s, to the stream and returns a reference to the
+ Writes the string, \a t, to the stream and returns a reference to the
stream. Normally, QDebug prints the string inside quotes and transforms
non-printable characters to their Unicode values (\\u1234).
@@ -634,9 +634,9 @@ QDebug &QDebug::resetFormat()
*/
/*!
- \fn QDebug &QDebug::operator<<(const QStringRef &s)
+ \fn QDebug &QDebug::operator<<(const QStringRef &t)
- Writes the string, \a s, to the stream and returns a reference to the
+ Writes the string, \a t, to the stream and returns a reference to the
stream. Normally, QDebug prints the string inside quotes and transforms
non-printable characters to their Unicode values (\\u1234).
@@ -663,9 +663,9 @@ QDebug &QDebug::resetFormat()
*/
/*!
- \fn QDebug &QDebug::operator<<(QLatin1String s)
+ \fn QDebug &QDebug::operator<<(QLatin1String t)
- Writes the string, \a s, to the stream and returns a reference to the
+ Writes the string, \a t, to the stream and returns a reference to the
stream. Normally, QDebug prints the string inside quotes and transforms
non-printable characters to their Unicode values (\\u1234).
@@ -677,9 +677,9 @@ QDebug &QDebug::resetFormat()
*/
/*!
- \fn QDebug &QDebug::operator<<(const QByteArray &b)
+ \fn QDebug &QDebug::operator<<(const QByteArray &t)
- Writes the byte array, \a b, to the stream and returns a reference to the
+ Writes the byte array, \a t, to the stream and returns a reference to the
stream. Normally, QDebug prints the array inside quotes and transforms
control or non-US-ASCII characters to their C escape sequences (\\xAB). This
way, the output is always 7-bit clean and the string can be copied from the
@@ -716,9 +716,9 @@ QDebug &QDebug::resetFormat()
*/
/*!
- \fn QDebug &QDebug::operator<<(const void *p)
+ \fn QDebug &QDebug::operator<<(const void *t)
- Writes a pointer, \a p, to the stream and returns a reference to the stream.
+ Writes a pointer, \a t, to the stream and returns a reference to the stream.
*/
/*!
@@ -732,99 +732,99 @@ QDebug &QDebug::resetFormat()
*/
/*!
- \fn QDebug operator<<(QDebug stream, const QList<T> &list)
+ \fn template <class T> QDebug operator<<(QDebug debug, const QList<T> &list)
\relates QDebug
- Writes the contents of \a list to \a stream. \c T needs to
+ Writes the contents of \a list to \a debug. \c T needs to
support streaming into QDebug.
*/
/*!
- \fn QDebug operator<<(QDebug stream, const std::list<T, Alloc> &list)
+ \fn template <typename T, typename Alloc> QDebug operator<<(QDebug debug, const std::list<T, Alloc> &vec)
\relates QDebug
\since 5.7
- Writes the contents of \a list to \a stream. \c T needs to
+ Writes the contents of list \a vec to \a debug. \c T needs to
support streaming into QDebug.
*/
/*!
- \fn QDebug operator<<(QDebug stream, const QVector<T> &vector)
+ \fn template <typename T> QDebug operator<<(QDebug debug, const QVector<T> &vec)
\relates QDebug
- Writes the contents of \a vector to \a stream. \c T needs to
+ Writes the contents of vector \a vec to \a debug. \c T needs to
support streaming into QDebug.
*/
/*!
- \fn QDebug operator<<(QDebug stream, const std::vector<T, Alloc> &vector)
+ \fn template <typename T, typename Alloc> QDebug operator<<(QDebug debug, const std::vector<T, Alloc> &vec)
\relates QDebug
\since 5.7
- Writes the contents of \a vector to \a stream. \c T needs to
+ Writes the contents of vector \a vec to \a debug. \c T needs to
support streaming into QDebug.
*/
/*!
- \fn QDebug operator<<(QDebug stream, const QSet<T> &set)
+ \fn template <typename T> QDebug operator<<(QDebug debug, const QSet<T> &set)
\relates QDebug
- Writes the contents of \a set to \a stream. \c T needs to
+ Writes the contents of \a set to \a debug. \c T needs to
support streaming into QDebug.
*/
/*!
- \fn QDebug operator<<(QDebug stream, const QMap<Key, T> &map)
+ \fn template <class Key, class T> QDebug operator<<(QDebug debug, const QMap<Key, T> &map)
\relates QDebug
- Writes the contents of \a map to \a stream. Both \c Key and
+ Writes the contents of \a map to \a debug. Both \c Key and
\c T need to support streaming into QDebug.
*/
/*!
- \fn QDebug operator<<(QDebug stream, const std::map<Key, T, Compare, Alloc> &map)
+ \fn template <typename Key, typename T, typename Compare, typename Alloc> QDebug operator<<(QDebug debug, const std::map<Key, T, Compare, Alloc> &map)
\relates QDebug
\since 5.7
- Writes the contents of \a map to \a stream. Both \c Key and
+ Writes the contents of \a map to \a debug. Both \c Key and
\c T need to support streaming into QDebug.
*/
/*!
- \fn QDebug operator<<(QDebug stream, const std::multimap<Key, T, Compare, Alloc> &map)
+ \fn template <typename Key, typename T, typename Compare, typename Alloc> QDebug operator<<(QDebug debug, const std::multimap<Key, T, Compare, Alloc> &map)
\relates QDebug
\since 5.7
- Writes the contents of \a map to \a stream. Both \c Key and
+ Writes the contents of \a map to \a debug. Both \c Key and
\c T need to support streaming into QDebug.
*/
/*!
- \fn QDebug operator<<(QDebug stream, const QHash<Key, T> &hash)
+ \fn template <class Key, class T> QDebug operator<<(QDebug debug, const QHash<Key, T> &hash)
\relates QDebug
- Writes the contents of \a hash to \a stream. Both \c Key and
+ Writes the contents of \a hash to \a debug. Both \c Key and
\c T need to support streaming into QDebug.
*/
/*!
- \fn QDebug operator<<(QDebug stream, const QPair<T1, T2> &pair)
+ \fn template <class T1, class T2> QDebug operator<<(QDebug debug, const QPair<T1, T2> &pair)
\relates QDebug
- Writes the contents of \a pair to \a stream. Both \c T1 and
+ Writes the contents of \a pair to \a debug. Both \c T1 and
\c T2 need to support streaming into QDebug.
*/
/*!
- \fn QDebug operator<<(QDebug stream, const QFlags<T> &flag)
+ \fn template<typename T> QDebug operator<<(QDebug debug, const QFlags<T> &flags)
\relates QDebug
\since 4.7
- Writes \a flag to \a stream.
+ Writes \a flags to \a debug.
*/
/*!
- \fn QDebug operator<<(QDebug debug, const QSharedPointer<T> &ptr)
+ \fn template<typename T> QDebug operator<<(QDebug debug, const QSharedPointer<T> &ptr)
\relates QSharedPointer
\since 5.7
@@ -835,6 +835,11 @@ QDebug &QDebug::resetFormat()
*/
/*!
+ \fn QDebug &QDebug::operator<<(std::nullptr_t)
+ \internal
+ */
+
+/*!
\class QDebugStateSaver
\inmodule QtCore
\brief Convenience class for custom QDebug operators
diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp
index 6d144cb65d..520f98b18f 100644
--- a/src/corelib/io/qdir.cpp
+++ b/src/corelib/io/qdir.cpp
@@ -2087,6 +2087,7 @@ bool QDir::match(const QString &filter, const QString &fileName)
#endif // QT_NO_REGEXP
/*!
+ \internal
Returns \a path with redundant directory separators removed,
and "."s and ".."s resolved (as far as possible).
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/qfilesystemiterator_unix.cpp b/src/corelib/io/qfilesystemiterator_unix.cpp
index 0d1438f137..a9acf542d4 100644
--- a/src/corelib/io/qfilesystemiterator_unix.cpp
+++ b/src/corelib/io/qfilesystemiterator_unix.cpp
@@ -77,12 +77,19 @@ bool QFileSystemIterator::advance(QFileSystemEntry &fileEntry, QFileSystemMetaDa
if (!dir)
return false;
- dirEntry = QT_READDIR(dir);
+ for (;;) {
+ dirEntry = QT_READDIR(dir);
- if (dirEntry) {
- fileEntry = QFileSystemEntry(nativePath + QByteArray(dirEntry->d_name), QFileSystemEntry::FromNativePath());
- metaData.fillFromDirEnt(*dirEntry);
- return true;
+ if (dirEntry) {
+ // process entries with correct UTF-8 names only
+ if (QFile::encodeName(QFile::decodeName(dirEntry->d_name)) == dirEntry->d_name) {
+ fileEntry = QFileSystemEntry(nativePath + QByteArray(dirEntry->d_name), QFileSystemEntry::FromNativePath());
+ metaData.fillFromDirEnt(*dirEntry);
+ return true;
+ }
+ } else {
+ break;
+ }
}
lastError = errno;
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.cpp b/src/corelib/io/qfsfileengine.cpp
index b7a5440224..dc41197bd7 100644
--- a/src/corelib/io/qfsfileengine.cpp
+++ b/src/corelib/io/qfsfileengine.cpp
@@ -915,11 +915,15 @@ bool QFSFileEngine::supportsExtension(Extension extension) const
For Unix, the list contains just the root path "/".
*/
-/*! \fn QString QFSFileEngine::fileName(FileName file) const
+/*! \fn QString QFSFileEngine::fileName(QAbstractFileEngine::FileName file) const
\reimp
*/
-/*! \fn bool QFSFileEngine::setFileTime(const QDateTime &newDate, FileTime time)
+/*! \fn bool QFSFileEngine::setFileTime(const QDateTime &newDate, QAbstractFileEngine::FileTime time)
+ \reimp
+*/
+
+/*! \fn QDateTime QFSFileEngine::fileTime(QAbstractFileEngine::FileTime time) const
\reimp
*/
@@ -945,7 +949,7 @@ bool QFSFileEngine::supportsExtension(Extension extension) const
\reimp
*/
-/*! \fn uint QFSFileEngine::ownerId(FileOwner own) const
+/*! \fn uint QFSFileEngine::ownerId(QAbstractFileEngine::FileOwner own) const
In Unix, if stat() is successful, the \c uid is returned if
\a own is the owner. Otherwise the \c gid is returned. If stat()
is unsuccessful, -2 is reuturned.
@@ -953,7 +957,7 @@ bool QFSFileEngine::supportsExtension(Extension extension) const
For Windows, -2 is always returned.
*/
-/*! \fn QString QFSFileEngine::owner(FileOwner own) const
+/*! \fn QString QFSFileEngine::owner(QAbstractFileEngine::FileOwner own) const
\reimp
*/
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 faef84cbe2..16ba161b75 100644
--- a/src/corelib/io/qfsfileengine_p.h
+++ b/src/corelib/io/qfsfileengine_p.h
@@ -71,52 +71,52 @@ 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;
virtual bool isUnnamedFile() const
{ return false; }
- 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/qlockfile.cpp b/src/corelib/io/qlockfile.cpp
index 129cf01b63..aa84ce6bc1 100644
--- a/src/corelib/io/qlockfile.cpp
+++ b/src/corelib/io/qlockfile.cpp
@@ -56,6 +56,8 @@ struct LockFileInfo
qint64 pid;
QString appname;
QString hostname;
+ QByteArray hostid;
+ QByteArray bootid;
};
}
@@ -331,13 +333,15 @@ QByteArray QLockFilePrivate::lockFileContents() const
// Use operator% from the fast builder to avoid multiple memory allocations.
return QByteArray::number(QCoreApplication::applicationPid()) % '\n'
% processNameByPid(QCoreApplication::applicationPid()).toUtf8() % '\n'
- % machineName().toUtf8() % '\n';
+ % machineName().toUtf8() % '\n'
+ % QSysInfo::machineUniqueId() % '\n'
+ % QSysInfo::bootUniqueId() % '\n';
}
static bool getLockInfo_helper(const QString &fileName, LockFileInfo *info)
{
QFile reader(fileName);
- if (!reader.open(QIODevice::ReadOnly))
+ if (!reader.open(QIODevice::ReadOnly | QIODevice::Text))
return false;
QByteArray pidLine = reader.readLine();
@@ -349,9 +353,17 @@ static bool getLockInfo_helper(const QString &fileName, LockFileInfo *info)
QByteArray hostNameLine = reader.readLine();
hostNameLine.chop(1);
+ // prior to Qt 5.10, only the lines above were recorded
+ QByteArray hostId = reader.readLine();
+ hostId.chop(1);
+ QByteArray bootId = reader.readLine();
+ bootId.chop(1);
+
bool ok;
info->appname = QString::fromUtf8(appNameLine);
info->hostname = QString::fromUtf8(hostNameLine);
+ info->hostid = hostId;
+ info->bootid = bootId;
info->pid = pidLine.toLongLong(&ok);
return ok && info->pid > 0;
}
@@ -360,7 +372,20 @@ bool QLockFilePrivate::isApparentlyStale() const
{
LockFileInfo info;
if (getLockInfo_helper(fileName, &info)) {
- if (info.hostname.isEmpty() || info.hostname == machineName()) {
+ bool sameHost = info.hostname.isEmpty() || info.hostname == machineName();
+ if (!info.hostid.isEmpty()) {
+ // Override with the host ID, if we know it.
+ QByteArray ourHostId = QSysInfo::machineUniqueId();
+ if (!ourHostId.isEmpty())
+ sameHost = (ourHostId == info.hostid);
+ }
+
+ if (sameHost) {
+ if (!info.bootid.isEmpty()) {
+ // If we've rebooted, then the lock is definitely stale.
+ if (info.bootid != QSysInfo::bootUniqueId())
+ return true;
+ }
if (!isProcessRunning(info.pid, info.appname))
return true;
}
diff --git a/src/corelib/io/qlockfile_p.h b/src/corelib/io/qlockfile_p.h
index b41dfb38ad..5b69347206 100644
--- a/src/corelib/io/qlockfile_p.h
+++ b/src/corelib/io/qlockfile_p.h
@@ -55,7 +55,10 @@
#include <QtCore/qlockfile.h>
#include <QtCore/qfile.h>
+#include <qplatformdefs.h>
+
#ifdef Q_OS_WIN
+#include <io.h>
#include <qt_windows.h>
#endif
@@ -96,6 +99,19 @@ public:
int staleLockTime; // "int milliseconds" is big enough for 24 days
QLockFile::LockError lockError;
bool isLocked;
+
+ static int getLockFileHandle(QLockFile *f)
+ {
+ int fd;
+#ifdef Q_OS_WIN
+ // Use of this function on Windows WILL leak a file descriptor.
+ fd = _open_osfhandle(intptr_t(f->d_func()->fileHandle), 0);
+#else
+ fd = f->d_func()->fileHandle;
+#endif
+ QT_LSEEK(fd, 0, SEEK_SET);
+ return fd;
+ }
};
QT_END_NAMESPACE
diff --git a/src/corelib/io/qlockfile_unix.cpp b/src/corelib/io/qlockfile_unix.cpp
index fc01f83e80..418b7d22ba 100644
--- a/src/corelib/io/qlockfile_unix.cpp
+++ b/src/corelib/io/qlockfile_unix.cpp
@@ -147,7 +147,7 @@ static bool setNativeLocks(int fd)
QLockFile::LockError QLockFilePrivate::tryLock_sys()
{
const QByteArray lockFileName = QFile::encodeName(fileName);
- const int fd = qt_safe_open(lockFileName.constData(), O_WRONLY | O_CREAT | O_EXCL, 0666);
+ const int fd = qt_safe_open(lockFileName.constData(), O_RDWR | O_CREAT | O_EXCL, 0666);
if (fd < 0) {
switch (errno) {
case EEXIST:
diff --git a/src/corelib/io/qlockfile_win.cpp b/src/corelib/io/qlockfile_win.cpp
index de64ec0432..6b8028460c 100644
--- a/src/corelib/io/qlockfile_win.cpp
+++ b/src/corelib/io/qlockfile_win.cpp
@@ -68,7 +68,7 @@ QLockFile::LockError QLockFilePrivate::tryLock_sys()
#ifndef Q_OS_WINRT
SECURITY_ATTRIBUTES securityAtts = { sizeof(SECURITY_ATTRIBUTES), NULL, FALSE };
HANDLE fh = CreateFile((const wchar_t*)fileEntry.nativeFilePath().utf16(),
- GENERIC_WRITE,
+ GENERIC_READ | GENERIC_WRITE,
dwShareMode,
&securityAtts,
CREATE_NEW, // error if already exists
@@ -76,7 +76,7 @@ QLockFile::LockError QLockFilePrivate::tryLock_sys()
NULL);
#else // !Q_OS_WINRT
HANDLE fh = CreateFile2((const wchar_t*)fileEntry.nativeFilePath().utf16(),
- GENERIC_WRITE,
+ GENERIC_READ | GENERIC_WRITE,
dwShareMode,
CREATE_NEW, // error if already exists
NULL);
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.cpp b/src/corelib/io/qprocess.cpp
index 64a59bc2c3..2ee680a7c6 100644
--- a/src/corelib/io/qprocess.cpp
+++ b/src/corelib/io/qprocess.cpp
@@ -1094,10 +1094,9 @@ bool QProcessPrivate::_q_canReadStandardError()
*/
bool QProcessPrivate::_q_canWrite()
{
- if (stdinChannel.notifier)
- stdinChannel.notifier->setEnabled(false);
-
if (writeBuffer.isEmpty()) {
+ if (stdinChannel.notifier)
+ stdinChannel.notifier->setEnabled(false);
#if defined QPROCESS_DEBUG
qDebug("QProcessPrivate::canWrite(), not writing anything (empty write buffer).");
#endif
@@ -1106,10 +1105,10 @@ bool QProcessPrivate::_q_canWrite()
const bool writeSucceeded = writeToStdin();
- if (stdinChannel.notifier && !writeBuffer.isEmpty())
- stdinChannel.notifier->setEnabled(true);
if (writeBuffer.isEmpty() && stdinChannel.closed)
closeWriteChannel();
+ else if (stdinChannel.notifier)
+ stdinChannel.notifier->setEnabled(!writeBuffer.isEmpty());
return writeSucceeded;
}
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 8da6d6b16e..6ab806d9fe 100644
--- a/src/corelib/io/qprocess_win.cpp
+++ b/src/corelib/io/qprocess_win.cpp
@@ -114,9 +114,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 31f02e977d..35a0de4fb7 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 &section, 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/qstandardpaths_unix.cpp b/src/corelib/io/qstandardpaths_unix.cpp
index d06778e2a1..e49edd9a40 100644
--- a/src/corelib/io/qstandardpaths_unix.cpp
+++ b/src/corelib/io/qstandardpaths_unix.cpp
@@ -170,7 +170,7 @@ QString QStandardPaths::writableLocation(StandardLocation type)
break;
}
-#ifndef QT_BOOTSTRAPPED
+#if QT_CONFIG(regularexpression)
// http://www.freedesktop.org/wiki/Software/xdg-user-dirs
QString xdgConfigHome = QFile::decodeName(qgetenv("XDG_CONFIG_HOME"));
if (xdgConfigHome.isEmpty())
@@ -232,7 +232,7 @@ QString QStandardPaths::writableLocation(StandardLocation type)
}
}
}
-#endif
+#endif // QT_CONFIG(regularexpression)
QString path;
switch (type) {
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 c2d31e7677..7664b77d81 100644
--- a/src/corelib/io/qstorageinfo_unix.cpp
+++ b/src/corelib/io/qstorageinfo_unix.cpp
@@ -45,6 +45,7 @@
#include <QtCore/qtextstream.h>
#include <QtCore/private/qcore_unix_p.h>
+#include <QtCore/private/qlocale_tools_p.h>
#include <errno.h>
#include <sys/stat.h>
@@ -128,6 +129,7 @@ public:
inline QByteArray fileSystemType() const;
inline QByteArray device() const;
inline QByteArray options() const;
+ inline QByteArray subvolume() const;
private:
#if defined(Q_OS_BSD4)
QT_STATFSBUF *stat_buf;
@@ -143,9 +145,36 @@ private:
QByteArray m_device;
QByteArray m_options;
#elif defined(Q_OS_LINUX) || defined(Q_OS_HURD)
+ struct mountinfoent : public mntent {
+ // Details from proc(5) section from /proc/<pid>/mountinfo:
+ //(1) mount ID: a unique ID for the mount (may be reused after umount(2)).
+ int mount_id;
+ //(2) parent ID: the ID of the parent mount (or of self for the top of the mount tree).
+// int parent_id;
+ //(3) major:minor: the value of st_dev for files on this filesystem (see stat(2)).
+// dev_t rdev;
+ //(4) root: the pathname of the directory in the filesystem which forms the root of this mount.
+ char *subvolume;
+ //(5) mount point: the pathname of the mount point relative to the process's root directory.
+// char *mnt_dir; // in mntent
+ //(6) mount options: per-mount options.
+// char *mnt_opts; // in mntent
+ //(7) optional fields: zero or more fields of the form "tag[:value]"; see below.
+// int flags;
+ //(8) separator: the end of the optional fields is marked by a single hyphen.
+
+ //(9) filesystem type: the filesystem type in the form "type[.subtype]".
+// char *mnt_type; // in mntent
+ //(10) mount source: filesystem-specific information or "none".
+// char *mnt_fsname; // in mntent
+ //(11) super options: per-superblock options.
+ char *superopts;
+ };
+
FILE *fp;
- mntent mnt;
QByteArray buffer;
+ mountinfoent mnt;
+ bool usingMountinfo;
#elif defined(Q_OS_HAIKU)
BVolumeRoster m_volumeRoster;
@@ -246,6 +275,10 @@ inline QByteArray QStorageIterator::options() const
return QByteArray();
}
+inline QByteArray QStorageIterator::subvolume() const
+{
+ return QByteArray();
+}
#elif defined(Q_OS_SOLARIS)
inline QStorageIterator::QStorageIterator()
@@ -262,7 +295,7 @@ inline QStorageIterator::~QStorageIterator()
inline bool QStorageIterator::isValid() const
{
- return fp != Q_NULLPTR;
+ return fp != nullptr;
}
inline bool QStorageIterator::next()
@@ -285,6 +318,10 @@ inline QByteArray QStorageIterator::device() const
return QByteArray(mnt.mnt_mntopts);
}
+inline QByteArray QStorageIterator::subvolume() const
+{
+ return QByteArray();
+}
#elif defined(Q_OS_ANDROID)
inline QStorageIterator::QStorageIterator()
@@ -340,6 +377,10 @@ inline QByteArray QStorageIterator::options() const
return m_options;
}
+inline QByteArray QStorageIterator::subvolume() const
+{
+ return QByteArray();
+}
#elif defined(Q_OS_LINUX) || defined(Q_OS_HURD)
static const int bufferSize = 1024; // 2 paths (mount point+device) and metainfo;
@@ -348,23 +389,158 @@ static const int bufferSize = 1024; // 2 paths (mount point+device) and metainfo
inline QStorageIterator::QStorageIterator() :
buffer(QByteArray(bufferSize, 0))
{
- fp = ::setmntent(_PATH_MOUNTED, "r");
+ fp = nullptr;
+
+#ifdef Q_OS_LINUX
+ // first, try to open /proc/self/mountinfo, which has more details
+ fp = ::fopen("/proc/self/mountinfo", "re");
+#endif
+ if (fp) {
+ usingMountinfo = true;
+ } else {
+ usingMountinfo = false;
+ fp = ::setmntent(_PATH_MOUNTED, "r");
+ }
}
inline QStorageIterator::~QStorageIterator()
{
- if (fp)
- ::endmntent(fp);
+ if (fp) {
+ if (usingMountinfo)
+ ::fclose(fp);
+ else
+ ::endmntent(fp);
+ }
}
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;
+ mnt.subvolume = nullptr;
+ mnt.superopts = nullptr;
+ if (!usingMountinfo)
+ return ::getmntent_r(fp, &mnt, buffer.data(), buffer.size()) != nullptr;
+
+ // Helper function to parse paths that the kernel inserts escape sequences
+ // for. The unescaped string is left at \a src and is properly
+ // NUL-terminated. Returns a pointer to the delimiter that terminated the
+ // path, or nullptr if it failed.
+ auto parseMangledPath = [](char *src) {
+ // The kernel escapes with octal the following characters:
+ // space ' ', tab '\t', backslask '\\', and newline '\n'
+ char *dst = src;
+ while (*src) {
+ switch (*src) {
+ case ' ':
+ // Unescaped space: end of the field.
+ *dst = '\0';
+ return src;
+
+ default:
+ *dst++ = *src++;
+ break;
+
+ case '\\':
+ // It always uses exactly three octal characters.
+ ++src;
+ char c = (*src++ - '0') << 6;
+ c |= (*src++ - '0') << 3;
+ c |= (*src++ - '0');
+ *dst++ = c;
+ break;
+ }
+ }
+
+ // Found a NUL before the end of the field.
+ src = nullptr;
+ return src;
+ };
+
+ char *ptr = buffer.data();
+ if (fgets(ptr, buffer.size(), fp) == nullptr)
+ return false;
+
+ size_t len = strlen(buffer.data());
+ if (len == 0)
+ return false;
+ if (ptr[len - 1] == '\n')
+ ptr[len - 1] = '\0';
+
+ // parse the line
+ bool ok;
+ mnt.mnt_freq = 0;
+ mnt.mnt_passno = 0;
+
+ mnt.mount_id = qstrtoll(ptr, const_cast<const char **>(&ptr), 10, &ok);
+ if (!ptr || !ok)
+ return false;
+
+ int parent_id = qstrtoll(ptr, const_cast<const char **>(&ptr), 10, &ok);
+ Q_UNUSED(parent_id);
+ if (!ptr || !ok)
+ return false;
+
+ int rdevmajor = qstrtoll(ptr, const_cast<const char **>(&ptr), 10, &ok);
+ if (!ptr || !ok)
+ return false;
+ if (*ptr != ':')
+ return false;
+ int rdevminor = qstrtoll(ptr + 1, const_cast<const char **>(&ptr), 10, &ok);
+ if (!ptr || !ok)
+ return false;
+ Q_UNUSED(rdevmajor);
+ Q_UNUSED(rdevminor);
+
+ if (*ptr != ' ')
+ return false;
+
+ mnt.subvolume = ++ptr;
+ ptr = parseMangledPath(ptr);
+ if (!ptr)
+ return false;
+
+ // unset a subvolume of "/" -- it's not a *sub* volume
+ if (mnt.subvolume + 1 == ptr)
+ *mnt.subvolume = '\0';
+
+ mnt.mnt_dir = ++ptr;
+ ptr = parseMangledPath(ptr);
+ if (!ptr)
+ return false;
+
+ mnt.mnt_opts = ++ptr;
+ ptr = strchr(ptr, ' ');
+ if (!ptr)
+ return false;
+
+ // we don't parse the flags, so just find the separator
+ if (char *const dashed = strstr(ptr, " - ")) {
+ *ptr = '\0';
+ ptr = dashed + strlen(" - ") - 1;
+ } else {
+ return false;
+ }
+
+ mnt.mnt_type = ++ptr;
+ ptr = strchr(ptr, ' ');
+ if (!ptr)
+ return false;
+ *ptr = '\0';
+
+ mnt.mnt_fsname = ++ptr;
+ ptr = parseMangledPath(ptr);
+ if (!ptr)
+ return false;
+
+ mnt.superopts = ++ptr;
+ ptr += strcspn(ptr, " \n");
+ *ptr = '\0';
+
+ return true;
}
inline QString QStorageIterator::rootPath() const
@@ -384,9 +560,28 @@ inline QByteArray QStorageIterator::device() const
inline QByteArray QStorageIterator::options() const
{
+ // Merge the two options, starting with the superblock options and letting
+ // the per-mount options override.
+ const char *superopts = mnt.superopts;
+
+ // Both mnt_opts and superopts start with "ro" or "rw", so we can skip the
+ // superblock's field (see show_mountinfo() in fs/proc_namespace.c).
+ if (superopts && superopts[0] == 'r') {
+ if (superopts[2] == '\0') // no other superopts besides "ro" / "rw"?
+ superopts = nullptr;
+ else if (superopts[2] == ',')
+ superopts += 3;
+ }
+
+ if (superopts)
+ return QByteArray(superopts) + ',' + mnt.mnt_opts;
return QByteArray(mnt.mnt_opts);
}
+inline QByteArray QStorageIterator::subvolume() const
+{
+ return QByteArray(mnt.subvolume);
+}
#elif defined(Q_OS_HAIKU)
inline QStorageIterator::QStorageIterator()
{
@@ -449,6 +644,10 @@ inline QByteArray QStorageIterator::options() const
return QByteArray();
}
+inline QByteArray QStorageIterator::subvolume() const
+{
+ return QByteArray();
+}
#else
inline QStorageIterator::QStorageIterator()
@@ -489,31 +688,11 @@ inline QByteArray QStorageIterator::options() const
return QByteArray();
}
-#endif
-
-static QByteArray extractSubvolume(const QStorageIterator &it)
+inline QByteArray QStorageIterator::subvolume() const
{
-#ifdef Q_OS_LINUX
- if (it.fileSystemType() == "btrfs") {
- const QByteArrayList opts = it.options().split(',');
- QByteArray id;
- for (const QByteArray &opt : opts) {
- static const char subvol[] = "subvol=";
- static const char subvolid[] = "subvolid=";
- if (opt.startsWith(subvol))
- return std::move(opt).mid(strlen(subvol));
- if (opt.startsWith(subvolid))
- id = std::move(opt).mid(strlen(subvolid));
- }
-
- // if we didn't find the subvolume name, return the subvolume ID
- return id;
- }
-#else
- Q_UNUSED(it);
-#endif
return QByteArray();
}
+#endif
void QStorageInfoPrivate::initRootPath()
{
@@ -541,7 +720,7 @@ void QStorageInfoPrivate::initRootPath()
rootPath = mountDir;
device = it.device();
fileSystemType = fsName;
- subvolume = extractSubvolume(it);
+ subvolume = it.subvolume();
}
}
}
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..7e1ab851d7 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)
@@ -2686,6 +2686,7 @@ bool QAbstractItemModel::decodeData(int row, int column, const QModelIndex &pare
void QAbstractItemModel::beginInsertRows(const QModelIndex &parent, int first, int last)
{
Q_ASSERT(first >= 0);
+ Q_ASSERT(first <= rowCount(parent)); // == is allowed, to insert at the end
Q_ASSERT(last >= first);
Q_D(QAbstractItemModel);
d->changes.push(QAbstractItemModelPrivate::Change(parent, first, last));
@@ -2741,6 +2742,7 @@ void QAbstractItemModel::beginRemoveRows(const QModelIndex &parent, int first, i
{
Q_ASSERT(first >= 0);
Q_ASSERT(last >= first);
+ Q_ASSERT(last < rowCount(parent));
Q_D(QAbstractItemModel);
d->changes.push(QAbstractItemModelPrivate::Change(parent, first, last));
emit rowsAboutToBeRemoved(parent, first, last, QPrivateSignal());
@@ -2987,6 +2989,7 @@ void QAbstractItemModel::endMoveRows()
void QAbstractItemModel::beginInsertColumns(const QModelIndex &parent, int first, int last)
{
Q_ASSERT(first >= 0);
+ Q_ASSERT(first <= columnCount(parent)); // == is allowed, to insert at the end
Q_ASSERT(last >= first);
Q_D(QAbstractItemModel);
d->changes.push(QAbstractItemModelPrivate::Change(parent, first, last));
@@ -3043,6 +3046,7 @@ void QAbstractItemModel::beginRemoveColumns(const QModelIndex &parent, int first
{
Q_ASSERT(first >= 0);
Q_ASSERT(last >= first);
+ Q_ASSERT(last < columnCount(parent));
Q_D(QAbstractItemModel);
d->changes.push(QAbstractItemModelPrivate::Change(parent, first, last));
emit columnsAboutToBeRemoved(parent, first, last, QPrivateSignal());
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.cpp b/src/corelib/itemmodels/qitemselectionmodel.cpp
index 59a10e9057..9af4fd9133 100644
--- a/src/corelib/itemmodels/qitemselectionmodel.cpp
+++ b/src/corelib/itemmodels/qitemselectionmodel.cpp
@@ -218,13 +218,15 @@ QT_BEGIN_NAMESPACE
*/
bool QItemSelectionRange::intersects(const QItemSelectionRange &other) const
{
- return (isValid() && other.isValid()
- && parent() == other.parent()
- && model() == other.model()
+ // isValid() and parent() last since they are more expensive
+ return (model() == other.model()
&& ((top() <= other.top() && bottom() >= other.top())
|| (top() >= other.top() && top() <= other.bottom()))
&& ((left() <= other.left() && right() >= other.left())
- || (left() >= other.left() && left() <= other.right())));
+ || (left() >= other.left() && left() <= other.right()))
+ && parent() == other.parent()
+ && isValid() && other.isValid()
+ );
}
/*!
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 7dad892606..c70fbaf63b 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;
@@ -1857,6 +1857,9 @@ void QSortFilterProxyModel::setSourceModel(QAbstractItemModel *sourceModel)
{
Q_D(QSortFilterProxyModel);
+ if (sourceModel == d->model)
+ return;
+
beginResetModel();
disconnect(d->model, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
@@ -1910,6 +1913,7 @@ void QSortFilterProxyModel::setSourceModel(QAbstractItemModel *sourceModel)
disconnect(d->model, SIGNAL(modelAboutToBeReset()), this, SLOT(_q_sourceAboutToBeReset()));
disconnect(d->model, SIGNAL(modelReset()), this, SLOT(_q_sourceReset()));
+ d->_q_sourceModelDestroyed();
QAbstractProxyModel::setSourceModel(sourceModel);
connect(d->model, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
@@ -1963,7 +1967,6 @@ void QSortFilterProxyModel::setSourceModel(QAbstractItemModel *sourceModel)
connect(d->model, SIGNAL(modelAboutToBeReset()), this, SLOT(_q_sourceAboutToBeReset()));
connect(d->model, SIGNAL(modelReset()), this, SLOT(_q_sourceReset()));
- d->_q_clearMapping();
endResetModel();
if (d->update_source_sort_column() && d->dynamic_sortfilter)
d->sort();
diff --git a/src/corelib/itemmodels/qsortfilterproxymodel.h b/src/corelib/itemmodels/qsortfilterproxymodel.h
index 9f9b59733d..6c620f4812 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 recursiveFilteringEnabled READ isRecursiveFilteringEnabled WRITE setRecursiveFilteringEnabled)
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 &regExp);
@@ -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.cpp b/src/corelib/json/qjsondocument.cpp
index 6469412054..9794bca60d 100644
--- a/src/corelib/json/qjsondocument.cpp
+++ b/src/corelib/json/qjsondocument.cpp
@@ -332,7 +332,7 @@ QVariant QJsonDocument::toVariant() const
\sa fromJson()
*/
-#ifndef QT_JSON_READONLY
+#if !defined(QT_JSON_READONLY) || defined(Q_CLANG_QDOC)
QByteArray QJsonDocument::toJson() const
{
return toJson(Indented);
@@ -369,7 +369,7 @@ QByteArray QJsonDocument::toJson() const
\sa fromJson(), JsonFormat
*/
-#ifndef QT_JSON_READONLY
+#if !defined(QT_JSON_READONLY) || defined(Q_CLANG_QDOC)
QByteArray QJsonDocument::toJson(JsonFormat format) const
{
QByteArray json;
diff --git a/src/corelib/json/qjsondocument.h b/src/corelib/json/qjsondocument.h
index 4e76af21e2..b784890c54 100644
--- a/src/corelib/json/qjsondocument.h
+++ b/src/corelib/json/qjsondocument.h
@@ -129,11 +129,9 @@ 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;
-#elif !defined(QT_JSON_READONLY)
+#if !defined(QT_JSON_READONLY) || defined(Q_CLANG_QDOC)
QByteArray toJson() const; //### Merge in Qt6
QByteArray toJson(JsonFormat format) const;
#endif
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.cpp b/src/corelib/kernel/qabstracteventdispatcher.cpp
index d1e436c371..67c15d2f2c 100644
--- a/src/corelib/kernel/qabstracteventdispatcher.cpp
+++ b/src/corelib/kernel/qabstracteventdispatcher.cpp
@@ -479,7 +479,7 @@ bool QAbstractEventDispatcher::filterNativeEvent(const QByteArray &eventType, vo
the processing of the event should continue.
*/
-/*! \fn bool QAbstractEventDispatcher::registerEventNotifier(QWinEventNotifier *notifier);
+/*! \fn bool QAbstractEventDispatcher::registerEventNotifier(QWinEventNotifier *notifier)
This pure virtual method exists on windows only and has to be reimplemented by a Windows specific
event dispatcher implementation. \a notifier is the QWinEventNotifier instance to be registered.
@@ -492,7 +492,7 @@ bool QAbstractEventDispatcher::filterNativeEvent(const QByteArray &eventType, vo
\sa QWinEventNotifier, unregisterEventNotifier()
*/
-/*! \fn bool QAbstractEventDispatcher::unregisterEventNotifier(QWinEventNotifier *notifier);
+/*! \fn bool QAbstractEventDispatcher::unregisterEventNotifier(QWinEventNotifier *notifier)
This pure virtual method exists on windows only and has to be reimplemented by a Windows specific
event dispatcher implementation. \a notifier is the QWinEventNotifier instance to be unregistered.
diff --git a/src/corelib/kernel/qabstracteventdispatcher.h b/src/corelib/kernel/qabstracteventdispatcher.h
index 3a530cf1de..4775d3d47a 100644
--- a/src/corelib/kernel/qabstracteventdispatcher.h
+++ b/src/corelib/kernel/qabstracteventdispatcher.h
@@ -49,7 +49,7 @@ class QAbstractNativeEventFilter;
class QAbstractEventDispatcherPrivate;
class QSocketNotifier;
-#ifdef Q_OS_WIN
+#if defined(Q_OS_WIN) || defined(Q_CLANG_QDOC)
class QWinEventNotifier;
#endif
@@ -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
@@ -95,7 +95,7 @@ public:
virtual int remainingTime(int timerId) = 0;
-#if defined(Q_OS_WIN) || defined(Q_QDOC)
+#if defined(Q_OS_WIN) || defined(Q_CLANG_QDOC)
virtual bool registerEventNotifier(QWinEventNotifier *notifier) = 0;
virtual void unregisterEventNotifier(QWinEventNotifier *notifier) = 0;
#endif
@@ -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 34a3d7ef7e..38bcba275f 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
@@ -781,6 +781,12 @@ QCoreApplication::QCoreApplication(int &argc, char **argv
#endif
}
+/*!
+ \enum QCoreApplication::anonymous
+ \internal
+
+ \value ApplicationFlags QT_VERSION
+*/
void QCoreApplicationPrivate::init()
{
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 0d7c143999..04c9a9bcba 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..3560ea1b32 100644
--- a/src/corelib/kernel/qmetaobject.cpp
+++ b/src/corelib/kernel/qmetaobject.cpp
@@ -1341,7 +1341,7 @@ QByteArray QMetaObject::normalizedSignature(const char *method)
enum { MaximumParamCount = 11 }; // up to 10 arguments + 1 return value
-/*!
+/*
Returns the signatures of all methods whose name matches \a nonExistentMember,
or an empty QByteArray if there are no matches.
*/
@@ -1589,53 +1589,29 @@ bool QMetaObject::invokeMethodImpl(QObject *object, QtPrivate::QSlotObjectBase *
*/
/*!
- \fn bool QMetaObject::invokeMethod(QObject *receiver, PointerToMemberFunction function, Qt::ConnectionType type = Qt::AutoConnection, MemberFunctionReturnType *ret = Q_NULLPTR)
-
- \since 5.10
-
- \overload
-*/
-
-/*!
- \fn bool QMetaObject::invokeMethod(QObject *receiver, PointerToMemberFunction function, MemberFunctionReturnType *ret)
-
- \since 5.10
-
- \overload
-
- This overload invokes the member function using the connection type Qt::AutoConnection.
-*/
-
-/*!
- \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, FunctorReturnType *ret)
\since 5.10
\overload
- Call the functor in the event loop of \a context.
+ Invokes the \a function in the event loop of \a context. \a function can be a functor
+ or a pointer to a member function. Returns \c true if the function could be invoked.
+ Returns \c false if there is no such function or the parameters did not match.
+ The return value of the function call is placed in \a ret.
*/
/*!
- \fn bool QMetaObject::invokeMethod(QObject *context, Functor function, FunctorReturnType *ret = Q_NULLPTR)
+ \fn bool QMetaObject::invokeMethod(QObject *context, Functor function, FunctorReturnType *ret)
\since 5.10
\overload
- Call the functor in the event loop of \a context using the connection type Qt::AutoConnection.
-*/
-
-/*!
- \fn QMetaObject::Connection::Connection(const Connection &other)
-
- Constructs a copy of \a other.
-*/
-
-/*!
- \fn QMetaObject::Connection::Connection &operator=(const Connection &other)
-
- Assigns \a other to this connection and returns a reference to this connection.
+ Invokes the \a function in the event loop of \a context using the connection type Qt::AutoConnection.
+ \a function can be a functor or a pointer to a member function. Returns \c true if the function could
+ be invoked. Returns \c false if there is no such member or the parameters did not match.
+ The return value of the function call is placed in \a ret.
*/
/*!
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 bc1af5d66f..30cae20359 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. "
@@ -5024,7 +5024,7 @@ bool QObjectPrivate::disconnect(const QObject *sender, int signal_index, void **
*/
/*!
- Create a copy of the handle to the connection
+ Create a copy of the handle to the \a other connection
*/
QMetaObject::Connection::Connection(const QMetaObject::Connection &other) : d_ptr(other.d_ptr)
{
@@ -5032,6 +5032,9 @@ QMetaObject::Connection::Connection(const QMetaObject::Connection &other) : d_pt
static_cast<QObjectPrivate::Connection *>(d_ptr)->ref();
}
+/*!
+ Assigns \a other to this connection and returns a reference to this connection.
+*/
QMetaObject::Connection& QMetaObject::Connection::operator=(const QMetaObject::Connection& other)
{
if (other.d_ptr != d_ptr) {
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..7d2cc4dcbc 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(),
@@ -466,11 +466,7 @@ struct Q_CORE_EXPORT QMetaObject
val1, val2, val3, val4, val5, val6, val7, val8, val9);
}
-#ifdef Q_QDOC
- template<typename PointerToMemberFunction, typename MemberFunctionReturnType>
- static bool invokeMethod(QObject *receiver, PointerToMemberFunction function, Qt::ConnectionType type = Qt::AutoConnection, MemberFunctionReturnType *ret = nullptr);
- template<typename PointerToMemberFunction, typename MemberFunctionReturnType>
- static bool invokeMethod(QObject *receiver, PointerToMemberFunction function, MemberFunctionReturnType *ret);
+#ifdef Q_CLANG_QDOC
template<typename Functor, typename FunctorReturnType>
static bool invokeMethod(QObject *context, Functor function, Qt::ConnectionType type = Qt::AutoConnection, FunctorReturnType *ret = nullptr);
template<typename Functor, typename FunctorReturnType>
@@ -551,7 +547,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,14 +607,12 @@ 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 &operator=(Connection &&other)
+ Connection(Connection &&o) Q_DECL_NOTHROW : d_ptr(o.d_ptr) { o.d_ptr = nullptr; }
+ Connection &operator=(Connection &&other) Q_DECL_NOTHROW
{ qSwap(d_ptr, other.d_ptr); return *this; }
-#endif
};
inline const QMetaObject *QMetaObject::superClass() const
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/qpointer.cpp b/src/corelib/kernel/qpointer.cpp
index 66495ce005..c3dee7989e 100644
--- a/src/corelib/kernel/qpointer.cpp
+++ b/src/corelib/kernel/qpointer.cpp
@@ -111,7 +111,7 @@
*/
/*!
- \fn QPointer::QPointer()
+ \fn template <class T> QPointer<T>::QPointer()
Constructs a 0 guarded pointer.
@@ -119,14 +119,14 @@
*/
/*!
- \fn QPointer::QPointer(T* p)
+ \fn template <class T> QPointer<T>::QPointer(T* p)
Constructs a guarded pointer that points to the same object that \a p
points to.
*/
/*!
- \fn QPointer::~QPointer()
+ \fn template <class T> QPointer<T>::~QPointer()
Destroys the guarded pointer. Just like a normal pointer,
destroying a guarded pointer does \e not destroy the object being
@@ -134,7 +134,7 @@
*/
/*!
- \fn void QPointer::swap(QPointer &other)
+ \fn template <class T> void QPointer<T>::swap(QPointer &other)
\since 5.6
Swaps the contents of this QPointer with the contents of \a other.
@@ -142,28 +142,28 @@
*/
/*!
- \fn QPointer<T> & QPointer::operator=(T* p)
+ \fn template <class T> QPointer<T> & QPointer<T>::operator=(T* p)
Assignment operator. This guarded pointer will now point to the
same object that \a p points to.
*/
/*!
- \fn T* QPointer::data() const
+ \fn template <class T> T* QPointer<T>::data() const
\since 4.4
Returns the pointer to the object being guarded.
*/
/*!
- \fn bool QPointer::isNull() const
+ \fn template <class T> bool QPointer<T>::isNull() const
Returns \c true if the referenced object has been destroyed or if
there is no referenced object; otherwise returns \c false.
*/
/*!
- \fn void QPointer::clear()
+ \fn template <class T> void QPointer<T>::clear()
\since 5.0
Clears this QPointer object.
@@ -172,21 +172,21 @@
*/
/*!
- \fn T* QPointer::operator->() const
+ \fn template <class T> T* QPointer<T>::operator->() const
Overloaded arrow operator; implements pointer semantics. Just use
this operator as you would with a normal C++ pointer.
*/
/*!
- \fn T& QPointer::operator*() const
+ \fn template <class T> T& QPointer<T>::operator*() const
Dereference operator; implements pointer semantics. Just use this
operator as you would with a normal C++ pointer.
*/
/*!
- \fn QPointer::operator T*() const
+ \fn template <class T> QPointer<T>::operator T*() const
Cast operator; implements pointer semantics. Because of this
function you can pass a QPointer\<T\> to a function where a T*
@@ -194,7 +194,7 @@
*/
/*!
- \fn bool operator==(const T *o, const QPointer<T> &p)
+ \fn template <class T> bool operator==(const T *o, const QPointer<T> &p)
\relates QPointer
Equality operator. Returns \c true if \a o and the guarded
@@ -203,7 +203,7 @@
*/
/*!
- \fn bool operator==(const QPointer<T> &p, const T *o)
+ \fn template <class T> bool operator==(const QPointer<T> &p, const T *o)
\relates QPointer
Equality operator. Returns \c true if \a o and the guarded
@@ -212,7 +212,7 @@
*/
/*!
- \fn bool operator==(T *o, const QPointer<T> &p)
+ \fn template <class T> bool operator==(T *o, const QPointer<T> &p)
\relates QPointer
Equality operator. Returns \c true if \a o and the guarded
@@ -221,7 +221,7 @@
*/
/*!
- \fn bool operator==(const QPointer<T> &p, T *o)
+ \fn template <class T> bool operator==(const QPointer<T> &p, T *o)
\relates QPointer
Equality operator. Returns \c true if \a o and the guarded
@@ -230,7 +230,7 @@
*/
/*!
- \fn bool operator==(const QPointer<T> &p1, const QPointer<T> &p2)
+ \fn template <class T> bool operator==(const QPointer<T> &p1, const QPointer<T> &p2)
\relates QPointer
Equality operator. Returns \c true if the guarded pointers \a p1 and \a p2
@@ -241,7 +241,7 @@
/*!
- \fn bool operator!=(const T *o, const QPointer<T> &p)
+ \fn template <class T> bool operator!=(const T *o, const QPointer<T> &p)
\relates QPointer
Inequality operator. Returns \c true if \a o and the guarded
@@ -249,7 +249,7 @@
returns \c false.
*/
/*!
- \fn bool operator!=(const QPointer<T> &p, const T *o)
+ \fn template <class T> bool operator!=(const QPointer<T> &p, const T *o)
\relates QPointer
Inequality operator. Returns \c true if \a o and the guarded
@@ -257,7 +257,7 @@
returns \c false.
*/
/*!
- \fn bool operator!=(T *o, const QPointer<T> &p)
+ \fn template <class T> bool operator!=(T *o, const QPointer<T> &p)
\relates QPointer
Inequality operator. Returns \c true if \a o and the guarded
@@ -265,7 +265,7 @@
returns \c false.
*/
/*!
- \fn bool operator!=(const QPointer<T> &p, T *o)
+ \fn template <class T> bool operator!=(const QPointer<T> &p, T *o)
\relates QPointer
Inequality operator. Returns \c true if \a o and the guarded
@@ -273,7 +273,7 @@
returns \c false.
*/
/*!
- \fn bool operator!=(const QPointer<T> &p1, const QPointer<T> &p2)
+ \fn template <class T> bool operator!=(const QPointer<T> &p1, const QPointer<T> &p2)
\relates QPointer
Inequality operator. Returns \c true if the guarded pointers \a p1 and
@@ -281,7 +281,7 @@
returns \c false.
*/
/*!
- \fn QPointer<T> qPointerFromVariant(const QVariant &variant)
+ \fn template <typename T> QPointer<T> qPointerFromVariant(const QVariant &variant)
\internal
diff --git a/src/corelib/kernel/qsharedmemory.cpp b/src/corelib/kernel/qsharedmemory.cpp
index c8ba13c90c..c952655cb8 100644
--- a/src/corelib/kernel/qsharedmemory.cpp
+++ b/src/corelib/kernel/qsharedmemory.cpp
@@ -67,9 +67,11 @@ QSharedMemoryPrivate::makePlatformSafeKey(const QString &key,
QString result = prefix;
- QString part1 = key;
- part1.replace(QRegExp(QLatin1String("[^A-Za-z]")), QString());
- result.append(part1);
+ for (QChar ch : key) {
+ if ((ch >= QLatin1Char('a') && ch <= QLatin1Char('z')) ||
+ (ch >= QLatin1Char('A') && ch <= QLatin1Char('Z')))
+ result += ch;
+ }
QByteArray hex = QCryptographicHash::hash(key.toUtf8(), QCryptographicHash::Sha1).toHex();
result.append(QLatin1String(hex));
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/qsystemerror_p.h b/src/corelib/kernel/qsystemerror_p.h
index 1d8c253f53..abc2f1efc1 100644
--- a/src/corelib/kernel/qsystemerror_p.h
+++ b/src/corelib/kernel/qsystemerror_p.h
@@ -56,7 +56,7 @@
QT_BEGIN_NAMESPACE
-class Q_CORE_EXPORT QSystemError
+class QSystemError
{
public:
enum ErrorScope
@@ -66,51 +66,27 @@ public:
NativeError
};
- inline QSystemError(int error, ErrorScope scope);
- inline QSystemError();
+ Q_DECL_CONSTEXPR explicit QSystemError(int error, ErrorScope scope)
+ : errorCode(error), errorScope(scope)
+ {
+ }
+ Q_DECL_CONSTEXPR QSystemError() = default;
- inline QString toString() const;
- inline ErrorScope scope() const;
- inline int error() const;
+ QString toString() const { return string(errorScope, errorCode); }
+ Q_DECL_CONSTEXPR ErrorScope scope() const { return errorScope; }
+ Q_DECL_CONSTEXPR int error() const { return errorCode; }
- static QString string(ErrorScope errorScope, int errorCode);
- static QString stdString(int errorCode = -1);
+ static Q_CORE_EXPORT QString string(ErrorScope errorScope, int errorCode);
+ static Q_CORE_EXPORT QString stdString(int errorCode = -1);
#ifdef Q_OS_WIN
- static QString windowsString(int errorCode = -1);
+ static Q_CORE_EXPORT QString windowsString(int errorCode = -1);
#endif
//data members
- int errorCode;
- ErrorScope errorScope;
+ int errorCode = 0;
+ ErrorScope errorScope = NoError;
};
-QSystemError::QSystemError(int error, QSystemError::ErrorScope scope)
-: errorCode(error), errorScope(scope)
-{
-
-}
-
-QSystemError::QSystemError()
-: errorCode(0), errorScope(NoError)
-{
-
-}
-
-QString QSystemError::toString() const
-{
- return string(errorScope, errorCode);
-}
-
-QSystemError::ErrorScope QSystemError::scope() const
-{
- return errorScope;
-}
-
-int QSystemError::error() const
-{
- return errorCode;
-}
-
QT_END_NAMESPACE
#endif // QSYSTEMERROR_P_H
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.cpp b/src/corelib/kernel/qtranslator.cpp
index 2232e24a25..c868f6d266 100644
--- a/src/corelib/kernel/qtranslator.cpp
+++ b/src/corelib/kernel/qtranslator.cpp
@@ -1064,7 +1064,7 @@ searchDependencies:
return QString();
}
-/*!
+/*
Empties this translator of all contents.
This function works with stripped translator files.
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/mimetypes.qrc b/src/corelib/mimetypes/mimetypes.qrc
index f0cf47cd49..19bc1d3e2a 100644
--- a/src/corelib/mimetypes/mimetypes.qrc
+++ b/src/corelib/mimetypes/mimetypes.qrc
@@ -1,5 +1,5 @@
<RCC>
- <qresource prefix="/qt-project.org/qmime">
+ <qresource prefix="/qt-project.org/qmime/packages">
<file alias="freedesktop.org.xml">mime/packages/freedesktop.org.xml</file>
</qresource>
</RCC>
diff --git a/src/corelib/mimetypes/qmimedatabase.cpp b/src/corelib/mimetypes/qmimedatabase.cpp
index 687f0b3e03..f90fd12e3b 100644
--- a/src/corelib/mimetypes/qmimedatabase.cpp
+++ b/src/corelib/mimetypes/qmimedatabase.cpp
@@ -51,6 +51,7 @@
#include <QtCore/QFile>
#include <QtCore/QFileInfo>
#include <QtCore/QSet>
+#include <QtCore/QStandardPaths>
#include <QtCore/QBuffer>
#include <QtCore/QUrl>
#include <QtCore/QDebug>
@@ -69,34 +70,102 @@ QMimeDatabasePrivate *QMimeDatabasePrivate::instance()
}
QMimeDatabasePrivate::QMimeDatabasePrivate()
- : m_provider(0), m_defaultMimeType(QLatin1String("application/octet-stream"))
+ : m_defaultMimeType(QLatin1String("application/octet-stream"))
{
}
QMimeDatabasePrivate::~QMimeDatabasePrivate()
{
- delete m_provider;
- m_provider = 0;
+ qDeleteAll(m_providers);
}
-QMimeProviderBase *QMimeDatabasePrivate::provider()
+Q_CORE_EXPORT int qmime_secondsBetweenChecks = 5; // exported for the unit test
+
+bool QMimeDatabasePrivate::shouldCheck()
+{
+ if (m_lastCheck.isValid() && m_lastCheck.elapsed() < qmime_secondsBetweenChecks * 1000)
+ return false;
+ m_lastCheck.start();
+ return true;
+}
+
+#if defined(Q_OS_UNIX) && !defined(Q_OS_INTEGRITY)
+#define QT_USE_MMAP
+#endif
+
+void QMimeDatabasePrivate::loadProviders()
{
- if (!m_provider) {
- QMimeProviderBase *binaryProvider = new QMimeBinaryProvider(this);
- if (binaryProvider->isValid()) {
- m_provider = binaryProvider;
+ // We use QStandardPaths every time to check if new files appeared
+ QStringList mimeDirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QLatin1String("mime"), QStandardPaths::LocateDirectory);
+ const auto fdoIterator = std::find_if(mimeDirs.constBegin(), mimeDirs.constEnd(), [](const QString &mimeDir) -> bool {
+ return QFileInfo::exists(mimeDir + QStringLiteral("/packages/freedesktop.org.xml")); }
+ );
+ if (fdoIterator == mimeDirs.constEnd())
+ mimeDirs.prepend(QLatin1String(":/qt-project.org/qmime"));
+ //qDebug() << "mime dirs:" << mimeDirs;
+
+ QVector<QMimeProviderBase *> currentProviders = m_providers;
+ m_providers.clear();
+ m_providers.reserve(mimeDirs.size());
+ for (const QString &mimeDir : qAsConst(mimeDirs)) {
+ const QString cacheFile = mimeDir + QStringLiteral("/mime.cache");
+ QFileInfo fileInfo(cacheFile);
+ // Check if we already have a provider for this dir
+ const auto it = std::find_if(currentProviders.begin(), currentProviders.end(), [mimeDir](QMimeProviderBase *prov) { return prov->directory() == mimeDir; });
+ if (it == currentProviders.end()) {
+ QMimeProviderBase *provider = nullptr;
+#if defined(QT_USE_MMAP)
+ if (qEnvironmentVariableIsEmpty("QT_NO_MIME_CACHE") && fileInfo.exists()) {
+ provider = new QMimeBinaryProvider(this, mimeDir);
+ //qDebug() << "Created binary provider for" << mimeDir;
+ if (!provider->isValid()) {
+ delete provider;
+ provider = nullptr;
+ }
+ }
+#endif
+ if (!provider) {
+ provider = new QMimeXMLProvider(this, mimeDir);
+ //qDebug() << "Created XML provider for" << mimeDir;
+ }
+ m_providers.append(provider);
} else {
- delete binaryProvider;
- m_provider = new QMimeXMLProvider(this);
+ QMimeProviderBase *provider = *it;
+ currentProviders.erase(it);
+ provider->ensureLoaded();
+ if (!provider->isValid()) {
+ delete provider;
+ provider = new QMimeXMLProvider(this, mimeDir);
+ //qDebug() << "Created XML provider to replace binary provider for" << mimeDir;
+ }
+ m_providers.append(provider);
}
}
- return m_provider;
+ qDeleteAll(currentProviders);
}
-void QMimeDatabasePrivate::setProvider(QMimeProviderBase *theProvider)
+QVector<QMimeProviderBase *> QMimeDatabasePrivate::providers()
{
- delete m_provider;
- m_provider = theProvider;
+ Q_ASSERT(!mutex.tryLock()); // caller should have locked mutex
+ if (m_providers.isEmpty()) {
+ loadProviders();
+ m_lastCheck.start();
+ } else {
+ if (shouldCheck())
+ loadProviders();
+ }
+ return m_providers;
+}
+
+QString QMimeDatabasePrivate::resolveAlias(const QString &nameOrAlias)
+{
+ const auto allProviders = providers();
+ for (QMimeProviderBase *provider : allProviders) {
+ const QString ret = provider->resolveAlias(nameOrAlias);
+ if (!ret.isEmpty())
+ return ret;
+ }
+ return nameOrAlias;
}
/*!
@@ -105,7 +174,14 @@ void QMimeDatabasePrivate::setProvider(QMimeProviderBase *theProvider)
*/
QMimeType QMimeDatabasePrivate::mimeTypeForName(const QString &nameOrAlias)
{
- return provider()->mimeTypeForName(provider()->resolveAlias(nameOrAlias));
+ const auto allProviders = providers();
+ const QString mimeName = resolveAlias(nameOrAlias);
+ for (QMimeProviderBase *provider : allProviders) {
+ const QMimeType mime = provider->mimeTypeForName(mimeName);
+ if (mime.isValid())
+ return mime;
+ }
+ return {};
}
QStringList QMimeDatabasePrivate::mimeTypeForFileName(const QString &fileName)
@@ -113,11 +189,113 @@ QStringList QMimeDatabasePrivate::mimeTypeForFileName(const QString &fileName)
if (fileName.endsWith(QLatin1Char('/')))
return QStringList() << QLatin1String("inode/directory");
- QStringList matchingMimeTypes = provider()->findByFileName(QFileInfo(fileName).fileName()).m_matchingMimeTypes;
+ const QString shortName = QFileInfo(fileName).fileName();
+ const QMimeGlobMatchResult result = findByFileName(shortName);
+ QStringList matchingMimeTypes = result.m_matchingMimeTypes;
matchingMimeTypes.sort(); // make it deterministic
return matchingMimeTypes;
}
+QMimeGlobMatchResult QMimeDatabasePrivate::findByFileName(const QString &fileName)
+{
+ QMimeGlobMatchResult result;
+ // TODO this parses in the order (local, global). Check that it handles "NOGLOBS" correctly.
+ const auto allProviders = providers();
+ for (QMimeProviderBase *provider : allProviders)
+ provider->addFileNameMatches(fileName, result);
+ return result;
+}
+
+void QMimeDatabasePrivate::loadMimeTypePrivate(QMimeTypePrivate &mimePrivate)
+{
+ QMutexLocker locker(&mutex);
+ if (!mimePrivate.loaded) { // XML provider sets loaded=true, binary provider does this on demand
+ Q_ASSERT(mimePrivate.fromCache);
+ QMimeBinaryProvider::loadMimeTypePrivate(mimePrivate);
+ }
+}
+
+void QMimeDatabasePrivate::loadGenericIcon(QMimeTypePrivate &mimePrivate)
+{
+ QMutexLocker locker(&mutex);
+ if (mimePrivate.fromCache) {
+ mimePrivate.genericIconName.clear();
+ const auto allProviders = providers();
+ for (QMimeProviderBase *provider : allProviders) {
+ provider->loadGenericIcon(mimePrivate);
+ if (!mimePrivate.genericIconName.isEmpty())
+ break;
+ }
+ }
+}
+
+void QMimeDatabasePrivate::loadIcon(QMimeTypePrivate &mimePrivate)
+{
+ QMutexLocker locker(&mutex);
+ if (mimePrivate.fromCache) {
+ mimePrivate.iconName.clear();
+ const auto allProviders = providers();
+ for (QMimeProviderBase *provider : allProviders) {
+ provider->loadIcon(mimePrivate);
+ if (!mimePrivate.iconName.isEmpty())
+ break;
+ }
+ }
+}
+
+static QString fallbackParent(const QString &mimeTypeName)
+{
+ const QStringRef myGroup = mimeTypeName.leftRef(mimeTypeName.indexOf(QLatin1Char('/')));
+ // All text/* types are subclasses of text/plain.
+ if (myGroup == QLatin1String("text") && mimeTypeName != QLatin1String("text/plain"))
+ return QLatin1String("text/plain");
+ // All real-file mimetypes implicitly derive from application/octet-stream
+ if (myGroup != QLatin1String("inode") &&
+ // ignore non-file extensions
+ myGroup != QLatin1String("all") && myGroup != QLatin1String("fonts") && myGroup != QLatin1String("print") && myGroup != QLatin1String("uri")
+ && mimeTypeName != QLatin1String("application/octet-stream")) {
+ return QLatin1String("application/octet-stream");
+ }
+ return QString();
+}
+
+QStringList QMimeDatabasePrivate::mimeParents(const QString &mimeName)
+{
+ QMutexLocker locker(&mutex);
+ return parents(mimeName);
+}
+
+QStringList QMimeDatabasePrivate::parents(const QString &mimeName)
+{
+ Q_ASSERT(!mutex.tryLock());
+ QStringList result;
+ const auto allProviders = providers();
+ for (QMimeProviderBase *provider : allProviders)
+ provider->addParents(mimeName, result);
+ if (result.isEmpty()) {
+ const QString parent = fallbackParent(mimeName);
+ if (!parent.isEmpty())
+ result.append(parent);
+ }
+ return result;
+}
+
+QStringList QMimeDatabasePrivate::listAliases(const QString &mimeName)
+{
+ QMutexLocker locker(&mutex);
+ QStringList result;
+ const auto allProviders = providers();
+ for (QMimeProviderBase *provider : allProviders)
+ provider->addAliases(mimeName, result);
+ return result;
+}
+
+bool QMimeDatabasePrivate::mimeInherits(const QString &mime, const QString &parent)
+{
+ QMutexLocker locker(&mutex);
+ return inherits(mime, parent);
+}
+
static inline bool isTextFile(const QByteArray &data)
{
// UTF16 byte order marks
@@ -145,7 +323,10 @@ QMimeType QMimeDatabasePrivate::findByData(const QByteArray &data, int *accuracy
}
*accuracyPtr = 0;
- QMimeType candidate = provider()->findByMagic(data, accuracyPtr);
+ QMimeType candidate;
+ const auto allProviders = providers();
+ for (QMimeProviderBase *provider : allProviders)
+ provider->findByMagic(data, accuracyPtr, candidate);
if (candidate.isValid())
return candidate;
@@ -172,7 +353,7 @@ QMimeType QMimeDatabasePrivate::mimeTypeForFileNameAndData(const QString &fileNa
if (fileName.endsWith(QLatin1Char('/')))
candidatesByName.addMatch(QLatin1String("inode/directory"), 100, QString());
else
- candidatesByName = provider()->findByFileName(QFileInfo(fileName).fileName());
+ candidatesByName = findByFileName(QFileInfo(fileName).fileName());
if (candidatesByName.m_allMatchingMimeTypes.count() == 1) {
*accuracyPtr = 100;
const QMimeType mime = mimeTypeForName(candidatesByName.m_matchingMimeTypes.at(0));
@@ -222,21 +403,25 @@ QMimeType QMimeDatabasePrivate::mimeTypeForFileNameAndData(const QString &fileNa
QList<QMimeType> QMimeDatabasePrivate::allMimeTypes()
{
- return provider()->allMimeTypes();
+ QList<QMimeType> result;
+ const auto allProviders = providers();
+ for (QMimeProviderBase *provider : allProviders)
+ provider->addAllMimeTypes(result);
+ return result;
}
bool QMimeDatabasePrivate::inherits(const QString &mime, const QString &parent)
{
- const QString resolvedParent = provider()->resolveAlias(parent);
- //Q_ASSERT(provider()->resolveAlias(mime) == mime);
+ const QString resolvedParent = resolveAlias(parent);
std::stack<QString, QStringList> toCheck;
toCheck.push(mime);
while (!toCheck.empty()) {
if (toCheck.top() == resolvedParent)
return true;
- const auto parents = provider()->parents(toCheck.top());
+ const QString mimeName = toCheck.top();
toCheck.pop();
- for (const QString &par : parents)
+ const auto parentList = parents(mimeName);
+ for (const QString &par : parentList)
toCheck.push(par);
}
return false;
@@ -460,7 +645,7 @@ QList<QMimeType> QMimeDatabase::mimeTypesForFileName(const QString &fileName) co
QString QMimeDatabase::suffixForFileName(const QString &fileName) const
{
QMutexLocker locker(&d->mutex);
- return d->provider()->findByFileName(QFileInfo(fileName).fileName()).m_foundSuffix;
+ return d->findByFileName(QFileInfo(fileName).fileName()).m_foundSuffix;
}
/*!
@@ -550,6 +735,7 @@ QMimeType QMimeDatabase::mimeTypeForUrl(const QUrl &url) const
*/
QMimeType QMimeDatabase::mimeTypeForFileNameAndData(const QString &fileName, QIODevice *device) const
{
+ QMutexLocker locker(&d->mutex);
int accuracy = 0;
const bool openedByUs = !device->isOpen() && device->open(QIODevice::ReadOnly);
const QMimeType result = d->mimeTypeForFileNameAndData(fileName, device, &accuracy);
@@ -576,6 +762,7 @@ QMimeType QMimeDatabase::mimeTypeForFileNameAndData(const QString &fileName, QIO
*/
QMimeType QMimeDatabase::mimeTypeForFileNameAndData(const QString &fileName, const QByteArray &data) const
{
+ QMutexLocker locker(&d->mutex);
QBuffer buffer(const_cast<QByteArray *>(&data));
buffer.open(QIODevice::ReadOnly);
int accuracy = 0;
diff --git a/src/corelib/mimetypes/qmimedatabase_p.h b/src/corelib/mimetypes/qmimedatabase_p.h
index 3f63f5f103..1c38f46115 100644
--- a/src/corelib/mimetypes/qmimedatabase_p.h
+++ b/src/corelib/mimetypes/qmimedatabase_p.h
@@ -59,7 +59,9 @@
#include "qmimetype_p.h"
#include "qmimeglobpattern_p.h"
+#include <QtCore/qelapsedtimer.h>
#include <QtCore/qmutex.h>
+#include <QtCore/qvector.h>
QT_BEGIN_NAMESPACE
@@ -77,22 +79,37 @@ public:
static QMimeDatabasePrivate *instance();
- QMimeProviderBase *provider();
- void setProvider(QMimeProviderBase *theProvider);
-
inline QString defaultMimeType() const { return m_defaultMimeType; }
bool inherits(const QString &mime, const QString &parent);
QList<QMimeType> allMimeTypes();
-
+ QString resolveAlias(const QString &nameOrAlias);
+ QStringList parents(const QString &mimeName);
QMimeType mimeTypeForName(const QString &nameOrAlias);
QMimeType mimeTypeForFileNameAndData(const QString &fileName, QIODevice *device, int *priorityPtr);
QMimeType findByData(const QByteArray &data, int *priorityPtr);
QStringList mimeTypeForFileName(const QString &fileName);
+ QMimeGlobMatchResult findByFileName(const QString &fileName);
+
+ // API for QMimeType. Takes care of locking the mutex.
+ void loadMimeTypePrivate(QMimeTypePrivate &mimePrivate);
+ void loadGenericIcon(QMimeTypePrivate &mimePrivate);
+ void loadIcon(QMimeTypePrivate &mimePrivate);
+ QStringList mimeParents(const QString &mimeName);
+ QStringList listAliases(const QString &mimeName);
+ bool mimeInherits(const QString &mime, const QString &parent);
- mutable QMimeProviderBase *m_provider;
+private:
+ QVector<QMimeProviderBase *> providers();
+ bool shouldCheck();
+ void loadProviders();
+
+ mutable QVector<QMimeProviderBase *> m_providers;
+ QElapsedTimer m_lastCheck;
+
+public:
const QString m_defaultMimeType;
QMutex mutex;
};
diff --git a/src/corelib/mimetypes/qmimeglobpattern.cpp b/src/corelib/mimetypes/qmimeglobpattern.cpp
index a4d2b046fa..e7b2b879a1 100644
--- a/src/corelib/mimetypes/qmimeglobpattern.cpp
+++ b/src/corelib/mimetypes/qmimeglobpattern.cpp
@@ -206,10 +206,9 @@ void QMimeGlobPatternList::match(QMimeGlobMatchResult &result,
}
}
-QMimeGlobMatchResult QMimeAllGlobPatterns::matchingGlobs(const QString &fileName) const
+void QMimeAllGlobPatterns::matchingGlobs(const QString &fileName, QMimeGlobMatchResult &result) const
{
// First try the high weight matches (>50), if any.
- QMimeGlobMatchResult result;
m_highWeightGlobs.match(result, fileName);
// Now use the "fast patterns" dict, for simple *.foo patterns with weight 50
@@ -230,8 +229,6 @@ QMimeGlobMatchResult QMimeAllGlobPatterns::matchingGlobs(const QString &fileName
// Finally, try the low weight matches (<=50)
m_lowWeightGlobs.match(result, fileName);
-
- return result;
}
void QMimeAllGlobPatterns::clear()
diff --git a/src/corelib/mimetypes/qmimeglobpattern_p.h b/src/corelib/mimetypes/qmimeglobpattern_p.h
index 21332e71bc..103729c4ff 100644
--- a/src/corelib/mimetypes/qmimeglobpattern_p.h
+++ b/src/corelib/mimetypes/qmimeglobpattern_p.h
@@ -152,7 +152,7 @@ public:
void addGlob(const QMimeGlobPattern &glob);
void removeMimeType(const QString &mimeType);
- QMimeGlobMatchResult matchingGlobs(const QString &fileName) const;
+ void matchingGlobs(const QString &fileName, QMimeGlobMatchResult &result) const;
void clear();
PatternsMap m_fastPatterns; // example: "doc" -> "application/msword", "text/plain"
diff --git a/src/corelib/mimetypes/qmimemagicrule.cpp b/src/corelib/mimetypes/qmimemagicrule.cpp
index 5bbf1bba9d..6356a3581b 100644
--- a/src/corelib/mimetypes/qmimemagicrule.cpp
+++ b/src/corelib/mimetypes/qmimemagicrule.cpp
@@ -65,7 +65,7 @@ static const char magicRuleTypes_string[] =
"\0";
static const int magicRuleTypes_indices[] = {
- 0, 8, 15, 22, 29, 35, 41, 50, 59, 65, 0
+ 0, 8, 15, 22, 29, 35, 41, 50, 59, 64, 0
};
QMimeMagicRule::Type QMimeMagicRule::type(const QByteArray &theTypeName)
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.cpp b/src/corelib/mimetypes/qmimeprovider.cpp
index ed7ebb2ef5..ec0a6bf0ef 100644
--- a/src/corelib/mimetypes/qmimeprovider.cpp
+++ b/src/corelib/mimetypes/qmimeprovider.cpp
@@ -61,46 +61,18 @@ static void initResources()
QT_BEGIN_NAMESPACE
-static QString fallbackParent(const QString &mimeTypeName)
-{
- const QStringRef myGroup = mimeTypeName.leftRef(mimeTypeName.indexOf(QLatin1Char('/')));
- // All text/* types are subclasses of text/plain.
- if (myGroup == QLatin1String("text") && mimeTypeName != QLatin1String("text/plain"))
- return QLatin1String("text/plain");
- // All real-file mimetypes implicitly derive from application/octet-stream
- if (myGroup != QLatin1String("inode") &&
- // ignore non-file extensions
- myGroup != QLatin1String("all") && myGroup != QLatin1String("fonts") && myGroup != QLatin1String("print") && myGroup != QLatin1String("uri")
- && mimeTypeName != QLatin1String("application/octet-stream")) {
- return QLatin1String("application/octet-stream");
- }
- return QString();
-}
-
-QMimeProviderBase::QMimeProviderBase(QMimeDatabasePrivate *db)
- : m_db(db)
+QMimeProviderBase::QMimeProviderBase(QMimeDatabasePrivate *db, const QString &directory)
+ : m_db(db), m_directory(directory)
{
}
-Q_CORE_EXPORT int qmime_secondsBetweenChecks = 5; // exported for the unit test
-bool QMimeProviderBase::shouldCheck()
-{
- if (m_lastCheck.isValid() && m_lastCheck.elapsed() < qmime_secondsBetweenChecks * 1000)
- return false;
- m_lastCheck.start();
- return true;
-}
-
-QMimeBinaryProvider::QMimeBinaryProvider(QMimeDatabasePrivate *db)
- : QMimeProviderBase(db), m_mimetypeListLoaded(false)
+QMimeBinaryProvider::QMimeBinaryProvider(QMimeDatabasePrivate *db, const QString &directory)
+ : QMimeProviderBase(db, directory), m_mimetypeListLoaded(false)
{
+ ensureLoaded();
}
-#if defined(Q_OS_UNIX) && !defined(Q_OS_INTEGRITY)
-#define QT_USE_MMAP
-#endif
-
struct QMimeBinaryProvider::CacheFile
{
CacheFile(const QString &fileName);
@@ -154,7 +126,6 @@ bool QMimeBinaryProvider::CacheFile::load()
bool QMimeBinaryProvider::CacheFile::reload()
{
- //qDebug() << "reload!" << file->fileName();
m_valid = false;
if (file.isOpen()) {
file.close();
@@ -163,18 +134,14 @@ bool QMimeBinaryProvider::CacheFile::reload()
return load();
}
-QMimeBinaryProvider::CacheFile *QMimeBinaryProvider::CacheFileList::findCacheFile(const QString &fileName) const
+QMimeBinaryProvider::~QMimeBinaryProvider()
{
- for (const_iterator it = begin(); it != end(); ++it) {
- if ((*it)->file.fileName() == fileName)
- return *it;
- }
- return 0;
+ delete m_cacheFile;
}
-QMimeBinaryProvider::~QMimeBinaryProvider()
+bool QMimeBinaryProvider::isValid()
{
- qDeleteAll(m_cacheFiles);
+ return m_cacheFile != nullptr;
}
// Position of the "list offsets" values, at the beginning of the mime.cache file
@@ -190,79 +157,33 @@ enum {
PosGenericIconsListOffset = 36
};
-bool QMimeBinaryProvider::isValid()
+bool QMimeBinaryProvider::checkCacheChanged()
{
-#if defined(QT_USE_MMAP)
- if (!qEnvironmentVariableIsEmpty("QT_NO_MIME_CACHE"))
- return false;
-
- Q_ASSERT(m_cacheFiles.isEmpty()); // this method is only ever called once
- checkCache();
-
- if (m_cacheFiles.count() > 1)
+ QFileInfo fileInfo(m_cacheFile->file);
+ if (fileInfo.lastModified() > m_cacheFile->m_mtime) {
+ // Deletion can't happen by just running update-mime-database.
+ // But the user could use rm -rf :-)
+ m_cacheFile->reload(); // will mark itself as invalid on failure
return true;
- if (m_cacheFiles.isEmpty())
- return false;
-
- // We found exactly one file; is it the user-modified mimes, or a system file?
- const QString foundFile = m_cacheFiles.constFirst()->file.fileName();
- const QString localCacheFile = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1String("/mime/mime.cache");
-
- return foundFile != localCacheFile;
-#else
- return false;
-#endif
-}
-
-bool QMimeBinaryProvider::CacheFileList::checkCacheChanged()
-{
- bool somethingChanged = false;
- for (CacheFile *cacheFile : qAsConst(*this)) {
- QFileInfo fileInfo(cacheFile->file);
- if (!fileInfo.exists() || fileInfo.lastModified() > cacheFile->m_mtime) {
- // Deletion can't happen by just running update-mime-database.
- // But the user could use rm -rf :-)
- cacheFile->reload(); // will mark itself as invalid on failure
- somethingChanged = true;
- }
- }
- if (somethingChanged) {
- auto deleteIfNoLongerValid = [](CacheFile *cacheFile) -> bool {
- const bool invalid = !cacheFile->isValid();
- if (invalid)
- delete cacheFile;
- return invalid;
- };
- erase(std::remove_if(begin(), end(), deleteIfNoLongerValid), end());
}
- return somethingChanged;
+ return false;
}
-void QMimeBinaryProvider::checkCache()
+void QMimeBinaryProvider::ensureLoaded()
{
- if (!shouldCheck())
- return;
-
- // First iterate over existing known cache files and check for uptodate
- if (m_cacheFiles.checkCacheChanged())
- m_mimetypeListLoaded = false;
-
- // Then check if new cache files appeared
- const QStringList cacheFileNames = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QLatin1String("mime/mime.cache"));
- if (cacheFileNames != m_cacheFileNames) {
- for (const QString &cacheFileName : cacheFileNames) {
- CacheFile *cacheFile = m_cacheFiles.findCacheFile(cacheFileName);
- if (!cacheFile) {
- //qDebug() << "new file:" << cacheFileName;
- cacheFile = new CacheFile(cacheFileName);
- if (cacheFile->isValid()) // verify version
- m_cacheFiles.append(cacheFile);
- else
- delete cacheFile;
- }
- }
- m_cacheFileNames = cacheFileNames;
+ if (!m_cacheFile) {
+ const QString cacheFileName = m_directory + QLatin1String("/mime.cache");
+ m_cacheFile = new CacheFile(cacheFileName);
m_mimetypeListLoaded = false;
+ } else {
+ if (checkCacheChanged())
+ m_mimetypeListLoaded = false;
+ else
+ return; // nothing to do
+ }
+ if (!m_cacheFile->isValid()) { // verify existence and version
+ delete m_cacheFile;
+ m_cacheFile = nullptr;
}
}
@@ -270,6 +191,7 @@ static QMimeType mimeTypeForNameUnchecked(const QString &name)
{
QMimeTypePrivate data;
data.name = name;
+ data.fromCache = true;
// The rest is retrieved on demand.
// comment and globPatterns: in loadMimeTypePrivate
// iconName: in loadIcon
@@ -279,7 +201,6 @@ static QMimeType mimeTypeForNameUnchecked(const QString &name)
QMimeType QMimeBinaryProvider::mimeTypeForName(const QString &name)
{
- checkCache();
if (!m_mimetypeListLoaded)
loadMimeTypeList();
if (!m_mimetypeNames.contains(name))
@@ -287,28 +208,23 @@ QMimeType QMimeBinaryProvider::mimeTypeForName(const QString &name)
return mimeTypeForNameUnchecked(name);
}
-QMimeGlobMatchResult QMimeBinaryProvider::findByFileName(const QString &fileName)
+void QMimeBinaryProvider::addFileNameMatches(const QString &fileName, QMimeGlobMatchResult &result)
{
- checkCache();
- QMimeGlobMatchResult result;
if (fileName.isEmpty())
- return result;
+ return;
+ Q_ASSERT(m_cacheFile);
const QString lowerFileName = fileName.toLower();
- // TODO this parses in the order (local, global). Check that it handles "NOGLOBS" correctly.
- for (CacheFile *cacheFile : qAsConst(m_cacheFiles)) {
- // Check literals (e.g. "Makefile")
- matchGlobList(result, cacheFile, cacheFile->getUint32(PosLiteralListOffset), fileName);
- // Check complex globs (e.g. "callgrind.out[0-9]*")
- matchGlobList(result, cacheFile, cacheFile->getUint32(PosGlobListOffset), fileName);
- // Check the very common *.txt cases with the suffix tree
- const int reverseSuffixTreeOffset = cacheFile->getUint32(PosReverseSuffixTreeOffset);
- const int numRoots = cacheFile->getUint32(reverseSuffixTreeOffset);
- const int firstRootOffset = cacheFile->getUint32(reverseSuffixTreeOffset + 4);
- matchSuffixTree(result, cacheFile, numRoots, firstRootOffset, lowerFileName, lowerFileName.length() - 1, false);
- if (result.m_matchingMimeTypes.isEmpty())
- matchSuffixTree(result, cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true);
- }
- return result;
+ // Check literals (e.g. "Makefile")
+ matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosLiteralListOffset), fileName);
+ // Check complex globs (e.g. "callgrind.out[0-9]*")
+ matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosGlobListOffset), fileName);
+ // Check the very common *.txt cases with the suffix tree
+ const int reverseSuffixTreeOffset = m_cacheFile->getUint32(PosReverseSuffixTreeOffset);
+ const int numRoots = m_cacheFile->getUint32(reverseSuffixTreeOffset);
+ const int firstRootOffset = m_cacheFile->getUint32(reverseSuffixTreeOffset + 4);
+ matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, lowerFileName, lowerFileName.length() - 1, false);
+ if (result.m_matchingMimeTypes.isEmpty())
+ matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true);
}
void QMimeBinaryProvider::matchGlobList(QMimeGlobMatchResult &result, CacheFile *cacheFile, int off, const QString &fileName)
@@ -406,124 +322,106 @@ bool QMimeBinaryProvider::matchMagicRule(QMimeBinaryProvider::CacheFile *cacheFi
return false;
}
-QMimeType QMimeBinaryProvider::findByMagic(const QByteArray &data, int *accuracyPtr)
-{
- checkCache();
- for (CacheFile *cacheFile : qAsConst(m_cacheFiles)) {
- const int magicListOffset = cacheFile->getUint32(PosMagicListOffset);
- const int numMatches = cacheFile->getUint32(magicListOffset);
- //const int maxExtent = cacheFile->getUint32(magicListOffset + 4);
- const int firstMatchOffset = cacheFile->getUint32(magicListOffset + 8);
-
- for (int i = 0; i < numMatches; ++i) {
- const int off = firstMatchOffset + i * 16;
- const int numMatchlets = cacheFile->getUint32(off + 8);
- const int firstMatchletOffset = cacheFile->getUint32(off + 12);
- if (matchMagicRule(cacheFile, numMatchlets, firstMatchletOffset, data)) {
- const int mimeTypeOffset = cacheFile->getUint32(off + 4);
- const char *mimeType = cacheFile->getCharStar(mimeTypeOffset);
- *accuracyPtr = cacheFile->getUint32(off);
- // Return the first match. We have no rules for conflicting magic data...
- // (mime.cache itself is sorted, but what about local overrides with a lower prio?)
- return mimeTypeForNameUnchecked(QLatin1String(mimeType));
- }
+void QMimeBinaryProvider::findByMagic(const QByteArray &data, int *accuracyPtr, QMimeType &candidate)
+{
+ const int magicListOffset = m_cacheFile->getUint32(PosMagicListOffset);
+ const int numMatches = m_cacheFile->getUint32(magicListOffset);
+ //const int maxExtent = cacheFile->getUint32(magicListOffset + 4);
+ const int firstMatchOffset = m_cacheFile->getUint32(magicListOffset + 8);
+
+ for (int i = 0; i < numMatches; ++i) {
+ const int off = firstMatchOffset + i * 16;
+ const int numMatchlets = m_cacheFile->getUint32(off + 8);
+ const int firstMatchletOffset = m_cacheFile->getUint32(off + 12);
+ if (matchMagicRule(m_cacheFile, numMatchlets, firstMatchletOffset, data)) {
+ const int mimeTypeOffset = m_cacheFile->getUint32(off + 4);
+ const char *mimeType = m_cacheFile->getCharStar(mimeTypeOffset);
+ *accuracyPtr = m_cacheFile->getUint32(off);
+ // Return the first match. We have no rules for conflicting magic data...
+ // (mime.cache itself is sorted, but what about local overrides with a lower prio?)
+ candidate = mimeTypeForNameUnchecked(QLatin1String(mimeType));
+ return;
}
}
- return QMimeType();
}
-QStringList QMimeBinaryProvider::parents(const QString &mime)
+void QMimeBinaryProvider::addParents(const QString &mime, QStringList &result)
{
- checkCache();
const QByteArray mimeStr = mime.toLatin1();
- QStringList result;
- for (CacheFile *cacheFile : qAsConst(m_cacheFiles)) {
- const int parentListOffset = cacheFile->getUint32(PosParentListOffset);
- const int numEntries = cacheFile->getUint32(parentListOffset);
-
- int begin = 0;
- int end = numEntries - 1;
- while (begin <= end) {
- const int medium = (begin + end) / 2;
- const int off = parentListOffset + 4 + 8 * medium;
- const int mimeOffset = cacheFile->getUint32(off);
- const char *aMime = cacheFile->getCharStar(mimeOffset);
- const int cmp = qstrcmp(aMime, mimeStr);
- if (cmp < 0) {
- begin = medium + 1;
- } else if (cmp > 0) {
- end = medium - 1;
- } else {
- const int parentsOffset = cacheFile->getUint32(off + 4);
- const int numParents = cacheFile->getUint32(parentsOffset);
- for (int i = 0; i < numParents; ++i) {
- const int parentOffset = cacheFile->getUint32(parentsOffset + 4 + 4 * i);
- const char *aParent = cacheFile->getCharStar(parentOffset);
- result.append(QString::fromLatin1(aParent));
- }
- break;
+ const int parentListOffset = m_cacheFile->getUint32(PosParentListOffset);
+ const int numEntries = m_cacheFile->getUint32(parentListOffset);
+
+ int begin = 0;
+ int end = numEntries - 1;
+ while (begin <= end) {
+ const int medium = (begin + end) / 2;
+ const int off = parentListOffset + 4 + 8 * medium;
+ const int mimeOffset = m_cacheFile->getUint32(off);
+ const char *aMime = m_cacheFile->getCharStar(mimeOffset);
+ const int cmp = qstrcmp(aMime, mimeStr);
+ if (cmp < 0) {
+ begin = medium + 1;
+ } else if (cmp > 0) {
+ end = medium - 1;
+ } else {
+ const int parentsOffset = m_cacheFile->getUint32(off + 4);
+ const int numParents = m_cacheFile->getUint32(parentsOffset);
+ for (int i = 0; i < numParents; ++i) {
+ const int parentOffset = m_cacheFile->getUint32(parentsOffset + 4 + 4 * i);
+ const char *aParent = m_cacheFile->getCharStar(parentOffset);
+ const QString strParent = QString::fromLatin1(aParent);
+ if (!result.contains(strParent))
+ result.append(strParent);
}
+ break;
}
}
- if (result.isEmpty()) {
- const QString parent = fallbackParent(mime);
- if (!parent.isEmpty())
- result.append(parent);
- }
- return result;
}
QString QMimeBinaryProvider::resolveAlias(const QString &name)
{
- checkCache();
const QByteArray input = name.toLatin1();
- for (CacheFile *cacheFile : qAsConst(m_cacheFiles)) {
- const int aliasListOffset = cacheFile->getUint32(PosAliasListOffset);
- const int numEntries = cacheFile->getUint32(aliasListOffset);
- int begin = 0;
- int end = numEntries - 1;
- while (begin <= end) {
- const int medium = (begin + end) / 2;
- const int off = aliasListOffset + 4 + 8 * medium;
- const int aliasOffset = cacheFile->getUint32(off);
- const char *alias = cacheFile->getCharStar(aliasOffset);
- const int cmp = qstrcmp(alias, input);
- if (cmp < 0) {
- begin = medium + 1;
- } else if (cmp > 0) {
- end = medium - 1;
- } else {
- const int mimeOffset = cacheFile->getUint32(off + 4);
- const char *mimeType = cacheFile->getCharStar(mimeOffset);
- return QLatin1String(mimeType);
- }
+ const int aliasListOffset = m_cacheFile->getUint32(PosAliasListOffset);
+ const int numEntries = m_cacheFile->getUint32(aliasListOffset);
+ int begin = 0;
+ int end = numEntries - 1;
+ while (begin <= end) {
+ const int medium = (begin + end) / 2;
+ const int off = aliasListOffset + 4 + 8 * medium;
+ const int aliasOffset = m_cacheFile->getUint32(off);
+ const char *alias = m_cacheFile->getCharStar(aliasOffset);
+ const int cmp = qstrcmp(alias, input);
+ if (cmp < 0) {
+ begin = medium + 1;
+ } else if (cmp > 0) {
+ end = medium - 1;
+ } else {
+ const int mimeOffset = m_cacheFile->getUint32(off + 4);
+ const char *mimeType = m_cacheFile->getCharStar(mimeOffset);
+ return QLatin1String(mimeType);
}
}
-
return name;
}
-QStringList QMimeBinaryProvider::listAliases(const QString &name)
+void QMimeBinaryProvider::addAliases(const QString &name, QStringList &result)
{
- checkCache();
- QStringList result;
const QByteArray input = name.toLatin1();
- for (CacheFile *cacheFile : qAsConst(m_cacheFiles)) {
- const int aliasListOffset = cacheFile->getUint32(PosAliasListOffset);
- const int numEntries = cacheFile->getUint32(aliasListOffset);
- for (int pos = 0; pos < numEntries; ++pos) {
- const int off = aliasListOffset + 4 + 8 * pos;
- const int mimeOffset = cacheFile->getUint32(off + 4);
- const char *mimeType = cacheFile->getCharStar(mimeOffset);
-
- if (input == mimeType) {
- const int aliasOffset = cacheFile->getUint32(off);
- const char *alias = cacheFile->getCharStar(aliasOffset);
- result.append(QString::fromLatin1(alias));
- }
+ const int aliasListOffset = m_cacheFile->getUint32(PosAliasListOffset);
+ const int numEntries = m_cacheFile->getUint32(aliasListOffset);
+ for (int pos = 0; pos < numEntries; ++pos) {
+ const int off = aliasListOffset + 4 + 8 * pos;
+ const int mimeOffset = m_cacheFile->getUint32(off + 4);
+ const char *mimeType = m_cacheFile->getCharStar(mimeOffset);
+
+ if (input == mimeType) {
+ const int aliasOffset = m_cacheFile->getUint32(off);
+ const char *alias = m_cacheFile->getCharStar(aliasOffset);
+ const QString strAlias = QString::fromLatin1(alias);
+ if (!result.contains(strAlias))
+ result.append(strAlias);
}
}
- return result;
}
void QMimeBinaryProvider::loadMimeTypeList()
@@ -533,31 +431,30 @@ void QMimeBinaryProvider::loadMimeTypeList()
m_mimetypeNames.clear();
// Unfortunately mime.cache doesn't have a full list of all mimetypes.
// So we have to parse the plain-text files called "types".
- const QStringList typesFilenames = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QLatin1String("mime/types"));
- for (const QString &typeFilename : typesFilenames) {
- QFile file(typeFilename);
- if (file.open(QIODevice::ReadOnly)) {
- QTextStream stream(&file);
- stream.setCodec("ISO 8859-1");
- QString line;
- while (stream.readLineInto(&line))
- m_mimetypeNames.insert(line);
- }
+ QFile file(m_directory + QStringLiteral("/types"));
+ if (file.open(QIODevice::ReadOnly)) {
+ QTextStream stream(&file);
+ stream.setCodec("ISO 8859-1");
+ QString line;
+ while (stream.readLineInto(&line))
+ m_mimetypeNames.insert(line);
}
}
}
-QList<QMimeType> QMimeBinaryProvider::allMimeTypes()
+void QMimeBinaryProvider::addAllMimeTypes(QList<QMimeType> &result)
{
- QList<QMimeType> result;
loadMimeTypeList();
- result.reserve(m_mimetypeNames.count());
-
- for (QSet<QString>::const_iterator it = m_mimetypeNames.constBegin();
- it != m_mimetypeNames.constEnd(); ++it)
- result.append(mimeTypeForNameUnchecked(*it));
-
- return result;
+ if (result.isEmpty()) {
+ result.reserve(m_mimetypeNames.count());
+ for (const QString &name : m_mimetypeNames)
+ result.append(mimeTypeForNameUnchecked(name));
+ } else {
+ for (const QString &name : m_mimetypeNames)
+ if (std::find_if(result.constBegin(), result.constEnd(), [name](const QMimeType &mime) -> bool { return mime.name() == name; })
+ == result.constEnd())
+ result.append(mimeTypeForNameUnchecked(name));
+ }
}
void QMimeBinaryProvider::loadMimeTypePrivate(QMimeTypePrivate &data)
@@ -681,36 +578,29 @@ QLatin1String QMimeBinaryProvider::iconForMime(CacheFile *cacheFile, int posList
void QMimeBinaryProvider::loadIcon(QMimeTypePrivate &data)
{
- checkCache();
const QByteArray inputMime = data.name.toLatin1();
- for (CacheFile *cacheFile : qAsConst(m_cacheFiles)) {
- const QLatin1String icon = iconForMime(cacheFile, PosIconsListOffset, inputMime);
- if (!icon.isEmpty()) {
- data.iconName = icon;
- return;
- }
+ const QLatin1String icon = iconForMime(m_cacheFile, PosIconsListOffset, inputMime);
+ if (!icon.isEmpty()) {
+ data.iconName = icon;
}
}
void QMimeBinaryProvider::loadGenericIcon(QMimeTypePrivate &data)
{
- checkCache();
const QByteArray inputMime = data.name.toLatin1();
- for (CacheFile *cacheFile : qAsConst(m_cacheFiles)) {
- const QLatin1String icon = iconForMime(cacheFile, PosGenericIconsListOffset, inputMime);
- if (!icon.isEmpty()) {
- data.genericIconName = icon;
- return;
- }
+ const QLatin1String icon = iconForMime(m_cacheFile, PosGenericIconsListOffset, inputMime);
+ if (!icon.isEmpty()) {
+ data.genericIconName = icon;
}
}
////
-QMimeXMLProvider::QMimeXMLProvider(QMimeDatabasePrivate *db)
- : QMimeProviderBase(db), m_loaded(false)
+QMimeXMLProvider::QMimeXMLProvider(QMimeDatabasePrivate *db, const QString &directory)
+ : QMimeProviderBase(db, directory)
{
initResources();
+ ensureLoaded();
}
QMimeXMLProvider::~QMimeXMLProvider()
@@ -719,81 +609,63 @@ QMimeXMLProvider::~QMimeXMLProvider()
bool QMimeXMLProvider::isValid()
{
+ // If you change this method, adjust the logic in QMimeDatabasePrivate::loadProviders,
+ // which assumes isValid==false is only possible in QMimeBinaryProvider.
return true;
}
QMimeType QMimeXMLProvider::mimeTypeForName(const QString &name)
{
- ensureLoaded();
-
return m_nameMimeTypeMap.value(name);
}
-QMimeGlobMatchResult QMimeXMLProvider::findByFileName(const QString &fileName)
+void QMimeXMLProvider::addFileNameMatches(const QString &fileName, QMimeGlobMatchResult &result)
{
- ensureLoaded();
-
- return m_mimeTypeGlobs.matchingGlobs(fileName);
+ m_mimeTypeGlobs.matchingGlobs(fileName, result);
}
-QMimeType QMimeXMLProvider::findByMagic(const QByteArray &data, int *accuracyPtr)
+void QMimeXMLProvider::findByMagic(const QByteArray &data, int *accuracyPtr, QMimeType &candidate)
{
- ensureLoaded();
-
- QString candidate;
-
+ QString candidateName;
+ bool foundOne = false;
for (const QMimeMagicRuleMatcher &matcher : qAsConst(m_magicMatchers)) {
if (matcher.matches(data)) {
const int priority = matcher.priority();
if (priority > *accuracyPtr) {
*accuracyPtr = priority;
- candidate = matcher.mimetype();
+ candidateName = matcher.mimetype();
+ foundOne = true;
}
}
}
- return mimeTypeForName(candidate);
+ if (foundOne)
+ candidate = mimeTypeForName(candidateName);
}
void QMimeXMLProvider::ensureLoaded()
{
- if (!m_loaded || shouldCheck()) {
- bool fdoXmlFound = false;
- QStringList allFiles;
-
- const QStringList packageDirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QLatin1String("mime/packages"), QStandardPaths::LocateDirectory);
- //qDebug() << "packageDirs=" << packageDirs;
- for (const QString &packageDir : packageDirs) {
- QDir dir(packageDir);
- const QStringList files = dir.entryList(QDir::Files | QDir::NoDotAndDotDot);
- //qDebug() << static_cast<const void *>(this) << packageDir << files;
- if (!fdoXmlFound)
- fdoXmlFound = files.contains(QLatin1String("freedesktop.org.xml"));
- QStringList::const_iterator endIt(files.constEnd());
- for (QStringList::const_iterator it(files.constBegin()); it != endIt; ++it) {
- allFiles.append(packageDir + QLatin1Char('/') + *it);
- }
- }
-
- if (!fdoXmlFound) {
- // We could instead install the file as part of installing Qt?
- allFiles.prepend(QLatin1String(":/qt-project.org/qmime/freedesktop.org.xml"));
- }
+ QStringList allFiles;
+ const QString packageDir = m_directory + QStringLiteral("/packages");
+ QDir dir(packageDir);
+ const QStringList files = dir.entryList(QDir::Files | QDir::NoDotAndDotDot);
+ allFiles.reserve(files.count());
+ for (const QString &xmlFile : files)
+ allFiles.append(packageDir + QLatin1Char('/') + xmlFile);
- if (m_allFiles == allFiles)
- return;
- m_allFiles = allFiles;
+ if (m_allFiles == allFiles)
+ return;
+ m_allFiles = allFiles;
- m_nameMimeTypeMap.clear();
- m_aliases.clear();
- m_parents.clear();
- m_mimeTypeGlobs.clear();
- m_magicMatchers.clear();
+ m_nameMimeTypeMap.clear();
+ m_aliases.clear();
+ m_parents.clear();
+ m_mimeTypeGlobs.clear();
+ m_magicMatchers.clear();
- //qDebug() << "Loading" << m_allFiles;
+ //qDebug() << "Loading" << m_allFiles;
- for (const QString &file : qAsConst(allFiles))
- load(file);
- }
+ for (const QString &file : qAsConst(allFiles))
+ load(file);
}
void QMimeXMLProvider::load(const QString &fileName)
@@ -805,8 +677,6 @@ void QMimeXMLProvider::load(const QString &fileName)
bool QMimeXMLProvider::load(const QString &fileName, QString *errorMessage)
{
- m_loaded = true;
-
QFile file(fileName);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
if (errorMessage)
@@ -828,19 +698,16 @@ void QMimeXMLProvider::addGlobPattern(const QMimeGlobPattern &glob)
void QMimeXMLProvider::addMimeType(const QMimeType &mt)
{
+ Q_ASSERT(!mt.d.data()->fromCache);
m_nameMimeTypeMap.insert(mt.name(), mt);
}
-QStringList QMimeXMLProvider::parents(const QString &mime)
+void QMimeXMLProvider::addParents(const QString &mime, QStringList &result)
{
- ensureLoaded();
- QStringList result = m_parents.value(mime);
- if (result.isEmpty()) {
- const QString parent = fallbackParent(mime);
- if (!parent.isEmpty())
+ for (const QString &parent : m_parents.value(mime)) {
+ if (!result.contains(parent))
result.append(parent);
}
- return result;
}
void QMimeXMLProvider::addParent(const QString &child, const QString &parent)
@@ -848,16 +715,20 @@ void QMimeXMLProvider::addParent(const QString &child, const QString &parent)
m_parents[child].append(parent);
}
-QStringList QMimeXMLProvider::listAliases(const QString &name)
+void QMimeXMLProvider::addAliases(const QString &name, QStringList &result)
{
- ensureLoaded();
// Iterate through the whole hash. This method is rarely used.
- return m_aliases.keys(name);
+ for (auto it = m_aliases.constBegin(), end = m_aliases.constEnd() ; it != end ; ++it) {
+ if (it.value() == name) {
+ if (!result.contains(it.key()))
+ result.append(it.key());
+ }
+ }
+
}
QString QMimeXMLProvider::resolveAlias(const QString &name)
{
- ensureLoaded();
return m_aliases.value(name, name);
}
@@ -866,10 +737,18 @@ void QMimeXMLProvider::addAlias(const QString &alias, const QString &name)
m_aliases.insert(alias, name);
}
-QList<QMimeType> QMimeXMLProvider::allMimeTypes()
+void QMimeXMLProvider::addAllMimeTypes(QList<QMimeType> &result)
{
- ensureLoaded();
- return m_nameMimeTypeMap.values();
+ if (result.isEmpty()) { // fast path
+ result = m_nameMimeTypeMap.values();
+ } else {
+ for (auto it = m_nameMimeTypeMap.constBegin(), end = m_nameMimeTypeMap.constEnd() ; it != end ; ++it) {
+ const QString newMime = it.key();
+ if (std::find_if(result.constBegin(), result.constEnd(), [newMime](const QMimeType &mime) -> bool { return mime.name() == newMime; })
+ == result.constEnd())
+ result.append(it.value());
+ }
+ }
}
void QMimeXMLProvider::addMagicMatcher(const QMimeMagicRuleMatcher &matcher)
diff --git a/src/corelib/mimetypes/qmimeprovider_p.h b/src/corelib/mimetypes/qmimeprovider_p.h
index 0be01d2fd0..b2be545cf8 100644
--- a/src/corelib/mimetypes/qmimeprovider_p.h
+++ b/src/corelib/mimetypes/qmimeprovider_p.h
@@ -59,7 +59,6 @@
#include "qmimeglobpattern_p.h"
#include <QtCore/qdatetime.h>
#include <QtCore/qset.h>
-#include <QtCore/qelapsedtimer.h>
QT_BEGIN_NAMESPACE
@@ -68,25 +67,25 @@ class QMimeMagicRuleMatcher;
class QMimeProviderBase
{
public:
- QMimeProviderBase(QMimeDatabasePrivate *db);
+ QMimeProviderBase(QMimeDatabasePrivate *db, const QString &directory);
virtual ~QMimeProviderBase() {}
virtual bool isValid() = 0;
virtual QMimeType mimeTypeForName(const QString &name) = 0;
- virtual QMimeGlobMatchResult findByFileName(const QString &fileName) = 0;
- virtual QStringList parents(const QString &mime) = 0;
+ virtual void addFileNameMatches(const QString &fileName, QMimeGlobMatchResult &result) = 0;
+ virtual void addParents(const QString &mime, QStringList &result) = 0;
virtual QString resolveAlias(const QString &name) = 0;
- virtual QStringList listAliases(const QString &name) = 0;
- virtual QMimeType findByMagic(const QByteArray &data, int *accuracyPtr) = 0;
- virtual QList<QMimeType> allMimeTypes() = 0;
- virtual void loadMimeTypePrivate(QMimeTypePrivate &) {}
+ virtual void addAliases(const QString &name, QStringList &result) = 0;
+ virtual void findByMagic(const QByteArray &data, int *accuracyPtr, QMimeType &candidate) = 0;
+ virtual void addAllMimeTypes(QList<QMimeType> &result) = 0;
virtual void loadIcon(QMimeTypePrivate &) {}
virtual void loadGenericIcon(QMimeTypePrivate &) {}
+ virtual void ensureLoaded() {}
+
+ QString directory() const { return m_directory; }
QMimeDatabasePrivate *m_db;
-protected:
- bool shouldCheck();
- QElapsedTimer m_lastCheck;
+ QString m_directory;
};
/*
@@ -95,20 +94,21 @@ protected:
class QMimeBinaryProvider : public QMimeProviderBase
{
public:
- QMimeBinaryProvider(QMimeDatabasePrivate *db);
+ QMimeBinaryProvider(QMimeDatabasePrivate *db, const QString &directory);
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;
+ void addFileNameMatches(const QString &fileName, QMimeGlobMatchResult &result) override;
+ void addParents(const QString &mime, QStringList &result) override;
+ virtual QString resolveAlias(const QString &name) override;
+ void addAliases(const QString &name, QStringList &result) override;
+ void findByMagic(const QByteArray &data, int *accuracyPtr, QMimeType &candidate) override;
+ void addAllMimeTypes(QList<QMimeType> &result) override;
+ static void loadMimeTypePrivate(QMimeTypePrivate &);
+ virtual void loadIcon(QMimeTypePrivate &) override;
+ virtual void loadGenericIcon(QMimeTypePrivate &) override;
+ void ensureLoaded() override;
private:
struct CacheFile;
@@ -118,15 +118,9 @@ private:
bool matchMagicRule(CacheFile *cacheFile, int numMatchlets, int firstOffset, const QByteArray &data);
QLatin1String iconForMime(CacheFile *cacheFile, int posListOffset, const QByteArray &inputMime);
void loadMimeTypeList();
- void checkCache();
-
- class CacheFileList : public QList<CacheFile *>
- {
- public:
- CacheFile *findCacheFile(const QString &fileName) const;
- bool checkCacheChanged();
- };
- CacheFileList m_cacheFiles;
+ bool checkCacheChanged();
+
+ CacheFile *m_cacheFile = nullptr;
QStringList m_cacheFileNames;
QSet<QString> m_mimetypeNames;
bool m_mimetypeListLoaded;
@@ -138,17 +132,18 @@ private:
class QMimeXMLProvider : public QMimeProviderBase
{
public:
- QMimeXMLProvider(QMimeDatabasePrivate *db);
+ QMimeXMLProvider(QMimeDatabasePrivate *db, const QString &directory);
~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;
+ void addFileNameMatches(const QString &fileName, QMimeGlobMatchResult &result) override;
+ void addParents(const QString &mime, QStringList &result) override;
+ virtual QString resolveAlias(const QString &name) override;
+ void addAliases(const QString &name, QStringList &result) override;
+ void findByMagic(const QByteArray &data, int *accuracyPtr, QMimeType &candidate) override;
+ void addAllMimeTypes(QList<QMimeType> &result) override;
+ void ensureLoaded() override;
bool load(const QString &fileName, QString *errorMessage);
@@ -160,11 +155,8 @@ public:
void addMagicMatcher(const QMimeMagicRuleMatcher &matcher);
private:
- void ensureLoaded();
void load(const QString &fileName);
- bool m_loaded;
-
typedef QHash<QString, QMimeType> NameMimeTypeMap;
NameMimeTypeMap m_nameMimeTypeMap;
diff --git a/src/corelib/mimetypes/qmimetype.cpp b/src/corelib/mimetypes/qmimetype.cpp
index 28113babfe..8f6237c1cb 100644
--- a/src/corelib/mimetypes/qmimetype.cpp
+++ b/src/corelib/mimetypes/qmimetype.cpp
@@ -57,7 +57,7 @@
QT_BEGIN_NAMESPACE
QMimeTypePrivate::QMimeTypePrivate()
- : loaded(false)
+ : loaded(false), fromCache(false)
{}
QMimeTypePrivate::QMimeTypePrivate(const QMimeType &other)
@@ -76,7 +76,6 @@ void QMimeTypePrivate::clear()
genericIconName.clear();
iconName.clear();
globPatterns.clear();
- loaded = false;
}
void QMimeTypePrivate::addGlobPattern(const QString &pattern)
@@ -256,7 +255,7 @@ QString QMimeType::name() const
*/
QString QMimeType::comment() const
{
- QMimeDatabasePrivate::instance()->provider()->loadMimeTypePrivate(*d);
+ QMimeDatabasePrivate::instance()->loadMimeTypePrivate(*d);
QStringList languageList;
languageList << QLocale().name();
@@ -296,7 +295,7 @@ QString QMimeType::comment() const
*/
QString QMimeType::genericIconName() const
{
- QMimeDatabasePrivate::instance()->provider()->loadGenericIcon(*d);
+ QMimeDatabasePrivate::instance()->loadGenericIcon(*d);
if (d->genericIconName.isEmpty()) {
// From the spec:
// If the generic icon name is empty (not specified by the mimetype definition)
@@ -324,7 +323,7 @@ QString QMimeType::genericIconName() const
*/
QString QMimeType::iconName() const
{
- QMimeDatabasePrivate::instance()->provider()->loadIcon(*d);
+ QMimeDatabasePrivate::instance()->loadIcon(*d);
if (d->iconName.isEmpty()) {
// Make default icon name from the mimetype name
d->iconName = name();
@@ -344,7 +343,7 @@ QString QMimeType::iconName() const
*/
QStringList QMimeType::globPatterns() const
{
- QMimeDatabasePrivate::instance()->provider()->loadMimeTypePrivate(*d);
+ QMimeDatabasePrivate::instance()->loadMimeTypePrivate(*d);
return d->globPatterns;
}
@@ -368,12 +367,12 @@ QStringList QMimeType::globPatterns() const
*/
QStringList QMimeType::parentMimeTypes() const
{
- return QMimeDatabasePrivate::instance()->provider()->parents(d->name);
+ return QMimeDatabasePrivate::instance()->mimeParents(d->name);
}
static void collectParentMimeTypes(const QString &mime, QStringList &allParents)
{
- const QStringList parents = QMimeDatabasePrivate::instance()->provider()->parents(mime);
+ const QStringList parents = QMimeDatabasePrivate::instance()->mimeParents(mime);
for (const QString &parent : parents) {
// I would use QSet, but since order matters I better not
if (!allParents.contains(parent))
@@ -425,7 +424,7 @@ QStringList QMimeType::allAncestors() const
*/
QStringList QMimeType::aliases() const
{
- return QMimeDatabasePrivate::instance()->provider()->listAliases(d->name);
+ return QMimeDatabasePrivate::instance()->listAliases(d->name);
}
/*!
@@ -439,7 +438,7 @@ QStringList QMimeType::aliases() const
*/
QStringList QMimeType::suffixes() const
{
- QMimeDatabasePrivate::instance()->provider()->loadMimeTypePrivate(*d);
+ QMimeDatabasePrivate::instance()->loadMimeTypePrivate(*d);
QStringList result;
for (const QString &pattern : qAsConst(d->globPatterns)) {
@@ -480,7 +479,7 @@ QString QMimeType::preferredSuffix() const
*/
QString QMimeType::filterString() const
{
- QMimeDatabasePrivate::instance()->provider()->loadMimeTypePrivate(*d);
+ QMimeDatabasePrivate::instance()->loadMimeTypePrivate(*d);
QString filter;
if (!d->globPatterns.empty()) {
@@ -508,7 +507,7 @@ bool QMimeType::inherits(const QString &mimeTypeName) const
{
if (d->name == mimeTypeName)
return true;
- return QMimeDatabasePrivate::instance()->inherits(d->name, mimeTypeName);
+ return QMimeDatabasePrivate::instance()->mimeInherits(d->name, mimeTypeName);
}
#ifndef QT_NO_DEBUG_STREAM
diff --git a/src/corelib/mimetypes/qmimetype_p.h b/src/corelib/mimetypes/qmimetype_p.h
index b0bfad2f65..aa38a1adf5 100644
--- a/src/corelib/mimetypes/qmimetype_p.h
+++ b/src/corelib/mimetypes/qmimetype_p.h
@@ -74,6 +74,7 @@ public:
void addGlobPattern(const QString &pattern);
bool loaded; // QSharedData leaves a 4 byte gap, so don't put 8 byte members first
+ bool fromCache; // true if this comes from the binary provider
QString name;
LocaleHash localeComments;
QString genericIconName;
@@ -94,6 +95,7 @@ QT_END_NAMESPACE
{ \
QMimeTypePrivate qMimeTypeData; \
qMimeTypeData.name = name; \
+ qMimeTypeData.loaded = true; \
qMimeTypeData.genericIconName = genericIconName; \
qMimeTypeData.iconName = iconName; \
qMimeTypeData.globPatterns = globPatterns; \
@@ -112,6 +114,7 @@ QT_END_NAMESPACE
) \
{ \
QMimeTypePrivate qMimeTypeData; \
+ qMimeTypeData.loaded = true; \
qMimeTypeData.name = std::move(name); \
qMimeTypeData.genericIconName = std::move(genericIconName); \
qMimeTypeData.iconName = std::move(iconName); \
diff --git a/src/corelib/mimetypes/qmimetypeparser.cpp b/src/corelib/mimetypes/qmimetypeparser.cpp
index 5ecd339908..0a55560ab0 100644
--- a/src/corelib/mimetypes/qmimetypeparser.cpp
+++ b/src/corelib/mimetypes/qmimetypeparser.cpp
@@ -201,6 +201,7 @@ bool QMimeTypeParserBase::parse(QIODevice *dev, const QString &fileName, QString
return false;
#else
QMimeTypePrivate data;
+ data.loaded = true;
int priority = 50;
QStack<QMimeMagicRule *> currentRules; // stack for the nesting of rules
QList<QMimeMagicRule> rules; // toplevel rules
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/plugin/quuid.h b/src/corelib/plugin/quuid.h
index 9e1a35f492..ee0a9f9dac 100644
--- a/src/corelib/plugin/quuid.h
+++ b/src/corelib/plugin/quuid.h
@@ -42,7 +42,7 @@
#include <QtCore/qstring.h>
-#if defined(Q_OS_WIN)
+#if defined(Q_OS_WIN) || defined(Q_CLANG_QDOC)
#ifndef GUID_DEFINED
#define GUID_DEFINED
typedef struct _GUID
@@ -55,7 +55,7 @@ typedef struct _GUID
#endif
#endif
-#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
+#if defined(Q_OS_DARWIN) || defined(Q_CLANG_QDOC)
Q_FORWARD_DECLARE_CF_TYPE(CFUUID);
Q_FORWARD_DECLARE_OBJC_CLASS(NSUUID);
#endif
@@ -85,7 +85,7 @@ public:
Sha1 = 5 // 0 1 0 1
};
-#if defined(Q_COMPILER_UNIFORM_INIT) && !defined(Q_QDOC)
+#if defined(Q_COMPILER_UNIFORM_INIT) && !defined(Q_CLANG_QDOC)
Q_DECL_CONSTEXPR QUuid() Q_DECL_NOTHROW : data1(0), data2(0), data3(0), data4{0,0,0,0,0,0,0,0} {}
Q_DECL_CONSTEXPR QUuid(uint l, ushort w1, ushort w2, uchar b1, uchar b2, uchar b3,
@@ -148,10 +148,10 @@ public:
bool operator<(const QUuid &other) const Q_DECL_NOTHROW;
bool operator>(const QUuid &other) const Q_DECL_NOTHROW;
-#if defined(Q_OS_WIN)
+#if defined(Q_OS_WIN) || defined(Q_CLANG_QDOC)
// On Windows we have a type GUID that is used by the platform API, so we
// provide convenience operators to cast from and to this type.
-#if defined(Q_COMPILER_UNIFORM_INIT) && !defined(Q_QDOC)
+#if defined(Q_COMPILER_UNIFORM_INIT) && !defined(Q_CLANG_QDOC)
Q_DECL_CONSTEXPR QUuid(const GUID &guid) Q_DECL_NOTHROW
: data1(guid.Data1), data2(guid.Data2), data3(guid.Data3),
data4{guid.Data4[0], guid.Data4[1], guid.Data4[2], guid.Data4[3],
@@ -208,7 +208,7 @@ public:
QUuid::Variant variant() const Q_DECL_NOTHROW;
QUuid::Version version() const Q_DECL_NOTHROW;
-#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
+#if defined(Q_OS_DARWIN) || defined(Q_CLANG_QDOC)
static QUuid fromCFUUID(CFUUIDRef uuid);
CFUUIDRef toCFUUID() const Q_DECL_CF_RETURNS_RETAINED;
static QUuid fromNSUUID(const NSUUID *uuid);
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 c2b5afd241..24734f99ac 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.cpp b/src/corelib/thread/qatomic.cpp
index ccb0ee6923..c161bec537 100644
--- a/src/corelib/thread/qatomic.cpp
+++ b/src/corelib/thread/qatomic.cpp
@@ -239,17 +239,17 @@
Constructs a QAtomicInt with the given \a value.
*/
-/*! \fn QAtomicInteger::QAtomicInteger(T value)
+/*! \fn QAtomicInteger<T>::QAtomicInteger(T value)
Constructs a QAtomicInteger with the given \a value.
*/
-/*! \fn QAtomicInteger::QAtomicInteger(const QAtomicInteger &other)
+/*! \fn template <typename T> QAtomicInteger<T>::QAtomicInteger(const QAtomicInteger &other)
Constructs a copy of \a other.
*/
-/*! \fn QAtomicInteger &QAtomicInteger::operator=(const QAtomicInteger &other)
+/*! \fn template <typename T> QAtomicInteger &QAtomicInteger<T>::operator=(const QAtomicInteger &other)
Assigns \a other to this QAtomicInteger and returns a reference to
this QAtomicInteger.
@@ -257,7 +257,7 @@
/*!
- \fn T QAtomicInteger::load() const
+ \fn template <typename T> T QAtomicInteger<T>::load() const
Atomically loads the value of this QAtomicInteger using relaxed memory
ordering. The value is not modified in any way, but note that there's no
@@ -267,7 +267,7 @@
*/
/*!
- \fn T QAtomicInteger::loadAcquire() const
+ \fn template <typename T> T QAtomicInteger<T>::loadAcquire() const
Atomically loads the value of this QAtomicInteger using the "Acquire" memory
ordering. The value is not modified in any way, but note that there's no
@@ -277,7 +277,7 @@
*/
/*!
- \fn void QAtomicInteger::store(T newValue)
+ \fn template <typename T> void QAtomicInteger<T>::store(T newValue)
Atomically stores the \a newValue value into this atomic type, using
relaxed memory ordering.
@@ -286,7 +286,7 @@
*/
/*!
- \fn void QAtomicInteger::storeRelease(T newValue)
+ \fn template <typename T> void QAtomicInteger<T>::storeRelease(T newValue)
Atomically stores the \a newValue value into this atomic type, using
the "Release" memory ordering.
@@ -295,7 +295,7 @@
*/
/*!
- \fn QAtomicInteger::operator T() const
+ \fn template <typename T> QAtomicInteger<T>::operator T() const
\since 5.3
Atomically loads the value of this QAtomicInteger using a sequentially
@@ -307,29 +307,29 @@
*/
/*!
- \fn QAtomicInteger &QAtomicInteger::operator=(T newValue)
+ \fn template <typename T> QAtomicInteger &QAtomicInteger<T>::operator=(T)
\since 5.3
- Atomically stores the \a newValue value into this atomic type using a
+ Atomically stores the other value into this atomic type using a
sequentially consistent memory ordering if possible; or "Release" ordering
if not. This function returns a reference to this object.
\sa store(), storeRelease()
*/
-/*! \fn bool QAtomicInteger::isReferenceCountingNative()
+/*! \fn template <typename T> bool QAtomicInteger<T>::isReferenceCountingNative()
Returns \c true if reference counting is implemented using atomic
processor instructions, false otherwise.
*/
-/*! \fn bool QAtomicInteger::isReferenceCountingWaitFree()
+/*! \fn template <typename T> bool QAtomicInteger<T>::isReferenceCountingWaitFree()
Returns \c true if atomic reference counting is wait-free, false
otherwise.
*/
-/*! \fn bool QAtomicInteger::ref()
+/*! \fn template <typename T> bool QAtomicInteger<T>::ref()
Atomically increments the value of this QAtomicInteger. Returns \c true
if the new value is non-zero, false otherwise.
@@ -342,7 +342,7 @@
*/
/*!
- \fn T QAtomicInteger::operator++()
+ \fn template <typename T> T QAtomicInteger<T>::operator++()
\since 5.3
Atomically pre-increments the value of this QAtomicInteger. Returns the new
@@ -355,7 +355,7 @@
*/
/*!
- \fn T QAtomicInteger::operator++(int)
+ \fn template <typename T> T QAtomicInteger<T>::operator++(int)
\since 5.3
Atomically post-increments the value of this QAtomicInteger. Returns the old
@@ -367,7 +367,7 @@
\sa ref(), operator++(), operator--(int)
*/
-/*! \fn bool QAtomicInteger::deref()
+/*! \fn template <typename T> bool QAtomicInteger<T>::deref()
Atomically decrements the value of this QAtomicInteger. Returns \c true
if the new value is non-zero, false otherwise.
@@ -380,7 +380,7 @@
*/
/*!
- \fn T QAtomicInteger::operator--()
+ \fn template <typename T> T QAtomicInteger<T>::operator--()
\since 5.3
Atomically pre-decrements the value of this QAtomicInteger. Returns the new
@@ -393,7 +393,7 @@
*/
/*!
- \fn T QAtomicInteger::operator--(int)
+ \fn template <typename T> T QAtomicInteger<T>::operator--(int)
\since 5.3
Atomically post-decrements the value of this QAtomicInteger. Returns the old
@@ -405,18 +405,18 @@
\sa deref(), operator--(), operator++(int)
*/
-/*! \fn bool QAtomicInteger::isTestAndSetNative()
+/*! \fn template <typename T> bool QAtomicInteger<T>::isTestAndSetNative()
Returns \c true if test-and-set is implemented using atomic processor
instructions, false otherwise.
*/
-/*! \fn bool QAtomicInteger::isTestAndSetWaitFree()
+/*! \fn template <typename T> bool QAtomicInteger<T>::isTestAndSetWaitFree()
Returns \c true if atomic test-and-set is wait-free, false otherwise.
*/
-/*! \fn bool QAtomicInteger::testAndSetRelaxed(T expectedValue, T newValue)
+/*! \fn template <typename T> bool QAtomicInteger<T>::testAndSetRelaxed(T expectedValue, T newValue)
Atomic test-and-set.
@@ -430,7 +430,7 @@
processor to freely reorder memory accesses.
*/
-/*! \fn bool QAtomicInteger::testAndSetAcquire(T expectedValue, T newValue)
+/*! \fn template <typename T> bool QAtomicInteger<T>::testAndSetAcquire(T expectedValue, T newValue)
Atomic test-and-set.
@@ -445,7 +445,7 @@
be re-ordered before the atomic operation.
*/
-/*! \fn bool QAtomicInteger::testAndSetRelease(T expectedValue, T newValue)
+/*! \fn template <typename T> bool QAtomicInteger<T>::testAndSetRelease(T expectedValue, T newValue)
Atomic test-and-set.
@@ -460,7 +460,7 @@
re-ordered after the atomic operation.
*/
-/*! \fn bool QAtomicInteger::testAndSetOrdered(T expectedValue, T newValue)
+/*! \fn template <typename T> bool QAtomicInteger<T>::testAndSetOrdered(T expectedValue, T newValue)
Atomic test-and-set.
@@ -475,19 +475,19 @@
may not be re-ordered.
*/
-/*! \fn bool QAtomicInteger::isFetchAndStoreNative()
+/*! \fn template <typename T> bool QAtomicInteger<T>::isFetchAndStoreNative()
Returns \c true if fetch-and-store is implemented using atomic
processor instructions, false otherwise.
*/
-/*! \fn bool QAtomicInteger::isFetchAndStoreWaitFree()
+/*! \fn template <typename T> bool QAtomicInteger<T>::isFetchAndStoreWaitFree()
Returns \c true if atomic fetch-and-store is wait-free, false
otherwise.
*/
-/*! \fn T QAtomicInteger::fetchAndStoreRelaxed(T newValue)
+/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndStoreRelaxed(T newValue)
Atomic fetch-and-store.
@@ -499,7 +499,7 @@
processor to freely reorder memory accesses.
*/
-/*! \fn T QAtomicInteger::fetchAndStoreAcquire(T newValue)
+/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndStoreAcquire(T newValue)
Atomic fetch-and-store.
@@ -512,7 +512,7 @@
be re-ordered before the atomic operation.
*/
-/*! \fn T QAtomicInteger::fetchAndStoreRelease(T newValue)
+/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndStoreRelease(T newValue)
Atomic fetch-and-store.
@@ -525,7 +525,7 @@
re-ordered after the atomic operation.
*/
-/*! \fn T QAtomicInteger::fetchAndStoreOrdered(T newValue)
+/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndStoreOrdered(T newValue)
Atomic fetch-and-store.
@@ -538,19 +538,19 @@
may not be re-ordered.
*/
-/*! \fn bool QAtomicInteger::isFetchAndAddNative()
+/*! \fn template <typename T> bool QAtomicInteger<T>::isFetchAndAddNative()
Returns \c true if fetch-and-add is implemented using atomic
processor instructions, false otherwise.
*/
-/*! \fn bool QAtomicInteger::isFetchAndAddWaitFree()
+/*! \fn template <typename T> bool QAtomicInteger<T>::isFetchAndAddWaitFree()
Returns \c true if atomic fetch-and-add is wait-free, false
otherwise.
*/
-/*! \fn T QAtomicInteger::fetchAndAddRelaxed(T valueToAdd)
+/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndAddRelaxed(T valueToAdd)
Atomic fetch-and-add.
@@ -564,7 +564,7 @@
\sa operator+=(), fetchAndSubRelaxed()
*/
-/*! \fn T QAtomicInteger::fetchAndAddAcquire(T valueToAdd)
+/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndAddAcquire(T valueToAdd)
Atomic fetch-and-add.
@@ -579,7 +579,7 @@
\sa operator+=(), fetchAndSubAcquire()
*/
-/*! \fn T QAtomicInteger::fetchAndAddRelease(T valueToAdd)
+/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndAddRelease(T valueToAdd)
Atomic fetch-and-add.
@@ -594,7 +594,7 @@
\sa operator+=(), fetchAndSubRelease()
*/
-/*! \fn T QAtomicInteger::fetchAndAddOrdered(T valueToAdd)
+/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndAddOrdered(T valueToAdd)
Atomic fetch-and-add.
@@ -609,13 +609,13 @@
\sa operator+=(), fetchAndSubOrdered()
*/
-/*! \fn T QAtomicInteger::operator+=(T valueToAdd)
+/*! \fn template <typename T> T QAtomicInteger<T>::operator+=(T value)
\since 5.3
Atomic add-and-fetch.
Reads the current value of this QAtomicInteger and then adds
- \a valueToAdd to the current value, returning the new value value.
+ \a value to the current value, returning the new value.
This function uses a sequentially consistent memory ordering if possible;
or "Ordered" ordering if not.
@@ -623,7 +623,7 @@
\sa fetchAndAddOrdered(), operator-=()
*/
-/*! \fn T QAtomicInteger::fetchAndSubRelaxed(T valueToSub)
+/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndSubRelaxed(T valueToSub)
\since 5.3
Atomic fetch-and-sub.
@@ -638,7 +638,7 @@
\sa operator-=(), fetchAndAddRelaxed()
*/
-/*! \fn T QAtomicInteger::fetchAndSubAcquire(T valueToSub)
+/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndSubAcquire(T valueToSub)
\since 5.3
Atomic fetch-and-sub.
@@ -654,7 +654,7 @@
\sa operator-=(), fetchAndAddAcquire()
*/
-/*! \fn T QAtomicInteger::fetchAndSubRelease(T valueToSub)
+/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndSubRelease(T valueToSub)
\since 5.3
Atomic fetch-and-sub.
@@ -670,7 +670,7 @@
\sa operator-=(), fetchAndAddRelease()
*/
-/*! \fn T QAtomicInteger::fetchAndSubOrdered(T valueToSub)
+/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndSubOrdered(T valueToSub)
\since 5.3
Atomic fetch-and-sub.
@@ -686,13 +686,13 @@
\sa operator-=(), fetchAndAddOrdered()
*/
-/*! \fn T QAtomicInteger::operator-=(T valueToSub)
+/*! \fn template <typename T> T QAtomicInteger<T>::operator-=(T value)
\since 5.3
Atomic sub-and-fetch.
Reads the current value of this QAtomicInteger and then subtracts
- \a valueToSub to the current value, returning the new value value.
+ \a value to the current value, returning the new value.
This function uses a sequentially consistent memory ordering if possible;
or "Ordered" ordering if not.
@@ -700,7 +700,7 @@
\sa fetchAndSubOrdered(), operator+=()
*/
-/*! \fn T QAtomicInteger::fetchAndOrRelaxed(T valueToOr)
+/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndOrRelaxed(T valueToOr)
\since 5.3
Atomic fetch-and-or.
@@ -715,7 +715,7 @@
\sa operator|=()
*/
-/*! \fn T QAtomicInteger::fetchAndOrAcquire(T valueToOr)
+/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndOrAcquire(T valueToOr)
\since 5.3
Atomic fetch-and-or.
@@ -731,7 +731,7 @@
\sa operator|=()
*/
-/*! \fn T QAtomicInteger::fetchAndOrRelease(T valueToOr)
+/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndOrRelease(T valueToOr)
\since 5.3
Atomic fetch-and-or.
@@ -747,7 +747,7 @@
\sa operator|=()
*/
-/*! \fn T QAtomicInteger::fetchAndOrOrdered(T valueToOr)
+/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndOrOrdered(T valueToOr)
\since 5.3
Atomic fetch-and-or.
@@ -763,13 +763,13 @@
\sa operator|=()
*/
-/*! \fn T QAtomicInteger::operator|=(T valueToOr)
+/*! \fn template <typename T> T QAtomicInteger<T>::operator|=(T value)
\since 5.3
Atomic or-and-fetch.
Reads the current value of this QAtomicInteger and then bitwise-ORs
- \a valueToOr to the current value, returning the new value value.
+ \a value to the current value, returning the new value.
This function uses a sequentially consistent memory ordering if possible;
or "Ordered" ordering if not.
@@ -777,7 +777,7 @@
\sa fetchAndOrOrdered()
*/
-/*! \fn T QAtomicInteger::fetchAndXorRelaxed(T valueToXor)
+/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndXorRelaxed(T valueToXor)
\since 5.3
Atomic fetch-and-xor.
@@ -792,7 +792,7 @@
\sa operator^=()
*/
-/*! \fn T QAtomicInteger::fetchAndXorAcquire(T valueToXor)
+/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndXorAcquire(T valueToXor)
\since 5.3
Atomic fetch-and-xor.
@@ -808,7 +808,7 @@
\sa operator^=()
*/
-/*! \fn T QAtomicInteger::fetchAndXorRelease(T valueToXor)
+/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndXorRelease(T valueToXor)
\since 5.3
Atomic fetch-and-xor.
@@ -824,7 +824,7 @@
\sa operator^=()
*/
-/*! \fn T QAtomicInteger::fetchAndXorOrdered(T valueToXor)
+/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndXorOrdered(T valueToXor)
\since 5.3
Atomic fetch-and-xor.
@@ -840,13 +840,13 @@
\sa operator^=()
*/
-/*! \fn T QAtomicInteger::operator^=(T valueToXor)
+/*! \fn template <typename T> T QAtomicInteger<T>::operator^=(T value)
\since 5.3
Atomic xor-and-fetch.
Reads the current value of this QAtomicInteger and then bitwise-XORs
- \a valueToXor to the current value, returning the new value value.
+ \a value to the current value, returning the new value.
This function uses a sequentially consistent memory ordering if possible;
or "Ordered" ordering if not.
@@ -854,7 +854,7 @@
\sa fetchAndXorOrdered()
*/
-/*! \fn T QAtomicInteger::fetchAndAndRelaxed(T valueToAnd)
+/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndAndRelaxed(T valueToAnd)
\since 5.3
Atomic fetch-and-and.
@@ -869,7 +869,7 @@
\sa operator&=()
*/
-/*! \fn T QAtomicInteger::fetchAndAndAcquire(T valueToAnd)
+/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndAndAcquire(T valueToAnd)
\since 5.3
Atomic fetch-and-and.
@@ -885,7 +885,7 @@
\sa operator&=()
*/
-/*! \fn T QAtomicInteger::fetchAndAndRelease(T valueToAnd)
+/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndAndRelease(T valueToAnd)
\since 5.3
Atomic fetch-and-and.
@@ -901,7 +901,7 @@
\sa operator&=()
*/
-/*! \fn T QAtomicInteger::fetchAndAndOrdered(T valueToAnd)
+/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndAndOrdered(T valueToAnd)
\since 5.3
Atomic fetch-and-and.
@@ -917,13 +917,13 @@
\sa operator&=()
*/
-/*! \fn T QAtomicInteger::operator&=(T valueToAnd)
+/*! \fn template <typename T> T QAtomicInteger<T>::operator&=(T value)
\since 5.3
Atomic add-and-fetch.
Reads the current value of this QAtomicInteger and then bitwise-ANDs
- \a valueToAnd to the current value, returning the new value value.
+ \a value to the current value, returning the new value.
This function uses a sequentially consistent memory ordering if possible;
or "Ordered" ordering if not.
@@ -958,7 +958,7 @@
This macro is defined when only certain generations of the
processor support atomic reference counting. Use the
- QAtomicInteger::isReferenceCountingNative() function to check what
+ QAtomicInteger<T>::isReferenceCountingNative() function to check what
your processor supports.
\e{nn} is the size of the integer, in bits (8, 16, 32 or 64).
@@ -1001,7 +1001,7 @@
This macro is defined when only certain generations of the
processor support atomic test-and-set on integers. Use the
- QAtomicInteger::isTestAndSetNative() function to check what your
+ QAtomicInteger<T>::isTestAndSetNative() function to check what your
processor supports.
\e{nn} is the size of the integer, in bits (8, 16, 32 or 64).
@@ -1044,7 +1044,7 @@
This macro is defined when only certain generations of the
processor support atomic fetch-and-store on integers. Use the
- QAtomicInteger::isFetchAndStoreNative() function to check what your
+ QAtomicInteger<T>::isFetchAndStoreNative() function to check what your
processor supports.
\e{nn} is the size of the integer, in bits (8, 16, 32 or 64).
@@ -1087,7 +1087,7 @@
This macro is defined when only certain generations of the
processor support atomic fetch-and-add on integers. Use the
- QAtomicInteger::isFetchAndAddNative() function to check what your
+ QAtomicInteger<T>::isFetchAndAddNative() function to check what your
processor supports.
\e{nn} is the size of the integer, in bits (8, 16, 32 or 64).
@@ -1260,24 +1260,24 @@
\sa QAtomicInteger
*/
-/*! \fn QAtomicPointer::QAtomicPointer(T *value)
+/*! \fn template <typename T> QAtomicPointer<T>::QAtomicPointer(T *value)
Constructs a QAtomicPointer with the given \a value.
*/
-/*! \fn QAtomicPointer::QAtomicPointer(const QAtomicPointer<T> &other)
+/*! \fn template <typename T> QAtomicPointer<T>::QAtomicPointer(const QAtomicPointer<T> &other)
Constructs a copy of \a other.
*/
-/*! \fn QAtomicPointer<T> &QAtomicPointer::operator=(const QAtomicPointer<T> &other)
+/*! \fn template <typename T> QAtomicPointer &QAtomicPointer<T>::operator=(const QAtomicPointer &other)
Assigns \a other to this QAtomicPointer and returns a reference to
this QAtomicPointer.
*/
/*!
- \fn T *QAtomicPointer::load() const
+ \fn template <typename T> T *QAtomicPointer<T>::load() const
Atomically loads the value of this QAtomicPointer using relaxed memory
ordering. The value is not modified in any way, but note that there's no
@@ -1287,7 +1287,7 @@
*/
/*!
- \fn T *QAtomicPointer::loadAcquire() const
+ \fn template <typename T> T *QAtomicPointer<T>::loadAcquire() const
Atomically loads the value of this QAtomicPointer using the "Acquire" memory
ordering. The value is not modified in any way, but note that there's no
@@ -1297,7 +1297,7 @@
*/
/*!
- \fn void QAtomicPointer::store(T *newValue)
+ \fn template <typename T> void QAtomicPointer<T>::store(T *newValue)
Atomically stores the \a newValue value into this atomic type, using
relaxed memory ordering.
@@ -1306,7 +1306,7 @@
*/
/*!
- \fn void QAtomicPointer::storeRelease(T *newValue)
+ \fn template <typename T> void QAtomicPointer<T>::storeRelease(T *newValue)
Atomically stores the \a newValue value into this atomic type, using
the "Release" memory ordering.
@@ -1314,18 +1314,18 @@
\sa store(), load()
*/
-/*! \fn bool QAtomicPointer::isTestAndSetNative()
+/*! \fn template <typename T> bool QAtomicPointer<T>::isTestAndSetNative()
Returns \c true if test-and-set is implemented using atomic processor
instructions, false otherwise.
*/
-/*! \fn bool QAtomicPointer::isTestAndSetWaitFree()
+/*! \fn template <typename T> bool QAtomicPointer<T>::isTestAndSetWaitFree()
Returns \c true if atomic test-and-set is wait-free, false otherwise.
*/
-/*! \fn bool QAtomicPointer::testAndSetRelaxed(T *expectedValue, T *newValue)
+/*! \fn template <typename T> bool QAtomicPointer<T>::testAndSetRelaxed(T *expectedValue, T *newValue)
Atomic test-and-set.
@@ -1339,7 +1339,7 @@
processor to freely reorder memory accesses.
*/
-/*! \fn bool QAtomicPointer::testAndSetAcquire(T *expectedValue, T *newValue)
+/*! \fn template <typename T> bool QAtomicPointer<T>::testAndSetAcquire(T *expectedValue, T *newValue)
Atomic test-and-set.
@@ -1354,7 +1354,7 @@
be re-ordered before the atomic operation.
*/
-/*! \fn bool QAtomicPointer::testAndSetRelease(T *expectedValue, T *newValue)
+/*! \fn template <typename T> bool QAtomicPointer<T>::testAndSetRelease(T *expectedValue, T *newValue)
Atomic test-and-set.
@@ -1369,7 +1369,7 @@
re-ordered after the atomic operation.
*/
-/*! \fn bool QAtomicPointer::testAndSetOrdered(T *expectedValue, T *newValue)
+/*! \fn template <typename T> bool QAtomicPointer<T>::testAndSetOrdered(T *expectedValue, T *newValue)
Atomic test-and-set.
@@ -1384,19 +1384,19 @@
may not be re-ordered.
*/
-/*! \fn bool QAtomicPointer::isFetchAndStoreNative()
+/*! \fn template <typename T> bool QAtomicPointer<T>::isFetchAndStoreNative()
Returns \c true if fetch-and-store is implemented using atomic
processor instructions, false otherwise.
*/
-/*! \fn bool QAtomicPointer::isFetchAndStoreWaitFree()
+/*! \fn template <typename T> bool QAtomicPointer<T>::isFetchAndStoreWaitFree()
Returns \c true if atomic fetch-and-store is wait-free, false
otherwise.
*/
-/*! \fn T *QAtomicPointer::fetchAndStoreRelaxed(T *newValue)
+/*! \fn template <typename T> T *QAtomicPointer<T>::fetchAndStoreRelaxed(T *newValue)
Atomic fetch-and-store.
@@ -1408,7 +1408,7 @@
processor to freely reorder memory accesses.
*/
-/*! \fn T *QAtomicPointer::fetchAndStoreAcquire(T *newValue)
+/*! \fn template <typename T> T *QAtomicPointer<T>::fetchAndStoreAcquire(T *newValue)
Atomic fetch-and-store.
@@ -1421,7 +1421,7 @@
be re-ordered before the atomic operation.
*/
-/*! \fn T *QAtomicPointer::fetchAndStoreRelease(T *newValue)
+/*! \fn template <typename T> T *QAtomicPointer<T>::fetchAndStoreRelease(T *newValue)
Atomic fetch-and-store.
@@ -1434,7 +1434,7 @@
re-ordered after the atomic operation.
*/
-/*! \fn T *QAtomicPointer::fetchAndStoreOrdered(T *newValue)
+/*! \fn template <typename T> T *QAtomicPointer<T>::fetchAndStoreOrdered(T *newValue)
Atomic fetch-and-store.
@@ -1447,19 +1447,19 @@
may not be re-ordered.
*/
-/*! \fn bool QAtomicPointer::isFetchAndAddNative()
+/*! \fn template <typename T> bool QAtomicPointer<T>::isFetchAndAddNative()
Returns \c true if fetch-and-add is implemented using atomic
processor instructions, false otherwise.
*/
-/*! \fn bool QAtomicPointer::isFetchAndAddWaitFree()
+/*! \fn template <typename T> bool QAtomicPointer<T>::isFetchAndAddWaitFree()
Returns \c true if atomic fetch-and-add is wait-free, false
otherwise.
*/
-/*! \fn T *QAtomicPointer::fetchAndAddRelaxed(qptrdiff valueToAdd)
+/*! \fn template <typename T> T *QAtomicPointer<T>::fetchAndAddRelaxed(qptrdiff valueToAdd)
Atomic fetch-and-add.
@@ -1471,7 +1471,7 @@
processor to freely reorder memory accesses.
*/
-/*! \fn T *QAtomicPointer::fetchAndAddAcquire(qptrdiff valueToAdd)
+/*! \fn template <typename T> T *QAtomicPointer<T>::fetchAndAddAcquire(qptrdiff valueToAdd)
Atomic fetch-and-add.
@@ -1484,7 +1484,7 @@
be re-ordered before the atomic operation.
*/
-/*! \fn T *QAtomicPointer::fetchAndAddRelease(qptrdiff valueToAdd)
+/*! \fn template <typename T> T *QAtomicPointer<T>::fetchAndAddRelease(qptrdiff valueToAdd)
Atomic fetch-and-add.
@@ -1497,7 +1497,7 @@
re-ordered after the atomic operation.
*/
-/*! \fn T *QAtomicPointer::fetchAndAddOrdered(qptrdiff valueToAdd)
+/*! \fn template <typename T> T *QAtomicPointer<T>::fetchAndAddOrdered(qptrdiff valueToAdd)
Atomic fetch-and-add.
diff --git a/src/corelib/thread/qatomic.h b/src/corelib/thread/qatomic.h
index f9eacbf6f0..f842534c38 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/
**
@@ -79,7 +79,7 @@ public:
return *this;
}
-#ifdef Q_QDOC
+#ifdef Q_CLANG_QDOC
T load() const;
T loadAcquire() const;
void store(T newValue);
@@ -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..a3e30d5a7a 100644
--- a/src/corelib/thread/qexception.cpp
+++ b/src/corelib/thread/qexception.cpp
@@ -40,8 +40,7 @@
#include "qexception.h"
#include "QtCore/qshareddata.h"
-#ifndef QT_NO_QFUTURE
-#ifndef QT_NO_EXCEPTIONS
+#if !defined(QT_NO_EXCEPTIONS) || defined(Q_CLANG_QDOC)
QT_BEGIN_NAMESPACE
@@ -155,7 +154,7 @@ QUnhandledException *QUnhandledException::clone() const
return new QUnhandledException(*this);
}
-#ifndef Q_QDOC
+#if !defined(Q_CLANG_QDOC)
namespace QtPrivate {
@@ -171,7 +170,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 +187,7 @@ ExceptionHolder::~ExceptionHolder()
QException *ExceptionHolder::exception() const
{
if (!base)
- return Q_NULLPTR;
+ return nullptr;
return base->exception;
}
@@ -220,9 +219,8 @@ bool ExceptionStore::hasThrown() const { return exceptionHolder.base->hasThrown;
} // namespace QtPrivate
-#endif //Q_QDOC
+#endif //Q_CLANG_QDOC
QT_END_NAMESPACE
#endif // QT_NO_EXCEPTIONS
-#endif // QT_NO_QFUTURE
diff --git a/src/corelib/thread/qexception.h b/src/corelib/thread/qexception.h
index b14d386c69..d33904c1f2 100644
--- a/src/corelib/thread/qexception.h
+++ b/src/corelib/thread/qexception.h
@@ -40,10 +40,6 @@
#ifndef QTCORE_QEXCEPTION_H
#define QTCORE_QEXCEPTION_H
-#include <QtCore/qglobal.h>
-
-#ifndef QT_NO_QFUTURE
-
#include <QtCore/qatomic.h>
#include <QtCore/qshareddata.h>
@@ -51,10 +47,12 @@
# include <exception>
#endif
+QT_REQUIRE_CONFIG(future);
+
QT_BEGIN_NAMESPACE
-#ifndef QT_NO_EXCEPTIONS
+#if !defined(QT_NO_EXCEPTIONS) || defined(Q_CLANG_QDOC)
class Q_CORE_EXPORT QException : public std::exception
{
@@ -80,8 +78,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 +88,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();
@@ -128,6 +126,4 @@ public:
QT_END_NAMESPACE
-#endif // QT_NO_QFUTURE
-
#endif
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/qfuture.h b/src/corelib/thread/qfuture.h
index 1f0c747f40..af599c26db 100644
--- a/src/corelib/thread/qfuture.h
+++ b/src/corelib/thread/qfuture.h
@@ -42,11 +42,11 @@
#include <QtCore/qglobal.h>
-#ifndef QT_NO_QFUTURE
-
#include <QtCore/qfutureinterface.h>
#include <QtCore/qstring.h>
+QT_REQUIRE_CONFIG(future);
+
QT_BEGIN_NAMESPACE
@@ -65,6 +65,11 @@ public:
explicit QFuture(QFutureInterface<T> *p) // internal
: d(*p)
{ }
+#if defined(Q_CLANG_QDOC)
+ ~QFuture() { }
+ QFuture(const QFuture<T> &) { }
+ QFuture<T> & operator=(const QFuture<T> &) { }
+#endif
bool operator==(const QFuture &other) const { return (d == other.d); }
bool operator!=(const QFuture &other) const { return (d != other.d); }
@@ -242,6 +247,4 @@ QFuture<void> qToVoidFuture(const QFuture<T> &future)
QT_END_NAMESPACE
-#endif // QT_NO_QFUTURE
-
#endif // QFUTURE_H
diff --git a/src/corelib/thread/qfuture.qdoc b/src/corelib/thread/qfuture.qdoc
index 25306d5564..8d5b7c776c 100644
--- a/src/corelib/thread/qfuture.qdoc
+++ b/src/corelib/thread/qfuture.qdoc
@@ -93,23 +93,23 @@
\sa QFutureWatcher, {Qt Concurrent}
*/
-/*! \fn QFuture::QFuture()
+/*! \fn template <typename T> QFuture<T>::QFuture()
Constructs an empty, canceled future.
*/
-/*! \fn QFuture::QFuture(const QFuture &other)
+/*! \fn template <typename T> QFuture<T>::QFuture(const QFuture<T> &other)
Constructs a copy of \a other.
\sa operator=()
*/
-/*! \fn QFuture::QFuture(QFutureInterface<T> *resultHolder)
+/*! \fn template <typename T> QFuture<T>::QFuture(QFutureInterface<T> *resultHolder)
\internal
*/
-/*! \fn QFuture::~QFuture()
+/*! \fn template <typename T> QFuture<T>::~QFuture()
Destroys the future.
@@ -118,23 +118,23 @@
computation is completed before the future is destroyed.
*/
-/*! \fn QFuture &QFuture::operator=(const QFuture &other)
+/*! \fn template <typename T> QFuture<T> &QFuture<T>::operator=(const QFuture<T> &other)
Assigns \a other to this future and returns a reference to this future.
*/
-/*! \fn bool QFuture::operator==(const QFuture &other) const
+/*! \fn template <typename T> bool QFuture<T>::operator==(const QFuture &other) const
Returns \c true if \a other is a copy of this future; otherwise returns \c false.
*/
-/*! \fn bool QFuture::operator!=(const QFuture &other) const
+/*! \fn template <typename T> bool QFuture<T>::operator!=(const QFuture &other) const
Returns \c true if \a other is \e not a copy of this future; otherwise returns
false.
*/
-/*! \fn void QFuture::cancel()
+/*! \fn template <typename T> void QFuture<T>::cancel()
Cancels the asynchronous computation represented by this future. Note that
the cancelation is asynchronous. Use waitForFinished() after calling
@@ -150,7 +150,7 @@
but the future returned by QtConcurrent::mappedReduced() can.
*/
-/*! \fn bool QFuture::isCanceled() const
+/*! \fn template <typename T> bool QFuture<T>::isCanceled() const
Returns \c true if the asynchronous computation has been canceled with the
cancel() function; otherwise returns \c false.
@@ -159,7 +159,7 @@
function returns \c true. See cancel() for more details.
*/
-/*! \fn void QFuture::setPaused(bool paused)
+/*! \fn template <typename T> void QFuture<T>::setPaused(bool paused)
If \a paused is true, this function pauses the asynchronous computation
represented by the future. If the computation is already paused, this
@@ -178,7 +178,7 @@
\sa pause(), resume(), togglePaused()
*/
-/*! \fn bool QFuture::isPaused() const
+/*! \fn template <typename T> bool QFuture<T>::isPaused() const
Returns \c true if the asynchronous computation has been paused with the
pause() function; otherwise returns \c false.
@@ -189,7 +189,7 @@
\sa setPaused(), togglePaused()
*/
-/*! \fn void QFuture::pause()
+/*! \fn template <typename T> void QFuture<T>::pause()
Pauses the asynchronous computation represented by this future. This is a
convenience method that simply calls setPaused(true).
@@ -197,7 +197,7 @@
\sa resume()
*/
-/*! \fn void QFuture::resume()
+/*! \fn template <typename T> void QFuture<T>::resume()
Resumes the asynchronous computation represented by this future. This is a
convenience method that simply calls setPaused(false).
@@ -205,7 +205,7 @@
\sa pause()
*/
-/*! \fn void QFuture::togglePaused()
+/*! \fn template <typename T> void QFuture<T>::togglePaused()
Toggles the paused state of the asynchronous computation. In other words,
if the computation is currently paused, calling this function resumes it;
@@ -215,25 +215,25 @@
\sa setPaused(), pause(), resume()
*/
-/*! \fn bool QFuture::isStarted() const
+/*! \fn template <typename T> bool QFuture<T>::isStarted() const
Returns \c true if the asynchronous computation represented by this future
has been started; otherwise returns \c false.
*/
-/*! \fn bool QFuture::isFinished() const
+/*! \fn template <typename T> bool QFuture<T>::isFinished() const
Returns \c true if the asynchronous computation represented by this future
has finished; otherwise returns \c false.
*/
-/*! \fn bool QFuture::isRunning() const
+/*! \fn template <typename T> bool QFuture<T>::isRunning() const
Returns \c true if the asynchronous computation represented by this future is
currently running; otherwise returns \c false.
*/
-/*! \fn int QFuture::resultCount() const
+/*! \fn template <typename T> int QFuture<T>::resultCount() const
Returns the number of continuous results available in this future. The real
number of results stored might be different from this value, due to gaps
@@ -242,7 +242,7 @@
\sa result(), resultAt(), results()
*/
-/*! \fn int QFuture::progressValue() const
+/*! \fn template <typename T> int QFuture<T>::progressValue() const
Returns the current progress value, which is between the progressMinimum()
and progressMaximum().
@@ -250,21 +250,21 @@
\sa progressMinimum(), progressMaximum()
*/
-/*! \fn int QFuture::progressMinimum() const
+/*! \fn template <typename T> int QFuture<T>::progressMinimum() const
Returns the minimum progressValue().
\sa progressValue(), progressMaximum()
*/
-/*! \fn int QFuture::progressMaximum() const
+/*! \fn template <typename T> int QFuture<T>::progressMaximum() const
Returns the maximum progressValue().
\sa progressValue(), progressMinimum()
*/
-/*! \fn QString QFuture::progressText() const
+/*! \fn template <typename T> QString QFuture<T>::progressText() const
Returns the (optional) textual representation of the progress as reported
by the asynchronous computation.
@@ -273,13 +273,13 @@
progress, and as such, this function may return an empty string.
*/
-/*! \fn void QFuture::waitForFinished()
+/*! \fn template <typename T> void QFuture<T>::waitForFinished()
Waits for the asynchronous computation to finish (including cancel()ed
computations).
*/
-/*! \fn T QFuture::result() const
+/*! \fn template <typename T> T QFuture<T>::result() const
Returns the first result in the future. If the result is not immediately
available, this function will block and wait for the result to become
@@ -288,7 +288,7 @@
\sa resultAt(), results()
*/
-/*! \fn T QFuture::resultAt(int index) const
+/*! \fn template <typename T> T QFuture<T>::resultAt(int index) const
Returns the result at \a index in the future. If the result is not
immediately available, this function will block and wait for the result to
@@ -297,7 +297,7 @@
\sa result(), results(), resultCount()
*/
-/*! \fn bool QFuture::isResultReadyAt(int index) const
+/*! \fn template <typename T> bool QFuture<T>::isResultReadyAt(int index) const
Returns \c true if the result at \a index is immediately available; otherwise
returns \c false.
@@ -305,7 +305,7 @@
\sa resultAt(), resultCount()
*/
-/*! \fn QFuture::operator T() const
+/*! \fn template <typename T> QFuture<T>::operator T() const
Returns the first result in the future. If the result is not immediately
available, this function will block and wait for the result to become
@@ -315,7 +315,7 @@
\sa result(), resultAt(), results()
*/
-/*! \fn QList<T> QFuture::results() const
+/*! \fn template <typename T> QList<T> QFuture<T>::results() const
Returns all results from the future. If the results are not immediately
available, this function will block and wait for them to become available.
@@ -323,7 +323,7 @@
\sa result(), resultAt(), resultCount()
*/
-/*! \fn QFuture::const_iterator QFuture::begin() const
+/*! \fn template <typename T> QFuture<T>::const_iterator QFuture<T>::begin() const
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first result in the
future.
@@ -331,7 +331,7 @@
\sa constBegin(), end()
*/
-/*! \fn QFuture::const_iterator QFuture::end() const
+/*! \fn template <typename T> QFuture<T>::const_iterator QFuture<T>::end() const
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary result
after the last result in the future.
@@ -339,7 +339,7 @@
\sa begin(), constEnd()
*/
-/*! \fn QFuture::const_iterator QFuture::constBegin() const
+/*! \fn template <typename T> QFuture<T>::const_iterator QFuture<T>::constBegin() const
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first result in the
future.
@@ -347,7 +347,7 @@
\sa begin(), constEnd()
*/
-/*! \fn QFuture::const_iterator QFuture::constEnd() const
+/*! \fn template <typename T> QFuture<T>::const_iterator QFuture<T>::constEnd() const
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary result
after the last result in the future.
@@ -403,7 +403,7 @@
Typedef for const T &. Provided for STL compatibility.
*/
-/*! \fn QFuture::const_iterator::const_iterator()
+/*! \fn template <typename T> QFuture<T>::const_iterator::const_iterator()
Constructs an uninitialized iterator.
@@ -414,31 +414,31 @@
\sa QFuture::constBegin(), QFuture::constEnd()
*/
-/*! \fn QFuture::const_iterator::const_iterator(QFuture const * const future, int index)
+/*! \fn template <typename T> QFuture<T>::const_iterator::const_iterator(QFuture const * const future, int index)
\internal
*/
-/*! \fn QFuture::const_iterator::const_iterator(const const_iterator &other)
+/*! \fn template <typename T> QFuture<T>::const_iterator::const_iterator(const const_iterator &other)
Constructs a copy of \a other.
*/
-/*! \fn QFuture::const_iterator &QFuture::const_iterator::operator=(const const_iterator &other)
+/*! \fn template <typename T> QFuture<T>::const_iterator &QFuture<T>::const_iterator::operator=(const const_iterator &other)
Assigns \a other to this iterator.
*/
-/*! \fn const T &QFuture::const_iterator::operator*() const
+/*! \fn template <typename T> const T &QFuture<T>::const_iterator::operator*() const
Returns the current result.
*/
-/*! \fn const T *QFuture::const_iterator::operator->() const
+/*! \fn template <typename T> const T *QFuture<T>::const_iterator::operator->() const
Returns a pointer to the current result.
*/
-/*! \fn bool QFuture::const_iterator::operator!=(const const_iterator &other) const
+/*! \fn template <typename T> bool QFuture<T>::const_iterator::operator!=(const const_iterator &other) const
Returns \c true if \a other points to a different result than this iterator;
otherwise returns \c false.
@@ -446,7 +446,7 @@
\sa operator==()
*/
-/*! \fn bool QFuture::const_iterator::operator==(const const_iterator &other) const
+/*! \fn template <typename T> bool QFuture<T>::const_iterator::operator==(const const_iterator &other) const
Returns \c true if \a other points to the same result as this iterator;
otherwise returns \c false.
@@ -454,17 +454,17 @@
\sa operator!=()
*/
-/*! \fn QFuture::const_iterator &QFuture::const_iterator::operator++()
+/*! \fn template <typename T> QFuture<T>::const_iterator &QFuture<T>::const_iterator::operator++()
The prefix ++ operator (\c{++it}) advances the iterator to the next result
in the future and returns an iterator to the new current result.
- Calling this function on QFuture::constEnd() leads to undefined results.
+ Calling this function on QFuture<T>::constEnd() leads to undefined results.
\sa operator--()
*/
-/*! \fn QFuture::const_iterator QFuture::const_iterator::operator++(int)
+/*! \fn template <typename T> QFuture<T>::const_iterator QFuture<T>::const_iterator::operator++(int)
\overload
@@ -473,17 +473,17 @@
result.
*/
-/*! \fn QFuture::const_iterator &QFuture::const_iterator::operator--()
+/*! \fn template <typename T> QFuture<T>::const_iterator &QFuture<T>::const_iterator::operator--()
The prefix -- operator (\c{--it}) makes the preceding result current and
returns an iterator to the new current result.
- Calling this function on QFuture::constBegin() leads to undefined results.
+ Calling this function on QFuture<T>::constBegin() leads to undefined results.
\sa operator++()
*/
-/*! \fn QFuture::const_iterator QFuture::const_iterator::operator--(int)
+/*! \fn template <typename T> QFuture<T>::const_iterator QFuture<T>::const_iterator::operator--(int)
\overload
@@ -491,7 +491,7 @@
returns an iterator to the previously current result.
*/
-/*! \fn QFuture::const_iterator &QFuture::const_iterator::operator+=(int j)
+/*! \fn template <typename T> QFuture<T>::const_iterator &QFuture<T>::const_iterator::operator+=(int j)
Advances the iterator by \a j results. (If \a j is negative, the iterator
goes backward.)
@@ -499,7 +499,7 @@
\sa operator-=(), operator+()
*/
-/*! \fn QFuture::const_iterator &QFuture::const_iterator::operator-=(int j)
+/*! \fn template <typename T> QFuture<T>::const_iterator &QFuture<T>::const_iterator::operator-=(int j)
Makes the iterator go back by \a j results. (If \a j is negative, the
iterator goes forward.)
@@ -507,7 +507,7 @@
\sa operator+=(), operator-()
*/
-/*! \fn QFuture::const_iterator QFuture::const_iterator::operator+(int j) const
+/*! \fn template <typename T> QFuture<T>::const_iterator QFuture<T>::const_iterator::operator+(int j) const
Returns an iterator to the results at \a j positions forward from this
iterator. (If \a j is negative, the iterator goes backward.)
@@ -515,7 +515,7 @@
\sa operator-(), operator+=()
*/
-/*! \fn QFuture::const_iterator QFuture::const_iterator::operator-(int j) const
+/*! \fn template <typename T> QFuture<T>::const_iterator QFuture<T>::const_iterator::operator-(int j) const
Returns an iterator to the result at \a j positions backward from this
iterator. (If \a j is negative, the iterator goes forward.)
@@ -582,7 +582,7 @@
*/
/*!
- \fn QFutureIterator::QFutureIterator(const QFuture<T> &future)
+ \fn template <typename T> QFutureIterator<T>::QFutureIterator(const QFuture<T> &future)
Constructs an iterator for traversing \a future. The iterator is set to be
at the front of the result list (before the first result).
@@ -590,7 +590,7 @@
\sa operator=()
*/
-/*! \fn QFutureIterator &QFutureIterator::operator=(const QFuture<T> &future)
+/*! \fn template <typename T> QFutureIterator &QFutureIterator<T>::operator=(const QFuture<T> &future)
Makes the iterator operate on \a future. The iterator is set to be at the
front of the result list (before the first result).
@@ -598,7 +598,7 @@
\sa toFront(), toBack()
*/
-/*! \fn void QFutureIterator::toFront()
+/*! \fn template <typename T> void QFutureIterator<T>::toFront()
Moves the iterator to the front of the result list (before the first
result).
@@ -606,14 +606,14 @@
\sa toBack(), next()
*/
-/*! \fn void QFutureIterator::toBack()
+/*! \fn template <typename T> void QFutureIterator<T>::toBack()
Moves the iterator to the back of the result list (after the last result).
\sa toFront(), previous()
*/
-/*! \fn bool QFutureIterator::hasNext() const
+/*! \fn template <typename T> bool QFutureIterator<T>::hasNext() const
Returns \c true if there is at least one result ahead of the iterator, e.g.,
the iterator is \e not at the back of the result list; otherwise returns
@@ -622,7 +622,7 @@
\sa hasPrevious(), next()
*/
-/*! \fn const T &QFutureIterator::next()
+/*! \fn template <typename T> const T &QFutureIterator<T>::next()
Returns the next result and advances the iterator by one position.
@@ -632,7 +632,7 @@
\sa hasNext(), peekNext(), previous()
*/
-/*! \fn const T &QFutureIterator::peekNext() const
+/*! \fn template <typename T> const T &QFutureIterator<T>::peekNext() const
Returns the next result without moving the iterator.
@@ -642,7 +642,7 @@
\sa hasNext(), next(), peekPrevious()
*/
-/*! \fn bool QFutureIterator::hasPrevious() const
+/*! \fn template <typename T> bool QFutureIterator<T>::hasPrevious() const
Returns \c true if there is at least one result ahead of the iterator, e.g.,
the iterator is \e not at the front of the result list; otherwise returns
@@ -651,7 +651,7 @@
\sa hasNext(), previous()
*/
-/*! \fn const T &QFutureIterator::previous()
+/*! \fn template <typename T> const T &QFutureIterator<T>::previous()
Returns the previous result and moves the iterator back by one position.
@@ -661,7 +661,7 @@
\sa hasPrevious(), peekPrevious(), next()
*/
-/*! \fn const T &QFutureIterator::peekPrevious() const
+/*! \fn template <typename T> const T &QFutureIterator<T>::peekPrevious() const
Returns the previous result without moving the iterator.
@@ -671,7 +671,7 @@
\sa hasPrevious(), previous(), peekNext()
*/
-/*! \fn bool QFutureIterator::findNext(const T &value)
+/*! \fn template <typename T> bool QFutureIterator<T>::findNext(const T &value)
Searches for \a value starting from the current iterator position forward.
Returns \c true if \a value is found; otherwise returns \c false.
@@ -683,7 +683,7 @@
\sa findPrevious()
*/
-/*! \fn bool QFutureIterator::findPrevious(const T &value)
+/*! \fn template <typename T> bool QFutureIterator<T>::findPrevious(const T &value)
Searches for \a value starting from the current iterator position
backward. Returns \c true if \a value is found; otherwise returns \c false.
diff --git a/src/corelib/thread/qfutureinterface.cpp b/src/corelib/thread/qfutureinterface.cpp
index c62b8fd36b..8bf74ca288 100644
--- a/src/corelib/thread/qfutureinterface.cpp
+++ b/src/corelib/thread/qfutureinterface.cpp
@@ -39,9 +39,6 @@
// qfutureinterface.h included from qfuture.h
#include "qfuture.h"
-
-#ifndef QT_NO_QFUTURE
-
#include "qfutureinterface_p.h"
#include <QtCore/qatomic.h>
@@ -604,5 +601,3 @@ void QFutureInterfaceBasePrivate::setState(QFutureInterfaceBase::State newState)
}
QT_END_NAMESPACE
-
-#endif // QT_NO_QFUTURE
diff --git a/src/corelib/thread/qfutureinterface.h b/src/corelib/thread/qfutureinterface.h
index 7b12f51e3e..3dd236752c 100644
--- a/src/corelib/thread/qfutureinterface.h
+++ b/src/corelib/thread/qfutureinterface.h
@@ -41,13 +41,12 @@
#define QFUTUREINTERFACE_H
#include <QtCore/qrunnable.h>
-
-#ifndef QT_NO_QFUTURE
-
#include <QtCore/qmutex.h>
#include <QtCore/qexception.h>
#include <QtCore/qresultstore.h>
+QT_REQUIRE_CONFIG(future);
+
QT_BEGIN_NAMESPACE
@@ -291,10 +290,9 @@ 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
-#endif // QT_NO_QFUTURE
#endif // QFUTUREINTERFACE_H
diff --git a/src/corelib/thread/qfutureinterface_p.h b/src/corelib/thread/qfutureinterface_p.h
index cf882dd9b4..63e534464f 100644
--- a/src/corelib/thread/qfutureinterface_p.h
+++ b/src/corelib/thread/qfutureinterface_p.h
@@ -59,6 +59,8 @@
#include <QtCore/qrunnable.h>
#include <QtCore/qthreadpool.h>
+QT_REQUIRE_CONFIG(future);
+
QT_BEGIN_NAMESPACE
class QFutureCallOutEvent : public QEvent
diff --git a/src/corelib/thread/qfuturesynchronizer.h b/src/corelib/thread/qfuturesynchronizer.h
index 6bc2725024..5006ebb9cf 100644
--- a/src/corelib/thread/qfuturesynchronizer.h
+++ b/src/corelib/thread/qfuturesynchronizer.h
@@ -42,7 +42,7 @@
#include <QtCore/qfuture.h>
-#ifndef QT_NO_QFUTURE
+QT_REQUIRE_CONFIG(future);
QT_BEGIN_NAMESPACE
@@ -110,6 +110,5 @@ protected:
};
QT_END_NAMESPACE
-#endif // QT_NO_QFUTURE
#endif // QFUTURESYNCHRONIZER_H
diff --git a/src/corelib/thread/qfuturesynchronizer.qdoc b/src/corelib/thread/qfuturesynchronizer.qdoc
index 580eae6982..c9c402ff87 100644
--- a/src/corelib/thread/qfuturesynchronizer.qdoc
+++ b/src/corelib/thread/qfuturesynchronizer.qdoc
@@ -68,13 +68,13 @@
*/
/*!
- \fn QFutureSynchronizer::QFutureSynchronizer()
+ \fn template <typename T> QFutureSynchronizer<T>::QFutureSynchronizer()
Constructs a QFutureSynchronizer.
*/
/*!
- \fn QFutureSynchronizer::QFutureSynchronizer(const QFuture<T> &future)
+ \fn template <typename T> QFutureSynchronizer<T>::QFutureSynchronizer(const QFuture<T> &future)
Constructs a QFutureSynchronizer and begins watching \a future by calling
addFuture().
@@ -83,7 +83,7 @@
*/
/*!
- \fn QFutureSynchronizer::~QFutureSynchronizer()
+ \fn template <typename T> QFutureSynchronizer<T>::~QFutureSynchronizer()
Calls waitForFinished() function to ensure that all futures have finished
before destroying this QFutureSynchronizer.
@@ -92,7 +92,7 @@
*/
/*!
- \fn void QFutureSynchronizer::setFuture(const QFuture<T> &future)
+ \fn template <typename T> void QFutureSynchronizer<T>::setFuture(const QFuture<T> &future)
Sets \a future to be the only future managed by this QFutureSynchronizer.
This is a convenience function that calls waitForFinished(),
@@ -102,7 +102,7 @@
*/
/*!
- \fn void QFutureSynchronizer::addFuture(const QFuture<T> &future)
+ \fn template <typename T> void QFutureSynchronizer<T>::addFuture(const QFuture<T> &future)
Adds \a future to the list of managed futures.
@@ -110,7 +110,7 @@
*/
/*!
- \fn void QFutureSynchronizer::waitForFinished()
+ \fn template <typename T> void QFutureSynchronizer<T>::waitForFinished()
Waits for all futures to finish. If cancelOnWait() returns \c true, each
future is canceled before waiting for them to finish.
@@ -119,7 +119,7 @@
*/
/*!
- \fn void QFutureSynchronizer::clearFutures()
+ \fn template <typename T> void QFutureSynchronizer<T>::clearFutures()
Removes all managed futures from this QFutureSynchronizer.
@@ -127,7 +127,7 @@
*/
/*!
- \fn QList<QFuture<T> > QFutureSynchronizer::futures() const
+ \fn template <typename T> QList<QFuture<T> > QFutureSynchronizer<T>::futures() const
Returns a list of all managed futures.
@@ -135,7 +135,7 @@
*/
/*!
- \fn void QFutureSynchronizer::setCancelOnWait(bool enabled)
+ \fn template <typename T> void QFutureSynchronizer<T>::setCancelOnWait(bool enabled)
Enables or disables the cancel-on-wait feature based on the \a enabled
argument. If \a enabled is true, the waitForFinished() function will cancel
@@ -145,7 +145,7 @@
*/
/*!
- \fn bool QFutureSynchronizer::cancelOnWait() const
+ \fn template <typename T> bool QFutureSynchronizer<T>::cancelOnWait() const
Returns \c true if the cancel-on-wait feature is enabled; otherwise returns
false. If cancel-on-wait is enabled, the waitForFinished() function will
diff --git a/src/corelib/thread/qfuturewatcher.cpp b/src/corelib/thread/qfuturewatcher.cpp
index d2ec18850f..8c4cb9a5a2 100644
--- a/src/corelib/thread/qfuturewatcher.cpp
+++ b/src/corelib/thread/qfuturewatcher.cpp
@@ -38,9 +38,6 @@
****************************************************************************/
#include "qfuturewatcher.h"
-
-#ifndef QT_NO_QFUTURE
-
#include "qfuturewatcher_p.h"
#include <QtCore/qcoreevent.h>
@@ -99,7 +96,7 @@ QT_BEGIN_NAMESPACE
\sa QFuture, {Qt Concurrent}
*/
-/*! \fn QFutureWatcher::QFutureWatcher(QObject *parent)
+/*! \fn template <typename T> QFutureWatcher<T>::QFutureWatcher(QObject *parent)
Constructs a new QFutureWatcher with the given \a parent.
*/
@@ -107,12 +104,12 @@ QFutureWatcherBase::QFutureWatcherBase(QObject *parent)
:QObject(*new QFutureWatcherBasePrivate, parent)
{ }
-/*! \fn QFutureWatcher::~QFutureWatcher()
+/*! \fn template <typename T> QFutureWatcher<T>::~QFutureWatcher()
Destroys the QFutureWatcher.
*/
-/*! \fn void QFutureWatcher::cancel()
+/*! \fn template <typename T> void QFutureWatcher<T>::cancel()
Cancels the asynchronous computation represented by the future(). Note that
the cancelation is asynchronous. Use waitForFinished() after calling
@@ -134,7 +131,7 @@ void QFutureWatcherBase::cancel()
futureInterface().cancel();
}
-/*! \fn void QFutureWatcher::setPaused(bool paused)
+/*! \fn template <typename T> void QFutureWatcher<T>::setPaused(bool paused)
If \a paused is true, this function pauses the asynchronous computation
represented by the future(). If the computation is already paused, this
@@ -156,7 +153,7 @@ void QFutureWatcherBase::setPaused(bool paused)
futureInterface().setPaused(paused);
}
-/*! \fn void QFutureWatcher::pause()
+/*! \fn template <typename T> void QFutureWatcher<T>::pause()
Pauses the asynchronous computation represented by the future(). This is a
convenience method that simply calls setPaused(true).
@@ -168,7 +165,7 @@ void QFutureWatcherBase::pause()
futureInterface().setPaused(true);
}
-/*! \fn void QFutureWatcher::resume()
+/*! \fn template <typename T> void QFutureWatcher<T>::resume()
Resumes the asynchronous computation represented by the future(). This is
a convenience method that simply calls setPaused(false).
@@ -180,7 +177,7 @@ void QFutureWatcherBase::resume()
futureInterface().setPaused(false);
}
-/*! \fn void QFutureWatcher::togglePaused()
+/*! \fn template <typename T> void QFutureWatcher<T>::togglePaused()
Toggles the paused state of the asynchronous computation. In other words,
if the computation is currently paused, calling this function resumes it;
@@ -194,7 +191,7 @@ void QFutureWatcherBase::togglePaused()
futureInterface().togglePaused();
}
-/*! \fn int QFutureWatcher::progressValue() const
+/*! \fn template <typename T> int QFutureWatcher<T>::progressValue() const
Returns the current progress value, which is between the progressMinimum()
and progressMaximum().
@@ -206,7 +203,7 @@ int QFutureWatcherBase::progressValue() const
return futureInterface().progressValue();
}
-/*! \fn int QFutureWatcher::progressMinimum() const
+/*! \fn template <typename T> int QFutureWatcher<T>::progressMinimum() const
Returns the minimum progressValue().
@@ -217,7 +214,7 @@ int QFutureWatcherBase::progressMinimum() const
return futureInterface().progressMinimum();
}
-/*! \fn int QFutureWatcher::progressMaximum() const
+/*! \fn template <typename T> int QFutureWatcher<T>::progressMaximum() const
Returns the maximum progressValue().
@@ -228,7 +225,7 @@ int QFutureWatcherBase::progressMaximum() const
return futureInterface().progressMaximum();
}
-/*! \fn QString QFutureWatcher::progressText() const
+/*! \fn template <typename T> QString QFutureWatcher<T>::progressText() const
Returns the (optional) textual representation of the progress as reported
by the asynchronous computation.
@@ -241,7 +238,7 @@ QString QFutureWatcherBase::progressText() const
return futureInterface().progressText();
}
-/*! \fn bool QFutureWatcher::isStarted() const
+/*! \fn template <typename T> bool QFutureWatcher<T>::isStarted() const
Returns \c true if the asynchronous computation represented by the future()
has been started; otherwise returns \c false.
@@ -251,7 +248,7 @@ bool QFutureWatcherBase::isStarted() const
return futureInterface().queryState(QFutureInterfaceBase::Started);
}
-/*! \fn bool QFutureWatcher::isFinished() const
+/*! \fn template <typename T> bool QFutureWatcher<T>::isFinished() const
Returns \c true if the asynchronous computation represented by the future()
has finished, or if no future has been set; otherwise returns \c false.
@@ -262,7 +259,7 @@ bool QFutureWatcherBase::isFinished() const
return d->finished;
}
-/*! \fn bool QFutureWatcher::isRunning() const
+/*! \fn template <typename T> bool QFutureWatcher<T>::isRunning() const
Returns \c true if the asynchronous computation represented by the future()
is currently running; otherwise returns \c false.
@@ -272,7 +269,7 @@ bool QFutureWatcherBase::isRunning() const
return futureInterface().queryState(QFutureInterfaceBase::Running);
}
-/*! \fn bool QFutureWatcher::isCanceled() const
+/*! \fn template <typename T> bool QFutureWatcher<T>::isCanceled() const
Returns \c true if the asynchronous computation has been canceled with the
cancel() function; otherwise returns \c false.
@@ -285,7 +282,7 @@ bool QFutureWatcherBase::isCanceled() const
return futureInterface().queryState(QFutureInterfaceBase::Canceled);
}
-/*! \fn bool QFutureWatcher::isPaused() const
+/*! \fn template <typename T> bool QFutureWatcher<T>::isPaused() const
Returns \c true if the asynchronous computation has been paused with the
pause() function; otherwise returns \c false.
@@ -300,7 +297,7 @@ bool QFutureWatcherBase::isPaused() const
return futureInterface().queryState(QFutureInterfaceBase::Paused);
}
-/*! \fn void QFutureWatcher::waitForFinished()
+/*! \fn template <typename T> void QFutureWatcher<T>::waitForFinished()
Waits for the asynchronous computation to finish (including cancel()ed
computations).
@@ -339,7 +336,7 @@ bool QFutureWatcherBase::event(QEvent *event)
return QObject::event(event);
}
-/*! \fn void QFutureWatcher::setPendingResultsLimit(int limit)
+/*! \fn template <typename T> void QFutureWatcher<T>::setPendingResultsLimit(int limit)
The setPendingResultsLimit() provides throttling control. When the number
of pending resultReadyAt() or resultsReadyAt() signals exceeds the
@@ -490,7 +487,7 @@ void QFutureWatcherBasePrivate::sendCallOutEvent(QFutureCallOutEvent *event)
}
-/*! \fn const T &QFutureWatcher::result() const
+/*! \fn template <typename T> const T &QFutureWatcher<T>::result() const
Returns the first result in the future(). If the result is not immediately
available, this function will block and wait for the result to become
@@ -499,7 +496,7 @@ void QFutureWatcherBasePrivate::sendCallOutEvent(QFutureCallOutEvent *event)
\sa resultAt()
*/
-/*! \fn const T &QFutureWatcher::resultAt(int index) const
+/*! \fn template <typename T> const T &QFutureWatcher<T>::resultAt(int index) const
Returns the result at \a index in the future(). If the result is not
immediately available, this function will block and wait for the result to
@@ -508,7 +505,7 @@ void QFutureWatcherBasePrivate::sendCallOutEvent(QFutureCallOutEvent *event)
\sa result()
*/
-/*! \fn void QFutureWatcher::setFuture(const QFuture<T> &future)
+/*! \fn template <typename T> void QFutureWatcher<T>::setFuture(const QFuture<T> &future)
Starts watching the given \a future.
@@ -520,44 +517,44 @@ void QFutureWatcherBasePrivate::sendCallOutEvent(QFutureCallOutEvent *event)
\e after doing the connections.
*/
-/*! \fn QFuture<T> QFutureWatcher::future() const
+/*! \fn template <typename T> QFuture<T> QFutureWatcher<T>::future() const
Returns the watched future.
*/
-/*! \fn void QFutureWatcher::started()
+/*! \fn template <typename T> void QFutureWatcher<T>::started()
This signal is emitted when this QFutureWatcher starts watching the future
set with setFuture().
*/
/*!
- \fn void QFutureWatcher::finished()
+ \fn template <typename T> void QFutureWatcher<T>::finished()
This signal is emitted when the watched future finishes.
*/
/*!
- \fn void QFutureWatcher::canceled()
+ \fn template <typename T> void QFutureWatcher<T>::canceled()
This signal is emitted if the watched future is canceled.
*/
-/*! \fn void QFutureWatcher::paused()
+/*! \fn template <typename T> void QFutureWatcher<T>::paused()
This signal is emitted when the watched future is paused.
*/
-/*! \fn void QFutureWatcher::resumed()
+/*! \fn template <typename T> void QFutureWatcher<T>::resumed()
This signal is emitted when the watched future is resumed.
*/
/*!
- \fn void QFutureWatcher::progressRangeChanged(int minimum, int maximum)
+ \fn template <typename T> void QFutureWatcher<T>::progressRangeChanged(int minimum, int maximum)
The progress range for the watched future has changed to \a minimum and
\a maximum
*/
/*!
- \fn void QFutureWatcher::progressValueChanged(int progressValue)
+ \fn template <typename T> void QFutureWatcher<T>::progressValueChanged(int progressValue)
This signal is emitted when the watched future reports progress,
\a progressValue gives the current progress. In order to avoid overloading
@@ -567,14 +564,14 @@ void QFutureWatcherBasePrivate::sendCallOutEvent(QFutureCallOutEvent *event)
\a progressValue equals the maximum value) will always be delivered.
*/
-/*! \fn void QFutureWatcher::progressTextChanged(const QString &progressText)
+/*! \fn template <typename T> void QFutureWatcher<T>::progressTextChanged(const QString &progressText)
This signal is emitted when the watched future reports textual progress
information, \a progressText.
*/
/*!
- \fn void QFutureWatcher::resultReadyAt(int index)
+ \fn template <typename T> void QFutureWatcher<T>::resultReadyAt(int index)
This signal is emitted when the watched future reports a ready result at
\a index. If the future reports multiple results, the index will indicate
@@ -583,7 +580,7 @@ void QFutureWatcherBasePrivate::sendCallOutEvent(QFutureCallOutEvent *event)
*/
/*!
- \fn void QFutureWatcher::resultsReadyAt(int beginIndex, int endIndex);
+ \fn template <typename T> void QFutureWatcher<T>::resultsReadyAt(int beginIndex, int endIndex);
This signal is emitted when the watched future reports ready results.
The results are indexed from \a beginIndex to \a endIndex.
@@ -593,5 +590,3 @@ void QFutureWatcherBasePrivate::sendCallOutEvent(QFutureCallOutEvent *event)
QT_END_NAMESPACE
#include "moc_qfuturewatcher.cpp"
-
-#endif // QT_NO_QFUTURE
diff --git a/src/corelib/thread/qfuturewatcher.h b/src/corelib/thread/qfuturewatcher.h
index 8a6716a8f7..fb7dd30499 100644
--- a/src/corelib/thread/qfuturewatcher.h
+++ b/src/corelib/thread/qfuturewatcher.h
@@ -41,11 +41,10 @@
#define QFUTUREWATCHER_H
#include <QtCore/qfuture.h>
-
-#ifndef QT_NO_QFUTURE
-
#include <QtCore/qobject.h>
+QT_REQUIRE_CONFIG(future);
+
QT_BEGIN_NAMESPACE
@@ -58,7 +57,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 +75,7 @@ public:
void setPendingResultsLimit(int limit);
- bool event(QEvent *event) Q_DECL_OVERRIDE;
+ bool event(QEvent *event) override;
Q_SIGNALS:
void started();
@@ -98,8 +97,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 +165,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 +184,7 @@ template <>
class QFutureWatcher<void> : public QFutureWatcherBase
{
public:
- explicit QFutureWatcher(QObject *_parent = Q_NULLPTR)
+ explicit QFutureWatcher(QObject *_parent = nullptr)
: QFutureWatcherBase(_parent)
{ }
~QFutureWatcher()
@@ -197,8 +196,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)
@@ -212,6 +211,5 @@ Q_INLINE_TEMPLATE void QFutureWatcher<void>::setFuture(const QFuture<void> &_fut
}
QT_END_NAMESPACE
-#endif // QT_NO_QFUTURE
#endif // QFUTUREWATCHER_H
diff --git a/src/corelib/thread/qfuturewatcher_p.h b/src/corelib/thread/qfuturewatcher_p.h
index e83bdaf45a..ead247b040 100644
--- a/src/corelib/thread/qfuturewatcher_p.h
+++ b/src/corelib/thread/qfuturewatcher_p.h
@@ -54,10 +54,10 @@
#include "qfutureinterface_p.h"
#include <qlist.h>
-#ifndef QT_NO_QFUTURE
-
#include <private/qobject_p.h>
+QT_REQUIRE_CONFIG(future);
+
QT_BEGIN_NAMESPACE
class QFutureWatcherBase;
@@ -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);
@@ -84,5 +84,4 @@ public:
QT_END_NAMESPACE
-#endif // QT_NO_QFUTURE
#endif
diff --git a/src/corelib/thread/qmutex.h b/src/corelib/thread/qmutex.h
index 3d24379fa9..3dff363541 100644
--- a/src/corelib/thread/qmutex.h
+++ b/src/corelib/thread/qmutex.h
@@ -98,16 +98,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 *&current) Q_DECL_NOTHROW {
- return d_ptr.testAndSetAcquire(Q_NULLPTR, dummyLocked(), current);
+ return d_ptr.testAndSetAcquire(nullptr, dummyLocked(), current);
}
inline bool fastTryUnlock(QMutexData *&current) Q_DECL_NOTHROW {
- return d_ptr.testAndSetRelease(dummyLocked(), Q_NULLPTR, current);
+ return d_ptr.testAndSetRelease(dummyLocked(), nullptr, current);
}
void lockInternal() QT_MUTEX_LOCK_NOEXCEPT;
@@ -293,7 +293,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.cpp b/src/corelib/thread/qresultstore.cpp
index 9a6fcec678..e0ce1b4b78 100644
--- a/src/corelib/thread/qresultstore.cpp
+++ b/src/corelib/thread/qresultstore.cpp
@@ -39,8 +39,6 @@
#include "qresultstore.h"
-#ifndef QT_NO_QFUTURE
-
QT_BEGIN_NAMESPACE
namespace QtPrivate {
@@ -256,5 +254,3 @@ int ResultStoreBase::updateInsertIndex(int index, int _count)
} // namespace QtPrivate
QT_END_NAMESPACE
-
-#endif // QT_NO_QFUTURE
diff --git a/src/corelib/thread/qresultstore.h b/src/corelib/thread/qresultstore.h
index 6c814ef854..39f0a6d1bb 100644
--- a/src/corelib/thread/qresultstore.h
+++ b/src/corelib/thread/qresultstore.h
@@ -40,13 +40,11 @@
#ifndef QTCORE_RESULTSTORE_H
#define QTCORE_RESULTSTORE_H
-#include <QtCore/qglobal.h>
-
-#ifndef QT_NO_QFUTURE
-
#include <QtCore/qmap.h>
#include <QtCore/qdebug.h>
+QT_REQUIRE_CONFIG(future);
+
QT_BEGIN_NAMESPACE
@@ -67,8 +65,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,
@@ -202,6 +200,4 @@ Q_DECLARE_TYPEINFO(QtPrivate::ResultItem, Q_PRIMITIVE_TYPE);
QT_END_NAMESPACE
-#endif // QT_NO_QFUTURE
-
#endif
diff --git a/src/corelib/thread/qsemaphore.cpp b/src/corelib/thread/qsemaphore.cpp
index 37736b3960..012628ef63 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;
@@ -222,6 +419,9 @@ bool QSemaphore::tryAcquire(int n, int timeout)
// but QDeadlineTimer only accepts -1.
timeout = qMax(timeout, -1);
+ if (futexAvailable())
+ return futexSemaphoreTryAcquire<true>(u, n, timeout);
+
QDeadlineTimer timer(timeout);
QMutexLocker locker(&d->mutex);
qint64 remainingTime = timer.remainingTime();
diff --git a/src/corelib/thread/qsemaphore.h b/src/corelib/thread/qsemaphore.h
index 9de23173e8..2639085e99 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.cpp b/src/corelib/thread/qthread.cpp
index cad7a14017..adff853669 100644
--- a/src/corelib/thread/qthread.cpp
+++ b/src/corelib/thread/qthread.cpp
@@ -844,15 +844,17 @@ bool QThread::event(QEvent *event)
void QThread::requestInterruption()
{
- Q_D(QThread);
- QMutexLocker locker(&d->mutex);
- if (!d->running || d->finished || d->isInFinish)
- return;
if (this == QCoreApplicationPrivate::theMainThread) {
qWarning("QThread::requestInterruption has no effect on the main thread");
return;
}
- d->interruptionRequested = true;
+ Q_D(QThread);
+ // ### Qt 6: use std::atomic_flag, and document that
+ // requestInterruption/isInterruptionRequested do not synchronize with each other
+ QMutexLocker locker(&d->mutex);
+ if (!d->running || d->finished || d->isInFinish)
+ return;
+ d->interruptionRequested.store(true, std::memory_order_relaxed);
}
/*!
@@ -881,10 +883,12 @@ void QThread::requestInterruption()
bool QThread::isInterruptionRequested() const
{
Q_D(const QThread);
- QMutexLocker locker(&d->mutex);
- if (!d->running || d->finished || d->isInFinish)
+ // fast path: check that the flag is not set:
+ if (!d->interruptionRequested.load(std::memory_order_relaxed))
return false;
- return d->interruptionRequested;
+ // slow path: if the flag is set, take into account run status:
+ QMutexLocker locker(&d->mutex);
+ return d->running && !d->finished && !d->isInFinish;
}
/*
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..baeefd87ff 100644
--- a/src/corelib/thread/qthread_p.h
+++ b/src/corelib/thread/qthread_p.h
@@ -63,6 +63,7 @@
#include "private/qobject_p.h"
#include <algorithm>
+#include <atomic>
#ifdef Q_OS_WINRT
namespace ABI {
@@ -165,7 +166,7 @@ public:
bool running;
bool finished;
bool isInFinish; //when in QThreadPrivate::finish
- bool interruptionRequested;
+ std::atomic<bool> interruptionRequested;
bool exited;
int returnCode;
@@ -317,7 +318,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..fb5c9fd770 100644
--- a/src/corelib/thread/qthread_unix.cpp
+++ b/src/corelib/thread/qthread_unix.cpp
@@ -109,6 +109,10 @@
#define QT_HAS_THREAD_PRIORITY_SCHEDULING
#endif
+#if defined(Q_OS_QNX)
+#include <sys/neutrino.h>
+#endif
+
QT_BEGIN_NAMESPACE
@@ -487,9 +491,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
@@ -555,6 +556,55 @@ void QThread::usleep(unsigned long usecs)
}
#ifdef QT_HAS_THREAD_PRIORITY_SCHEDULING
+#if defined(Q_OS_QNX)
+static bool calculateUnixPriority(int priority, int *sched_policy, int *sched_priority)
+{
+ // On QNX, NormalPriority is mapped to 10. A QNX system could use a value different
+ // than 10 for the "normal" priority but it's difficult to achieve this so we'll
+ // assume that no one has ever created such a system. This makes the mapping from
+ // Qt priorities to QNX priorities lopsided. There's usually more space available
+ // to map into above the "normal" priority than below it. QNX also has a privileged
+ // priority range (for threads that assist the kernel). We'll assume that no Qt
+ // thread needs to use priorities in that range.
+ int priority_norm = 10;
+ // _sched_info::priority_priv isn't documented. You'd think that it's the start of the
+ // privileged priority range but it's actually the end of the unpriviledged range.
+ struct _sched_info info;
+ if (SchedInfo_r(0, *sched_policy, &info) != EOK)
+ return false;
+
+ if (priority == QThread::IdlePriority) {
+ *sched_priority = info.priority_min;
+ return true;
+ }
+
+ if (priority_norm < info.priority_min)
+ priority_norm = info.priority_min;
+ if (priority_norm > info.priority_priv)
+ priority_norm = info.priority_priv;
+
+ int to_min, to_max;
+ int from_min, from_max;
+ int prio;
+ if (priority < QThread::NormalPriority) {
+ to_min = info.priority_min;
+ to_max = priority_norm;
+ from_min = QThread::LowestPriority;
+ from_max = QThread::NormalPriority;
+ } else {
+ to_min = priority_norm;
+ to_max = info.priority_priv;
+ from_min = QThread::NormalPriority;
+ from_max = QThread::TimeCriticalPriority;
+ }
+
+ prio = ((priority - from_min) * (to_max - to_min)) / (from_max - from_min) + to_min;
+ prio = qBound(to_min, prio, to_max);
+
+ *sched_priority = prio;
+ return true;
+}
+#else
// Does some magic and calculate the Unix scheduler priorities
// sched_policy is IN/OUT: it must be set to a valid policy before calling this function
// sched_priority is OUT only
@@ -598,6 +648,7 @@ static bool calculateUnixPriority(int priority, int *sched_policy, int *sched_pr
return true;
}
#endif
+#endif
void QThread::start(Priority priority)
{
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..e4972a57b3 100644
--- a/src/corelib/thread/thread.pri
+++ b/src/corelib/thread/thread.pri
@@ -10,30 +10,19 @@ HEADERS += thread/qmutex.h \
thread/qthreadstorage.h \
thread/qwaitcondition.h \
thread/qatomic.h \
- thread/qexception.h \
- thread/qresultstore.h \
- thread/qfuture.h \
- thread/qfutureinterface.h \
- thread/qfuturesynchronizer.h \
- thread/qfuturewatcher.h \
thread/qbasicatomic.h \
thread/qgenericatomic.h
# private headers
HEADERS += thread/qmutex_p.h \
thread/qmutexpool_p.h \
- thread/qfutureinterface_p.h \
- thread/qfuturewatcher_p.h \
+ thread/qfutex_p.h \
thread/qorderedmutexlocker_p.h \
thread/qreadwritelock_p.h \
thread/qthread_p.h \
thread/qthreadpool_p.h
SOURCES += thread/qatomic.cpp \
- thread/qexception.cpp \
- thread/qresultstore.cpp \
- thread/qfutureinterface.cpp \
- thread/qfuturewatcher.cpp \
thread/qmutex.cpp \
thread/qreadwritelock.cpp \
thread/qrunnable.cpp \
@@ -43,6 +32,24 @@ SOURCES += thread/qatomic.cpp \
thread/qthreadpool.cpp \
thread/qthreadstorage.cpp
+qtConfig(future) {
+ HEADERS += \
+ thread/qexception.h \
+ thread/qfuture.h \
+ thread/qfutureinterface.h \
+ thread/qfutureinterface_p.h \
+ thread/qfuturesynchronizer.h \
+ thread/qfuturewatcher.h \
+ thread/qfuturewatcher_p.h \
+ thread/qresultstore.h
+
+ SOURCES += \
+ thread/qexception.cpp \
+ thread/qfutureinterface.cpp \
+ thread/qfuturewatcher.cpp \
+ thread/qresultstore.cpp
+}
+
win32 {
SOURCES += \
thread/qmutex_win.cpp \
diff --git a/src/corelib/tools/qalgorithms.qdoc b/src/corelib/tools/qalgorithms.qdoc
index 096ede2fec..f0ac2701e7 100644
--- a/src/corelib/tools/qalgorithms.qdoc
+++ b/src/corelib/tools/qalgorithms.qdoc
@@ -228,7 +228,7 @@
\sa {container classes}, <QtGlobal>
*/
-/*! \fn OutputIterator qCopy(InputIterator begin1, InputIterator end1, OutputIterator begin2)
+/*! \fn template <typename InputIterator, typename OutputIterator> OutputIterator qCopy(InputIterator begin1, InputIterator end1, OutputIterator begin2)
\relates <QtAlgorithms>
\deprecated
@@ -247,7 +247,7 @@
\sa qCopyBackward(), {input iterators}, {output iterators}
*/
-/*! \fn BiIterator2 qCopyBackward(BiIterator1 begin1, BiIterator1 end1, BiIterator2 end2)
+/*! \fn template <typename BiIterator1, typename BiIterator2> BiIterator2 qCopyBackward(BiIterator1 begin1, BiIterator1 end1, BiIterator2 end2)
\relates <QtAlgorithms>
\deprecated
@@ -266,7 +266,7 @@
\sa qCopy(), {bidirectional iterators}
*/
-/*! \fn bool qEqual(InputIterator1 begin1, InputIterator1 end1, InputIterator2 begin2)
+/*! \fn template <typename InputIterator1, typename InputIterator2> bool qEqual(InputIterator1 begin1, InputIterator1 end1, InputIterator2 begin2)
\relates <QtAlgorithms>
\deprecated
@@ -285,7 +285,7 @@
\sa {input iterators}
*/
-/*! \fn void qFill(ForwardIterator begin, ForwardIterator end, const T &value)
+/*! \fn template <typename ForwardIterator, typename T> void qFill(ForwardIterator begin, ForwardIterator end, const T &value)
\relates <QtAlgorithms>
\deprecated
@@ -299,7 +299,7 @@
\sa qCopy(), {forward iterators}
*/
-/*! \fn void qFill(Container &container, const T &value)
+/*! \fn template <typename Container, typename T> void qFill(Container &container, const T &value)
\relates <QtAlgorithms>
\deprecated
\overload
@@ -309,7 +309,7 @@
This is the same as qFill(\a{container}.begin(), \a{container}.end(), \a value);
*/
-/*! \fn InputIterator qFind(InputIterator begin, InputIterator end, const T &value)
+/*! \fn template <typename InputIterator, typename T> InputIterator qFind(InputIterator begin, InputIterator end, const T &value)
\relates <QtAlgorithms>
\deprecated
@@ -332,7 +332,7 @@
\sa qBinaryFind(), {input iterators}
*/
-/*! \fn void qFind(const Container &container, const T &value)
+/*! \fn template <typename Container, typename T> void qFind(const Container &container, const T &value)
\relates <QtAlgorithms>
\deprecated
\overload
@@ -342,7 +342,7 @@
This is the same as qFind(\a{container}.constBegin(), \a{container}.constEnd(), \a value);
*/
-/*! \fn void qCount(InputIterator begin, InputIterator end, const T &value, Size &n)
+/*! \fn template <typename InputIterator, typename T, typename Size> void qCount(InputIterator begin, InputIterator end, const T &value, Size &n)
\relates <QtAlgorithms>
\deprecated
@@ -362,7 +362,7 @@
\sa {input iterators}
*/
-/*! \fn void qCount(const Container &container, const T &value, Size &n)
+/*! \fn template <typename Container, typename T, typename Size> void qCount(const Container &container, const T &value, Size &n)
\relates <QtAlgorithms>
\deprecated
\overload
@@ -374,7 +374,7 @@
of \a value in the variable passed as a reference in argument \a n.
*/
-/*! \fn void qSwap(T &var1, T &var2)
+/*! \fn template <typename T> void qSwap(T &var1, T &var2)
\relates <QtAlgorithms>
\deprecated
@@ -386,7 +386,7 @@
\snippet code/doc_src_qalgorithms.cpp 10
*/
-/*! \fn void qSort(RandomAccessIterator begin, RandomAccessIterator end)
+/*! \fn template <typename RandomAccessIterator> void qSort(RandomAccessIterator begin, RandomAccessIterator end)
\relates <QtAlgorithms>
\deprecated
@@ -411,7 +411,7 @@
\sa qStableSort(), {random access iterators}
*/
-/*! \fn void qSort(RandomAccessIterator begin, RandomAccessIterator end, LessThan lessThan)
+/*! \fn template <typename RandomAccessIterator, typename LessThan> void qSort(RandomAccessIterator begin, RandomAccessIterator end, LessThan lessThan)
\relates <QtAlgorithms>
\deprecated
\overload
@@ -447,7 +447,7 @@
\sa QMap
*/
-/*! \fn void qSort(Container &container)
+/*! \fn template<typename Container> void qSort(Container &container)
\relates <QtAlgorithms>
\deprecated
\overload
@@ -458,7 +458,7 @@
*/
/*!
- \fn void qStableSort(RandomAccessIterator begin, RandomAccessIterator end)
+ \fn template <typename RandomAccessIterator> void qStableSort(RandomAccessIterator begin, RandomAccessIterator end)
\relates <QtAlgorithms>
\deprecated
@@ -485,7 +485,7 @@
*/
/*!
- \fn void qStableSort(RandomAccessIterator begin, RandomAccessIterator end, LessThan lessThan)
+ \fn template <typename RandomAccessIterator, typename LessThan> void qStableSort(RandomAccessIterator begin, RandomAccessIterator end, LessThan lessThan)
\relates <QtAlgorithms>
\deprecated
\overload
@@ -517,7 +517,7 @@
*/
/*!
- \fn void qStableSort(Container &container)
+ \fn template <typename Container> void qStableSort(Container &container)
\relates <QtAlgorithms>
\deprecated
\overload
@@ -527,7 +527,7 @@
This is the same as qStableSort(\a{container}.begin(), \a{container}.end());
*/
-/*! \fn RandomAccessIterator qLowerBound(RandomAccessIterator begin, RandomAccessIterator end, const T &value)
+/*! \fn template <typename RandomAccessIterator, typename T> RandomAccessIterator qLowerBound(RandomAccessIterator begin, RandomAccessIterator end, const T &value)
\relates <QtAlgorithms>
\deprecated
@@ -556,7 +556,7 @@
*/
/*!
- \fn RandomAccessIterator qLowerBound(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan)
+ \fn template <typename RandomAccessIterator, typename T, typename LessThan> RandomAccessIterator qLowerBound(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan)
\relates <QtAlgorithms>
\deprecated
\overload
@@ -571,7 +571,7 @@
*/
/*!
- \fn void qLowerBound(const Container &container, const T &value)
+ \fn template <typename Container, typename T> void qLowerBound(const Container &container, const T &value)
\relates <QtAlgorithms>
\deprecated
\overload
@@ -584,7 +584,7 @@
to insert items.
*/
-/*! \fn RandomAccessIterator qUpperBound(RandomAccessIterator begin, RandomAccessIterator end, const T &value)
+/*! \fn template <typename RandomAccessIterator, typename T> RandomAccessIterator qUpperBound(RandomAccessIterator begin, RandomAccessIterator end, const T &value)
\relates <QtAlgorithms>
\deprecated
@@ -613,7 +613,7 @@
*/
/*!
- \fn RandomAccessIterator qUpperBound(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan)
+ \fn template <typename RandomAccessIterator, typename T, typename LessThan> RandomAccessIterator qUpperBound(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan)
\relates <QtAlgorithms>
\deprecated
\overload
@@ -628,7 +628,7 @@
*/
/*!
- \fn void qUpperBound(const Container &container, const T &value)
+ \fn template <typename Container, typename T> void qUpperBound(const Container &container, const T &value)
\relates <QtAlgorithms>
\deprecated
\overload
@@ -639,7 +639,7 @@
*/
-/*! \fn RandomAccessIterator qBinaryFind(RandomAccessIterator begin, RandomAccessIterator end, const T &value)
+/*! \fn template <typename RandomAccessIterator, typename T> RandomAccessIterator qBinaryFind(RandomAccessIterator begin, RandomAccessIterator end, const T &value)
\relates <QtAlgorithms>
\deprecated
@@ -665,7 +665,7 @@
\sa qLowerBound(), qUpperBound(), {random access iterators}
*/
-/*! \fn RandomAccessIterator qBinaryFind(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan)
+/*! \fn template <typename RandomAccessIterator, typename T, typename LessThan> RandomAccessIterator qBinaryFind(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan)
\relates <QtAlgorithms>
\deprecated
\overload
@@ -680,7 +680,7 @@
*/
/*!
- \fn void qBinaryFind(const Container &container, const T &value)
+ \fn template <typename Container, typename T> void qBinaryFind(const Container &container, const T &value)
\relates <QtAlgorithms>
\deprecated
\overload
@@ -692,7 +692,7 @@
/*!
- \fn void qDeleteAll(ForwardIterator begin, ForwardIterator end)
+ \fn template <typename ForwardIterator> void qDeleteAll(ForwardIterator begin, ForwardIterator end)
\relates <QtAlgorithms>
Deletes all the items in the range [\a begin, \a end) using the
@@ -715,7 +715,7 @@
*/
/*!
- \fn void qDeleteAll(const Container &c)
+ \fn template <typename Container> void qDeleteAll(const Container &c)
\relates <QtAlgorithms>
\overload
@@ -723,7 +723,7 @@
This is the same as qDeleteAll(\a{c}.begin(), \a{c}.end()).
*/
-/*! \fn LessThan qLess()
+/*! \fn template <typename LessThan> LessThan qLess()
\relates <QtAlgorithms>
\deprecated
@@ -739,7 +739,7 @@
\sa {qGreater()}{qGreater<T>()}
*/
-/*! \fn LessThan qGreater()
+/*! \fn template <typename LessThan> LessThan qGreater()
\relates <QtAlgorithms>
\deprecated
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/qbytearraymatcher.cpp b/src/corelib/tools/qbytearraymatcher.cpp
index 76af726ef9..252545c782 100644
--- a/src/corelib/tools/qbytearraymatcher.cpp
+++ b/src/corelib/tools/qbytearraymatcher.cpp
@@ -415,7 +415,7 @@ int QStaticByteArrayMatcherBase::indexOfIn(const char *needle, uint nlen, const
*/
/*!
- \fn qMakeStaticByteArrayMatcher(const char (&pattern)[N])
+ \fn QStaticByteArrayMatcher qMakeStaticByteArrayMatcher(const char (&pattern)[N])
\since 5.9
\relates QStaticByteArrayMatcher
diff --git a/src/corelib/tools/qcache.qdoc b/src/corelib/tools/qcache.qdoc
index 423a911ce0..31dfcb42cf 100644
--- a/src/corelib/tools/qcache.qdoc
+++ b/src/corelib/tools/qcache.qdoc
@@ -80,25 +80,25 @@
\sa QPixmapCache, QHash, QMap
*/
-/*! \fn QCache::QCache(int maxCost = 100)
+/*! \fn template <class Key, class T> QCache<Key, T>::QCache(int maxCost = 100)
Constructs a cache whose contents will never have a total cost
greater than \a maxCost.
*/
-/*! \fn QCache::~QCache()
+/*! \fn template <class Key, class T> QCache<Key, T>::~QCache()
Destroys the cache. Deletes all the objects in the cache.
*/
-/*! \fn int QCache::maxCost() const
+/*! \fn template <class Key, class T> int QCache<Key, T>::maxCost() const
Returns the maximum allowed total cost of the cache.
\sa setMaxCost(), totalCost()
*/
-/*! \fn void QCache::setMaxCost(int cost)
+/*! \fn template <class Key, class T> void QCache<Key, T>::setMaxCost(int cost)
Sets the maximum allowed total cost of the cache to \a cost. If
the current total cost is greater than \a cost, some objects are
@@ -107,7 +107,7 @@
\sa maxCost(), totalCost()
*/
-/*! \fn int QCache::totalCost() const
+/*! \fn template <class Key, class T> int QCache<Key, T>::totalCost() const
Returns the total cost of the objects in the cache.
@@ -120,19 +120,19 @@
\sa setMaxCost()
*/
-/*! \fn int QCache::size() const
+/*! \fn template <class Key, class T> int QCache<Key, T>::size() const
Returns the number of objects in the cache.
\sa isEmpty()
*/
-/*! \fn int QCache::count() const
+/*! \fn template <class Key, class T> int QCache<Key, T>::count() const
Same as size().
*/
-/*! \fn bool QCache::isEmpty() const
+/*! \fn template <class Key, class T> bool QCache<Key, T>::isEmpty() const
Returns \c true if the cache contains no objects; otherwise
returns \c false.
@@ -140,12 +140,12 @@
\sa size()
*/
-/*! \fn QList<Key> QCache::keys() const
+/*! \fn template <class Key, class T> QList<Key> QCache<Key, T>::keys() const
Returns a list of the keys in the cache.
*/
-/*! \fn void QCache::clear();
+/*! \fn template <class Key, class T> void QCache<Key, T>::clear();
Deletes all the objects in the cache.
@@ -153,7 +153,7 @@
*/
-/*! \fn bool QCache::insert(const Key &key, T *object, int cost = 1)
+/*! \fn template <class Key, class T> bool QCache<Key, T>::insert(const Key &key, T *object, int cost = 1)
Inserts \a object into the cache with key \a key and
associated cost \a cost. Any object with the same key already in
@@ -169,7 +169,7 @@
\sa take(), remove()
*/
-/*! \fn T *QCache::object(const Key &key) const
+/*! \fn template <class Key, class T> T *QCache<Key, T>::object(const Key &key) const
Returns the object associated with key \a key, or 0 if the key does
not exist in the cache.
@@ -180,7 +180,7 @@
\sa take(), remove()
*/
-/*! \fn bool QCache::contains(const Key &key) const
+/*! \fn template <class Key, class T> bool QCache<Key, T>::contains(const Key &key) const
Returns \c true if the cache contains an object associated with key \a
key; otherwise returns \c false.
@@ -188,7 +188,7 @@
\sa take(), remove()
*/
-/*! \fn T *QCache::operator[](const Key &key) const
+/*! \fn template <class Key, class T> T *QCache<Key, T>::operator[](const Key &key) const
Returns the object associated with key \a key, or 0 if the key does
not exist in the cache.
@@ -199,7 +199,7 @@
deleted at any time.
*/
-/*! \fn bool QCache::remove(const Key &key)
+/*! \fn template <class Key, class T> bool QCache<Key, T>::remove(const Key &key)
Deletes the object associated with key \a key. Returns \c true if the
object was found in the cache; otherwise returns \c false.
@@ -207,7 +207,7 @@
\sa take(), clear()
*/
-/*! \fn T *QCache::take(const Key &key)
+/*! \fn template <class Key, class T> T *QCache<Key, T>::take(const Key &key)
Takes the object associated with key \a key out of the cache
without deleting it. Returns a pointer to the object taken out, or
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/qcontiguouscache.cpp b/src/corelib/tools/qcontiguouscache.cpp
index 3393be2dee..2ded61c0be 100644
--- a/src/corelib/tools/qcontiguouscache.cpp
+++ b/src/corelib/tools/qcontiguouscache.cpp
@@ -131,14 +131,14 @@ MyRecord record(int row) const
See the \l{Contiguous Cache Example}{Contiguous Cache} example.
*/
-/*! \fn QContiguousCache::QContiguousCache(int capacity)
+/*! \fn template<typename T> QContiguousCache<T>::QContiguousCache(int capacity)
Constructs a cache with the given \a capacity.
\sa setCapacity()
*/
-/*! \fn QContiguousCache::QContiguousCache(const QContiguousCache<T> &other)
+/*! \fn template<typename T> QContiguousCache<T>::QContiguousCache(const QContiguousCache<T> &other)
Constructs a copy of \a other.
@@ -150,20 +150,20 @@ MyRecord record(int row) const
\sa operator=()
*/
-/*! \fn QContiguousCache::~QContiguousCache()
+/*! \fn template<typename T> QContiguousCache<T>::~QContiguousCache()
Destroys the cache.
*/
-/*! \fn void QContiguousCache::detach()
+/*! \fn template<typename T> void QContiguousCache<T>::detach()
\internal
*/
-/*! \fn bool QContiguousCache::isDetached() const
+/*! \fn template<typename T> bool QContiguousCache<T>::isDetached() const
\internal
*/
-/*! \fn void QContiguousCache::setSharable(bool sharable)
+/*! \fn template<typename T> void QContiguousCache<T>::setSharable(bool sharable)
\internal
*/
@@ -195,27 +195,27 @@ MyRecord record(int row) const
\internal
*/
-/*! \fn QContiguousCache<T> &QContiguousCache::operator=(const QContiguousCache<T> &other)
+/*! \fn template<typename T> QContiguousCache<T> &QContiguousCache<T>::operator=(const QContiguousCache<T> &other)
Assigns \a other to this cache and returns a reference to this cache.
*/
/*!
- \fn QContiguousCache<T> &QContiguousCache::operator=(QContiguousCache<T> &&other)
+ \fn template<typename T> QContiguousCache<T> &QContiguousCache<T>::operator=(QContiguousCache<T> &&other)
Move-assigns \a other to this QContiguousCache instance.
\since 5.2
*/
-/*! \fn void QContiguousCache::swap(QContiguousCache<T> &other)
+/*! \fn template<typename T> void QContiguousCache<T>::swap(QContiguousCache<T> &other)
\since 4.8
Swaps cache \a other with this cache. This operation is very
fast and never fails.
*/
-/*! \fn bool QContiguousCache::operator==(const QContiguousCache<T> &other) const
+/*! \fn template<typename T> bool QContiguousCache<T>::operator==(const QContiguousCache<T> &other) const
Returns \c true if \a other is equal to this cache; otherwise returns \c false.
@@ -225,7 +225,7 @@ MyRecord record(int row) const
\sa operator!=()
*/
-/*! \fn bool QContiguousCache::operator!=(const QContiguousCache<T> &other) const
+/*! \fn template<typename T> bool QContiguousCache<T>::operator!=(const QContiguousCache<T> &other) const
Returns \c true if \a other is not equal to this cache; otherwise
returns \c false.
@@ -236,7 +236,7 @@ MyRecord record(int row) const
\sa operator==()
*/
-/*! \fn int QContiguousCache::capacity() const
+/*! \fn template<typename T> int QContiguousCache<T>::capacity() const
Returns the number of items the cache can store before it is full.
When a cache contains a number of items equal to its capacity, adding new
@@ -245,26 +245,26 @@ MyRecord record(int row) const
\sa setCapacity(), size()
*/
-/*! \fn int QContiguousCache::count() const
+/*! \fn template<typename T> int QContiguousCache<T>::count() const
Same as size().
*/
-/*! \fn int QContiguousCache::size() const
+/*! \fn template<typename T> int QContiguousCache<T>::size() const
Returns the number of items contained within the cache.
\sa capacity()
*/
-/*! \fn bool QContiguousCache::isEmpty() const
+/*! \fn template<typename T> bool QContiguousCache<T>::isEmpty() const
Returns \c true if no items are stored within the cache.
\sa size(), capacity()
*/
-/*! \fn bool QContiguousCache::isFull() const
+/*! \fn template<typename T> bool QContiguousCache<T>::isFull() const
Returns \c true if the number of items stored within the cache is equal
to the capacity of the cache.
@@ -272,19 +272,19 @@ MyRecord record(int row) const
\sa size(), capacity()
*/
-/*! \fn int QContiguousCache::available() const
+/*! \fn template<typename T> int QContiguousCache<T>::available() const
Returns the number of items that can be added to the cache before it becomes full.
\sa size(), capacity(), isFull()
*/
-/*! \fn void QContiguousCache::clear()
+/*! \fn template<typename T> void QContiguousCache<T>::clear()
Removes all items from the cache. The capacity is unchanged.
*/
-/*! \fn void QContiguousCache::setCapacity(int size)
+/*! \fn template<typename T> void QContiguousCache<T>::setCapacity(int size)
Sets the capacity of the cache to the given \a size. A cache can hold a
number of items equal to its capacity. When inserting, appending or prepending
@@ -297,7 +297,7 @@ MyRecord record(int row) const
\sa capacity(), isFull()
*/
-/*! \fn const T &QContiguousCache::at(int i) const
+/*! \fn template<typename T> const T &QContiguousCache<T>::at(int i) const
Returns the item at index position \a i in the cache. \a i must
be a valid index position in the cache (i.e, firstIndex() <= \a i <= lastIndex()).
@@ -311,7 +311,7 @@ MyRecord record(int row) const
\sa firstIndex(), lastIndex(), insert(), operator[]()
*/
-/*! \fn T &QContiguousCache::operator[](int i)
+/*! \fn template<typename T> T &QContiguousCache<T>::operator[](int i)
Returns the item at index position \a i as a modifiable reference. If
the cache does not contain an item at the given index position \a i
@@ -326,14 +326,14 @@ MyRecord record(int row) const
\sa insert(), at()
*/
-/*! \fn const T &QContiguousCache::operator[](int i) const
+/*! \fn template<typename T> const T &QContiguousCache<T>::operator[](int i) const
\overload
Same as at(\a i).
*/
-/*! \fn void QContiguousCache::append(const T &value)
+/*! \fn template<typename T> void QContiguousCache<T>::append(const T &value)
Inserts \a value at the end of the cache. If the cache is already full
the item at the start of the cache will be removed.
@@ -341,7 +341,7 @@ MyRecord record(int row) const
\sa prepend(), insert(), isFull()
*/
-/*! \fn void QContiguousCache::prepend(const T &value)
+/*! \fn template<typename T> void QContiguousCache<T>::prepend(const T &value)
Inserts \a value at the start of the cache. If the cache is already full
the item at the end of the cache will be removed.
@@ -349,7 +349,7 @@ MyRecord record(int row) const
\sa append(), insert(), isFull()
*/
-/*! \fn void QContiguousCache::insert(int i, const T &value)
+/*! \fn template<typename T> void QContiguousCache<T>::insert(int i, const T &value)
Inserts the \a value at the index position \a i. If the cache already contains
an item at \a i then that value is replaced. If \a i is either one more than
@@ -369,14 +369,14 @@ MyRecord record(int row) const
\sa prepend(), append(), isFull(), firstIndex(), lastIndex()
*/
-/*! \fn bool QContiguousCache::containsIndex(int i) const
+/*! \fn template<typename T> bool QContiguousCache<T>::containsIndex(int i) const
Returns \c true if the cache's index range includes the given index \a i.
\sa firstIndex(), lastIndex()
*/
-/*! \fn int QContiguousCache::firstIndex() const
+/*! \fn template<typename T> int QContiguousCache<T>::firstIndex() const
Returns the first valid index in the cache. The index will be invalid if the
cache is empty.
@@ -384,7 +384,7 @@ MyRecord record(int row) const
\sa capacity(), size(), lastIndex()
*/
-/*! \fn int QContiguousCache::lastIndex() const
+/*! \fn template<typename T> int QContiguousCache<T>::lastIndex() const
Returns the last valid index in the cache. The index will be invalid if the cache is empty.
@@ -392,7 +392,7 @@ MyRecord record(int row) const
*/
-/*! \fn T &QContiguousCache::first()
+/*! \fn template<typename T> T &QContiguousCache<T>::first()
Returns a reference to the first item in the cache. This function
assumes that the cache isn't empty.
@@ -400,7 +400,7 @@ MyRecord record(int row) const
\sa last(), isEmpty()
*/
-/*! \fn T &QContiguousCache::last()
+/*! \fn template<typename T> T &QContiguousCache<T>::last()
Returns a reference to the last item in the cache. This function
assumes that the cache isn't empty.
@@ -408,17 +408,17 @@ MyRecord record(int row) const
\sa first(), isEmpty()
*/
-/*! \fn const T& QContiguousCache::first() const
+/*! \fn template<typename T> const T& QContiguousCache<T>::first() const
\overload
*/
-/*! \fn const T& QContiguousCache::last() const
+/*! \fn template<typename T> const T& QContiguousCache<T>::last() const
\overload
*/
-/*! \fn void QContiguousCache::removeFirst()
+/*! \fn template<typename T> void QContiguousCache<T>::removeFirst()
Removes the first item from the cache. This function assumes that
the cache isn't empty.
@@ -426,7 +426,7 @@ MyRecord record(int row) const
\sa removeLast()
*/
-/*! \fn void QContiguousCache::removeLast()
+/*! \fn template<typename T> void QContiguousCache<T>::removeLast()
Removes the last item from the cache. This function assumes that
the cache isn't empty.
@@ -434,7 +434,7 @@ MyRecord record(int row) const
\sa removeFirst()
*/
-/*! \fn T QContiguousCache::takeFirst()
+/*! \fn template<typename T> T QContiguousCache<T>::takeFirst()
Removes the first item in the cache and returns it. This function
assumes that the cache isn't empty.
@@ -444,7 +444,7 @@ MyRecord record(int row) const
\sa takeLast(), removeFirst()
*/
-/*! \fn T QContiguousCache::takeLast()
+/*! \fn template<typename T> T QContiguousCache<T>::takeLast()
Removes the last item in the cache and returns it. This function
assumes that the cache isn't empty.
@@ -454,7 +454,7 @@ MyRecord record(int row) const
\sa takeFirst(), removeLast()
*/
-/*! \fn void QContiguousCache::normalizeIndexes()
+/*! \fn template<typename T> void QContiguousCache<T>::normalizeIndexes()
Moves the first index and last index of the cache
such that they point to valid indexes. The function does not modify
@@ -473,7 +473,7 @@ MyRecord record(int row) const
\sa areIndexesValid(), append(), prepend()
*/
-/*! \fn bool QContiguousCache::areIndexesValid() const
+/*! \fn template<typename T> bool QContiguousCache<T>::areIndexesValid() const
Returns whether the indexes for items stored in the cache are valid.
Indexes can become invalid if items are appended after the index position
diff --git a/src/corelib/tools/qdatetime.h b/src/corelib/tools/qdatetime.h
index 3b741553d5..5a7b75db62 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, 10) && !defined QT_NO_TEXTDATE
QT_DEPRECATED_X("Use QLocale::monthName or QLocale::standaloneMonthName")
diff --git a/src/corelib/tools/qdatetimeparser.cpp b/src/corelib/tools/qdatetimeparser.cpp
index 1a56418aaf..551e01e076 100644
--- a/src/corelib/tools/qdatetimeparser.cpp
+++ b/src/corelib/tools/qdatetimeparser.cpp
@@ -802,6 +802,7 @@ QDateTimeParser::parseSection(const QDateTime &currentValue, int sectionIndex,
break;
}
Q_FALLTHROUGH();
+ // All numeric:
case DaySection:
case YearSection:
case YearSection2Digits:
@@ -824,9 +825,9 @@ QDateTimeParser::parseSection(const QDateTime &currentValue, int sectionIndex,
bool ok = true;
int last = -1, used = -1;
- const int max = qMin(sectionmaxsize, sectiontextSize);
- QStringRef digitsStr = sectionTextRef.left(max);
- for (int digits = max; digits >= 1; --digits) {
+ Q_ASSERT(sectiontextSize <= sectionmaxsize);
+ QStringRef digitsStr = sectionTextRef.left(sectiontextSize);
+ for (int digits = sectiontextSize; digits >= 1; --digits) {
digitsStr.truncate(digits);
int tmp = (int)loc.toUInt(digitsStr, &ok);
if (ok && sn.type == Hour12Section) {
@@ -853,20 +854,20 @@ QDateTimeParser::parseSection(const QDateTime &currentValue, int sectionIndex,
QDTPDEBUG << "invalid because" << sectionTextRef << "can't become a uint" << last << ok;
} else {
const FieldInfo fi = fieldInfo(sectionIndex);
- const bool done = (used == sectionmaxsize);
- if (!done && fi & Fraction) { // typing 2 in a zzz field should be .200, not .002
+ const bool unfilled = used < sectionmaxsize;
+ if (unfilled && fi & Fraction) { // typing 2 in a zzz field should be .200, not .002
for (int i = used; i < sectionmaxsize; ++i)
last *= 10;
}
+ // Even those *= 10s can't take last above absMax:
+ Q_ASSERT(last <= absMax);
const int absMin = absoluteMin(sectionIndex);
if (last < absMin) {
- if (!done) // reversed test to dodge QDTPDEBUG ugliness !
+ if (unfilled)
result = ParsedSection(Intermediate, last, used);
else
QDTPDEBUG << "invalid because" << last << "is less than absoluteMin" << absMin;
- } else if (last > absMax) {
- result = ParsedSection(Intermediate, last, used);
- } else if (!done && (fi & (FixedWidth|Numeric)) == (FixedWidth|Numeric)) {
+ } else if (unfilled && (fi & (FixedWidth|Numeric)) == (FixedWidth|Numeric)) {
if (skipToNextSection(sectionIndex, currentValue, digitsStr)) {
const int missingZeroes = sectionmaxsize - digitsStr.size();
result = ParsedSection(Acceptable, last, sectionmaxsize, missingZeroes);
@@ -1159,7 +1160,8 @@ QDateTimeParser::scanString(const QDateTime &defaultValue,
}
state = qMin<State>(state, sect.state);
- if (state == Invalid || (state == Intermediate && context == FromString))
+ // QDateTimeEdit can fix Intermediate and zeroes, but input needing that didn't match format:
+ if (state == Invalid || (context == FromString && (state == Intermediate || sect.zeroes)))
return StateNode();
switch (sn.type) {
@@ -1475,8 +1477,8 @@ QDateTimeParser::parse(QString input, int position, const QDateTime &defaultValu
} else {
if (context == FromString) {
// optimization
- Q_ASSERT(maximum.date().toJulianDay() == 4642999);
- if (scan.value.date().toJulianDay() > 4642999)
+ Q_ASSERT(maximum.date().toJulianDay() == 5373484);
+ if (scan.value.date().toJulianDay() > 5373484)
scan.state = Invalid;
} else {
if (scan.value > maximum)
diff --git a/src/corelib/tools/qdatetimeparser_p.h b/src/corelib/tools/qdatetimeparser_p.h
index c3ae08da71..c9e63fe307 100644
--- a/src/corelib/tools/qdatetimeparser_p.h
+++ b/src/corelib/tools/qdatetimeparser_p.h
@@ -69,7 +69,7 @@ QT_REQUIRE_CONFIG(datetimeparser);
#define QDATETIMEEDIT_TIME_MAX QTime(23, 59, 59, 999)
#define QDATETIMEEDIT_DATE_MIN QDate(100, 1, 1)
#define QDATETIMEEDIT_COMPAT_DATE_MIN QDate(1752, 9, 14)
-#define QDATETIMEEDIT_DATE_MAX QDate(7999, 12, 31)
+#define QDATETIMEEDIT_DATE_MAX QDate(9999, 12, 31)
#define QDATETIMEEDIT_DATETIME_MIN QDateTime(QDATETIMEEDIT_DATE_MIN, QDATETIMEEDIT_TIME_MIN)
#define QDATETIMEEDIT_COMPAT_DATETIME_MIN QDateTime(QDATETIMEEDIT_COMPAT_DATE_MIN, QDATETIMEEDIT_TIME_MIN)
#define QDATETIMEEDIT_DATETIME_MAX QDateTime(QDATETIMEEDIT_DATE_MAX, QDATETIMEEDIT_TIME_MAX)
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.cpp b/src/corelib/tools/qhash.cpp
index 501f0d345f..e72b3e1eb5 100644
--- a/src/corelib/tools/qhash.cpp
+++ b/src/corelib/tools/qhash.cpp
@@ -963,7 +963,7 @@ uint qHash(double key, uint seed) Q_DECL_NOTHROW
return key != 0.0 ? hash(reinterpret_cast<const uchar *>(&key), sizeof(key), seed) : seed ;
}
-#ifndef Q_OS_DARWIN
+#if !defined(Q_OS_DARWIN) || defined(Q_CLANG_QDOC)
/*! \relates QHash
\since 5.3
@@ -1242,7 +1242,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa QHashIterator, QMutableHashIterator, QMap, QSet
*/
-/*! \fn QHash::QHash()
+/*! \fn template <class Key, class T> QHash<Key, T>::QHash()
Constructs an empty hash.
@@ -1250,7 +1250,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
*/
/*!
- \fn QHash::QHash(QHash &&other)
+ \fn template <class Key, class T> QHash<Key, T>::QHash(QHash &&other)
Move-constructs a QHash instance, making it point at the same
object that \a other was pointing to.
@@ -1258,7 +1258,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\since 5.2
*/
-/*! \fn QHash::QHash(std::initializer_list<std::pair<Key,T> > list)
+/*! \fn template <class Key, class T> QHash<Key, T>::QHash(std::initializer_list<std::pair<Key,T> > list)
\since 5.1
Constructs a hash with a copy of each of the elements in the
@@ -1268,7 +1268,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
compiled in C++11 mode.
*/
-/*! \fn QHash::QHash(const QHash &other)
+/*! \fn template <class Key, class T> QHash<Key, T>::QHash(const QHash &other)
Constructs a copy of \a other.
@@ -1280,40 +1280,40 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa operator=()
*/
-/*! \fn QHash::~QHash()
+/*! \fn template <class Key, class T> QHash<Key, T>::~QHash()
Destroys the hash. References to the values in the hash and all
iterators of this hash become invalid.
*/
-/*! \fn QHash &QHash::operator=(const QHash &other)
+/*! \fn template <class Key, class T> QHash &QHash<Key, T>::operator=(const QHash &other)
Assigns \a other to this hash and returns a reference to this hash.
*/
/*!
- \fn QHash &QHash::operator=(QHash &&other)
+ \fn template <class Key, class T> QHash &QHash<Key, T>::operator=(QHash &&other)
Move-assigns \a other to this QHash instance.
\since 5.2
*/
-/*! \fn void QHash::swap(QHash &other)
+/*! \fn template <class Key, class T> void QHash<Key, T>::swap(QHash &other)
\since 4.8
Swaps hash \a other with this hash. This operation is very
fast and never fails.
*/
-/*! \fn void QMultiHash::swap(QMultiHash &other)
+/*! \fn template <class Key, class T> void QMultiHash<Key, T>::swap(QMultiHash &other)
\since 4.8
Swaps hash \a other with this hash. This operation is very
fast and never fails.
*/
-/*! \fn bool QHash::operator==(const QHash &other) const
+/*! \fn template <class Key, class T> bool QHash<Key, T>::operator==(const QHash &other) const
Returns \c true if \a other is equal to this hash; otherwise returns
false.
@@ -1326,7 +1326,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa operator!=()
*/
-/*! \fn bool QHash::operator!=(const QHash &other) const
+/*! \fn template <class Key, class T> bool QHash<Key, T>::operator!=(const QHash &other) const
Returns \c true if \a other is not equal to this hash; otherwise
returns \c false.
@@ -1339,14 +1339,14 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa operator==()
*/
-/*! \fn int QHash::size() const
+/*! \fn template <class Key, class T> int QHash<Key, T>::size() const
Returns the number of items in the hash.
\sa isEmpty(), count()
*/
-/*! \fn bool QHash::isEmpty() const
+/*! \fn template <class Key, class T> bool QHash<Key, T>::isEmpty() const
Returns \c true if the hash contains no items; otherwise returns
false.
@@ -1354,7 +1354,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa size()
*/
-/*! \fn int QHash::capacity() const
+/*! \fn template <class Key, class T> int QHash<Key, T>::capacity() const
Returns the number of buckets in the QHash's internal hash table.
@@ -1366,7 +1366,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa reserve(), squeeze()
*/
-/*! \fn void QHash::reserve(int size)
+/*! \fn template <class Key, class T> void QHash<Key, T>::reserve(int size)
Ensures that the QHash's internal hash table consists of at least
\a size buckets.
@@ -1389,7 +1389,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa squeeze(), capacity()
*/
-/*! \fn void QHash::squeeze()
+/*! \fn template <class Key, class T> void QHash<Key, T>::squeeze()
Reduces the size of the QHash's internal hash table to save
memory.
@@ -1401,7 +1401,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa reserve(), capacity()
*/
-/*! \fn void QHash::detach()
+/*! \fn template <class Key, class T> void QHash<Key, T>::detach()
\internal
@@ -1411,7 +1411,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa isDetached()
*/
-/*! \fn bool QHash::isDetached() const
+/*! \fn template <class Key, class T> bool QHash<Key, T>::isDetached() const
\internal
@@ -1421,24 +1421,24 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa detach()
*/
-/*! \fn void QHash::setSharable(bool sharable)
+/*! \fn template <class Key, class T> void QHash<Key, T>::setSharable(bool sharable)
\internal
*/
-/*! \fn bool QHash::isSharedWith(const QHash &other) const
+/*! \fn template <class Key, class T> bool QHash<Key, T>::isSharedWith(const QHash &other) const
\internal
*/
-/*! \fn void QHash::clear()
+/*! \fn template <class Key, class T> void QHash<Key, T>::clear()
Removes all items from the hash.
\sa remove()
*/
-/*! \fn int QHash::remove(const Key &key)
+/*! \fn template <class Key, class T> int QHash<Key, T>::remove(const Key &key)
Removes all the items that have the \a key from the hash.
Returns the number of items removed which is usually 1 but will
@@ -1448,7 +1448,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa clear(), take(), QMultiHash::remove()
*/
-/*! \fn T QHash::take(const Key &key)
+/*! \fn template <class Key, class T> T QHash<Key, T>::take(const Key &key)
Removes the item with the \a key from the hash and returns
the value associated with it.
@@ -1463,7 +1463,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa remove()
*/
-/*! \fn bool QHash::contains(const Key &key) const
+/*! \fn template <class Key, class T> bool QHash<Key, T>::contains(const Key &key) const
Returns \c true if the hash contains an item with the \a key;
otherwise returns \c false.
@@ -1471,7 +1471,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa count(), QMultiHash::contains()
*/
-/*! \fn const T QHash::value(const Key &key) const
+/*! \fn template <class Key, class T> const T QHash<Key, T>::value(const Key &key) const
Returns the value associated with the \a key.
@@ -1483,14 +1483,14 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa key(), values(), contains(), operator[]()
*/
-/*! \fn const T QHash::value(const Key &key, const T &defaultValue) const
+/*! \fn template <class Key, class T> const T QHash<Key, T>::value(const Key &key, const T &defaultValue) const
\overload
If the hash contains no item with the given \a key, the function returns
\a defaultValue.
*/
-/*! \fn T &QHash::operator[](const Key &key)
+/*! \fn template <class Key, class T> T &QHash<Key, T>::operator[](const Key &key)
Returns the value associated with the \a key as a modifiable
reference.
@@ -1504,14 +1504,14 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa insert(), value()
*/
-/*! \fn const T QHash::operator[](const Key &key) const
+/*! \fn template <class Key, class T> const T QHash<Key, T>::operator[](const Key &key) const
\overload
Same as value().
*/
-/*! \fn QList<Key> QHash::uniqueKeys() const
+/*! \fn template <class Key, class T> QList<Key> QHash<Key, T>::uniqueKeys() const
\since 4.2
Returns a list containing all the keys in the map. Keys that occur multiple
@@ -1521,7 +1521,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa keys(), values()
*/
-/*! \fn QList<Key> QHash::keys() const
+/*! \fn template <class Key, class T> QList<Key> QHash<Key, T>::keys() const
Returns a list containing all the keys in the hash, in an
arbitrary order. Keys that occur multiple times in the hash
@@ -1536,7 +1536,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa uniqueKeys(), values(), key()
*/
-/*! \fn QList<Key> QHash::keys(const T &value) const
+/*! \fn template <class Key, class T> QList<Key> QHash<Key, T>::keys(const T &value) const
\overload
@@ -1548,7 +1548,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
by value.
*/
-/*! \fn QList<T> QHash::values() const
+/*! \fn template <class Key, class T> QList<T> QHash<Key, T>::values() const
Returns a list containing all the values in the hash, in an
arbitrary order. If a key is associated with multiple values, all of
@@ -1560,7 +1560,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa keys(), value()
*/
-/*! \fn QList<T> QHash::values(const Key &key) const
+/*! \fn template <class Key, class T> QList<T> QHash<Key, T>::values(const Key &key) const
\overload
@@ -1570,7 +1570,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa count(), insertMulti()
*/
-/*! \fn Key QHash::key(const T &value) const
+/*! \fn template <class Key, class T> Key QHash<Key, T>::key(const T &value) const
Returns the first key mapped to \a value.
@@ -1585,7 +1585,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
*/
/*!
- \fn Key QHash::key(const T &value, const Key &defaultKey) const
+ \fn template <class Key, class T> Key QHash<Key, T>::key(const T &value, const Key &defaultKey) const
\since 4.3
\overload
@@ -1597,21 +1597,21 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
by value.
*/
-/*! \fn int QHash::count(const Key &key) const
+/*! \fn template <class Key, class T> int QHash<Key, T>::count(const Key &key) const
Returns the number of items associated with the \a key.
\sa contains(), insertMulti()
*/
-/*! \fn int QHash::count() const
+/*! \fn template <class Key, class T> int QHash<Key, T>::count() const
\overload
Same as size().
*/
-/*! \fn QHash::iterator QHash::begin()
+/*! \fn template <class Key, class T> QHash<Key, T>::iterator QHash<Key, T>::begin()
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the first item in
the hash.
@@ -1619,12 +1619,12 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa constBegin(), end()
*/
-/*! \fn QHash::const_iterator QHash::begin() const
+/*! \fn template <class Key, class T> QHash<Key, T>::const_iterator QHash<Key, T>::begin() const
\overload
*/
-/*! \fn QHash::const_iterator QHash::cbegin() const
+/*! \fn template <class Key, class T> QHash<Key, T>::const_iterator QHash<Key, T>::cbegin() const
\since 5.0
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first item
@@ -1633,7 +1633,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa begin(), cend()
*/
-/*! \fn QHash::const_iterator QHash::constBegin() const
+/*! \fn template <class Key, class T> QHash<Key, T>::const_iterator QHash<Key, T>::constBegin() const
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first item
in the hash.
@@ -1641,7 +1641,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa begin(), constEnd()
*/
-/*! \fn QHash::key_iterator QHash::keyBegin() const
+/*! \fn template <class Key, class T> QHash<Key, T>::key_iterator QHash<Key, T>::keyBegin() const
\since 5.6
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first key
@@ -1650,7 +1650,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa keyEnd()
*/
-/*! \fn QHash::iterator QHash::end()
+/*! \fn template <class Key, class T> QHash<Key, T>::iterator QHash<Key, T>::end()
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item
after the last item in the hash.
@@ -1658,12 +1658,12 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa begin(), constEnd()
*/
-/*! \fn QHash::const_iterator QHash::end() const
+/*! \fn template <class Key, class T> QHash<Key, T>::const_iterator QHash<Key, T>::end() const
\overload
*/
-/*! \fn QHash::const_iterator QHash::constEnd() const
+/*! \fn template <class Key, class T> QHash<Key, T>::const_iterator QHash<Key, T>::constEnd() const
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary
item after the last item in the hash.
@@ -1671,7 +1671,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa constBegin(), end()
*/
-/*! \fn QHash::const_iterator QHash::cend() const
+/*! \fn template <class Key, class T> QHash<Key, T>::const_iterator QHash<Key, T>::cend() const
\since 5.0
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary
@@ -1680,7 +1680,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa cbegin(), end()
*/
-/*! \fn QHash::key_iterator QHash::keyEnd() const
+/*! \fn template <class Key, class T> QHash<Key, T>::key_iterator QHash<Key, T>::keyEnd() const
\since 5.6
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary
@@ -1689,7 +1689,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa keyBegin()
*/
-/*! \fn QHash::key_value_iterator QHash::keyValueBegin()
+/*! \fn template <class Key, class T> QHash<Key, T>::key_value_iterator QHash<Key, T>::keyValueBegin()
\since 5.10
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the first entry
@@ -1698,7 +1698,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa keyValueEnd()
*/
-/*! \fn QHash::key_value_iterator QHash::keyValueEnd()
+/*! \fn template <class Key, class T> QHash<Key, T>::key_value_iterator QHash<Key, T>::keyValueEnd()
\since 5.10
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the imaginary
@@ -1707,7 +1707,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa keyValueBegin()
*/
-/*! \fn QHash::const_key_value_iterator QHash::keyValueBegin() const
+/*! \fn template <class Key, class T> QHash<Key, T>::const_key_value_iterator QHash<Key, T>::keyValueBegin() const
\since 5.10
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first entry
@@ -1716,7 +1716,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa keyValueEnd()
*/
-/*! \fn QHash::const_key_value_iterator QHash::constKeyValueBegin() const
+/*! \fn template <class Key, class T> QHash<Key, T>::const_key_value_iterator QHash<Key, T>::constKeyValueBegin() const
\since 5.10
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first entry
@@ -1725,7 +1725,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa keyValueBegin()
*/
-/*! \fn QHash::const_key_value_iterator QHash::keyValueEnd() const
+/*! \fn template <class Key, class T> QHash<Key, T>::const_key_value_iterator QHash<Key, T>::keyValueEnd() const
\since 5.10
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary
@@ -1734,7 +1734,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa keyValueBegin()
*/
-/*! \fn QHash::const_key_value_iterator QHash::constKeyValueEnd() const
+/*! \fn template <class Key, class T> QHash<Key, T>::const_key_value_iterator QHash<Key, T>::constKeyValueEnd() const
\since 5.10
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary
@@ -1743,7 +1743,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa constKeyValueBegin()
*/
-/*! \fn QHash::iterator QHash::erase(const_iterator pos)
+/*! \fn template <class Key, class T> QHash<Key, T>::iterator QHash<Key, T>::erase(const_iterator pos)
\since 5.7
Removes the (key, value) pair associated with the iterator \a pos
@@ -1760,11 +1760,11 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa remove(), take(), find()
*/
-/*! \fn QHash::iterator QHash::erase(iterator pos)
+/*! \fn template <class Key, class T> QHash<Key, T>::iterator QHash<Key, T>::erase(iterator pos)
\overload
*/
-/*! \fn QHash::iterator QHash::find(const Key &key)
+/*! \fn template <class Key, class T> QHash<Key, T>::iterator QHash<Key, T>::find(const Key &key)
Returns an iterator pointing to the item with the \a key in the
hash.
@@ -1783,12 +1783,12 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa value(), values(), QMultiHash::find()
*/
-/*! \fn QHash::const_iterator QHash::find(const Key &key) const
+/*! \fn template <class Key, class T> QHash<Key, T>::const_iterator QHash<Key, T>::find(const Key &key) const
\overload
*/
-/*! \fn QHash::const_iterator QHash::constFind(const Key &key) const
+/*! \fn template <class Key, class T> QHash<Key, T>::const_iterator QHash<Key, T>::constFind(const Key &key) const
\since 4.1
Returns an iterator pointing to the item with the \a key in the
@@ -1800,7 +1800,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa find(), QMultiHash::constFind()
*/
-/*! \fn QHash::iterator QHash::insert(const Key &key, const T &value)
+/*! \fn template <class Key, class T> QHash<Key, T>::iterator QHash<Key, T>::insert(const Key &key, const T &value)
Inserts a new item with the \a key and a value of \a value.
@@ -1813,7 +1813,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa insertMulti()
*/
-/*! \fn QHash::iterator QHash::insertMulti(const Key &key, const T &value)
+/*! \fn template <class Key, class T> QHash<Key, T>::iterator QHash<Key, T>::insertMulti(const Key &key, const T &value)
Inserts a new item with the \a key and a value of \a value.
@@ -1825,7 +1825,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa insert(), values()
*/
-/*! \fn QHash &QHash::unite(const QHash &other)
+/*! \fn template <class Key, class T> QHash &QHash<Key, T>::unite(const QHash &other)
Inserts all the items in the \a other hash into this hash. If a
key is common to both hashes, the resulting hash will contain the
@@ -1834,14 +1834,14 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa insertMulti()
*/
-/*! \fn bool QHash::empty() const
+/*! \fn template <class Key, class T> bool QHash<Key, T>::empty() const
This function is provided for STL compatibility. It is equivalent
to isEmpty(), returning true if the hash is empty; otherwise
returns \c false.
*/
-/*! \fn QPair<iterator, iterator> QHash::equal_range(const Key &key)
+/*! \fn template <class Key, class T> QPair<iterator, iterator> QHash<Key, T>::equal_range(const Key &key)
\since 5.7
Returns a pair of iterators delimiting the range of values \c{[first, second)}, that
@@ -1849,7 +1849,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
*/
/*!
- \fn QPair<const_iterator, const_iterator> QHash::equal_range(const Key &key) const
+ \fn template <class Key, class T> QPair<const_iterator, const_iterator> QHash<Key, T>::equal_range(const Key &key) const
\overload
\since 5.7
*/
@@ -2020,7 +2020,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa QHash::const_iterator, QHash::key_iterator, QMutableHashIterator
*/
-/*! \fn QHash::iterator::iterator()
+/*! \fn template <class Key, class T> QHash<Key, T>::iterator::iterator()
Constructs an uninitialized iterator.
@@ -2031,12 +2031,12 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa QHash::begin(), QHash::end()
*/
-/*! \fn QHash::iterator::iterator(void *node)
+/*! \fn template <class Key, class T> QHash<Key, T>::iterator::iterator(void *node)
\internal
*/
-/*! \fn const Key &QHash::iterator::key() const
+/*! \fn template <class Key, class T> const Key &QHash<Key, T>::iterator::key() const
Returns the current item's key as a const reference.
@@ -2047,7 +2047,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa value()
*/
-/*! \fn T &QHash::iterator::value() const
+/*! \fn template <class Key, class T> T &QHash<Key, T>::iterator::value() const
Returns a modifiable reference to the current item's value.
@@ -2059,7 +2059,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa key(), operator*()
*/
-/*! \fn T &QHash::iterator::operator*() const
+/*! \fn template <class Key, class T> T &QHash<Key, T>::iterator::operator*() const
Returns a modifiable reference to the current item's value.
@@ -2068,7 +2068,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa key()
*/
-/*! \fn T *QHash::iterator::operator->() const
+/*! \fn template <class Key, class T> T *QHash<Key, T>::iterator::operator->() const
Returns a pointer to the current item's value.
@@ -2076,8 +2076,8 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
*/
/*!
- \fn bool QHash::iterator::operator==(const iterator &other) const
- \fn bool QHash::iterator::operator==(const const_iterator &other) const
+ \fn template <class Key, class T> bool QHash<Key, T>::iterator::operator==(const iterator &other) const
+ \fn template <class Key, class T> bool QHash<Key, T>::iterator::operator==(const const_iterator &other) const
Returns \c true if \a other points to the same item as this
iterator; otherwise returns \c false.
@@ -2086,8 +2086,8 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
*/
/*!
- \fn bool QHash::iterator::operator!=(const iterator &other) const
- \fn bool QHash::iterator::operator!=(const const_iterator &other) const
+ \fn template <class Key, class T> bool QHash<Key, T>::iterator::operator!=(const iterator &other) const
+ \fn template <class Key, class T> bool QHash<Key, T>::iterator::operator!=(const const_iterator &other) const
Returns \c true if \a other points to a different item than this
iterator; otherwise returns \c false.
@@ -2096,7 +2096,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
*/
/*!
- \fn QHash::iterator &QHash::iterator::operator++()
+ \fn template <class Key, class T> QHash<Key, T>::iterator &QHash<Key, T>::iterator::operator++()
The prefix ++ operator (\c{++i}) advances the iterator to the
next item in the hash and returns an iterator to the new current
@@ -2107,7 +2107,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa operator--()
*/
-/*! \fn QHash::iterator QHash::iterator::operator++(int)
+/*! \fn template <class Key, class T> QHash<Key, T>::iterator QHash<Key, T>::iterator::operator++(int)
\overload
@@ -2117,7 +2117,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
*/
/*!
- \fn QHash::iterator &QHash::iterator::operator--()
+ \fn template <class Key, class T> QHash<Key, T>::iterator &QHash<Key, T>::iterator::operator--()
The prefix -- operator (\c{--i}) makes the preceding item
current and returns an iterator pointing to the new current item.
@@ -2129,7 +2129,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
*/
/*!
- \fn QHash::iterator QHash::iterator::operator--(int)
+ \fn template <class Key, class T> QHash<Key, T>::iterator QHash<Key, T>::iterator::operator--(int)
\overload
@@ -2138,7 +2138,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
current item.
*/
-/*! \fn QHash::iterator QHash::iterator::operator+(int j) const
+/*! \fn template <class Key, class T> QHash<Key, T>::iterator QHash<Key, T>::iterator::operator+(int j) const
Returns an iterator to the item at \a j positions forward from
this iterator. (If \a j is negative, the iterator goes backward.)
@@ -2149,7 +2149,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
*/
-/*! \fn QHash::iterator QHash::iterator::operator-(int j) const
+/*! \fn template <class Key, class T> QHash<Key, T>::iterator QHash<Key, T>::iterator::operator-(int j) const
Returns an iterator to the item at \a j positions backward from
this iterator. (If \a j is negative, the iterator goes forward.)
@@ -2159,7 +2159,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa operator+()
*/
-/*! \fn QHash::iterator &QHash::iterator::operator+=(int j)
+/*! \fn template <class Key, class T> QHash<Key, T>::iterator &QHash<Key, T>::iterator::operator+=(int j)
Advances the iterator by \a j items. (If \a j is negative, the
iterator goes backward.)
@@ -2167,7 +2167,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa operator-=(), operator+()
*/
-/*! \fn QHash::iterator &QHash::iterator::operator-=(int j)
+/*! \fn template <class Key, class T> QHash<Key, T>::iterator &QHash<Key, T>::iterator::operator-=(int j)
Makes the iterator go back by \a j items. (If \a j is negative,
the iterator goes forward.)
@@ -2222,7 +2222,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa QHash::iterator, QHashIterator
*/
-/*! \fn QHash::const_iterator::const_iterator()
+/*! \fn template <class Key, class T> QHash<Key, T>::const_iterator::const_iterator()
Constructs an uninitialized iterator.
@@ -2233,31 +2233,31 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa QHash::constBegin(), QHash::constEnd()
*/
-/*! \fn QHash::const_iterator::const_iterator(void *node)
+/*! \fn template <class Key, class T> QHash<Key, T>::const_iterator::const_iterator(void *node)
\internal
*/
-/*! \fn QHash::const_iterator::const_iterator(const iterator &other)
+/*! \fn template <class Key, class T> QHash<Key, T>::const_iterator::const_iterator(const iterator &other)
Constructs a copy of \a other.
*/
-/*! \fn const Key &QHash::const_iterator::key() const
+/*! \fn template <class Key, class T> const Key &QHash<Key, T>::const_iterator::key() const
Returns the current item's key.
\sa value()
*/
-/*! \fn const T &QHash::const_iterator::value() const
+/*! \fn template <class Key, class T> const T &QHash<Key, T>::const_iterator::value() const
Returns the current item's value.
\sa key(), operator*()
*/
-/*! \fn const T &QHash::const_iterator::operator*() const
+/*! \fn template <class Key, class T> const T &QHash<Key, T>::const_iterator::operator*() const
Returns the current item's value.
@@ -2266,14 +2266,14 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa key()
*/
-/*! \fn const T *QHash::const_iterator::operator->() const
+/*! \fn template <class Key, class T> const T *QHash<Key, T>::const_iterator::operator->() const
Returns a pointer to the current item's value.
\sa value()
*/
-/*! \fn bool QHash::const_iterator::operator==(const const_iterator &other) const
+/*! \fn template <class Key, class T> bool QHash<Key, T>::const_iterator::operator==(const const_iterator &other) const
Returns \c true if \a other points to the same item as this
iterator; otherwise returns \c false.
@@ -2281,7 +2281,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa operator!=()
*/
-/*! \fn bool QHash::const_iterator::operator!=(const const_iterator &other) const
+/*! \fn template <class Key, class T> bool QHash<Key, T>::const_iterator::operator!=(const const_iterator &other) const
Returns \c true if \a other points to a different item than this
iterator; otherwise returns \c false.
@@ -2290,7 +2290,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
*/
/*!
- \fn QHash::const_iterator &QHash::const_iterator::operator++()
+ \fn template <class Key, class T> QHash<Key, T>::const_iterator &QHash<Key, T>::const_iterator::operator++()
The prefix ++ operator (\c{++i}) advances the iterator to the
next item in the hash and returns an iterator to the new current
@@ -2301,7 +2301,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa operator--()
*/
-/*! \fn QHash::const_iterator QHash::const_iterator::operator++(int)
+/*! \fn template <class Key, class T> QHash<Key, T>::const_iterator QHash<Key, T>::const_iterator::operator++(int)
\overload
@@ -2310,7 +2310,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
current item.
*/
-/*! \fn QHash::const_iterator &QHash::const_iterator::operator--()
+/*! \fn template <class Key, class T> QHash<Key, T>::const_iterator &QHash<Key, T>::const_iterator::operator--()
The prefix -- operator (\c{--i}) makes the preceding item
current and returns an iterator pointing to the new current item.
@@ -2321,7 +2321,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa operator++()
*/
-/*! \fn QHash::const_iterator QHash::const_iterator::operator--(int)
+/*! \fn template <class Key, class T> QHash<Key, T>::const_iterator QHash<Key, T>::const_iterator::operator--(int)
\overload
@@ -2330,7 +2330,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
current item.
*/
-/*! \fn QHash::const_iterator QHash::const_iterator::operator+(int j) const
+/*! \fn template <class Key, class T> QHash<Key, T>::const_iterator QHash<Key, T>::const_iterator::operator+(int j) const
Returns an iterator to the item at \a j positions forward from
this iterator. (If \a j is negative, the iterator goes backward.)
@@ -2340,7 +2340,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa operator-()
*/
-/*! \fn QHash::const_iterator QHash::const_iterator::operator-(int j) const
+/*! \fn template <class Key, class T> QHash<Key, T>::const_iterator QHash<Key, T>::const_iterator::operator-(int j) const
Returns an iterator to the item at \a j positions backward from
this iterator. (If \a j is negative, the iterator goes forward.)
@@ -2350,7 +2350,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa operator+()
*/
-/*! \fn QHash::const_iterator &QHash::const_iterator::operator+=(int j)
+/*! \fn template <class Key, class T> QHash<Key, T>::const_iterator &QHash<Key, T>::const_iterator::operator+=(int j)
Advances the iterator by \a j items. (If \a j is negative, the
iterator goes backward.)
@@ -2360,7 +2360,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa operator-=(), operator+()
*/
-/*! \fn QHash::const_iterator &QHash::const_iterator::operator-=(int j)
+/*! \fn template <class Key, class T> QHash<Key, T>::const_iterator &QHash<Key, T>::const_iterator::operator-=(int j)
Makes the iterator go back by \a j items. (If \a j is negative,
the iterator goes forward.)
@@ -2407,17 +2407,17 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa QHash::const_iterator, QHash::iterator
*/
-/*! \fn const T &QHash::key_iterator::operator*() const
+/*! \fn template <class Key, class T> const T &QHash<Key, T>::key_iterator::operator*() const
Returns the current item's key.
*/
-/*! \fn const T *QHash::key_iterator::operator->() const
+/*! \fn template <class Key, class T> const T *QHash<Key, T>::key_iterator::operator->() const
Returns a pointer to the current item's key.
*/
-/*! \fn bool QHash::key_iterator::operator==(key_iterator other) const
+/*! \fn template <class Key, class T> bool QHash<Key, T>::key_iterator::operator==(key_iterator other) const
Returns \c true if \a other points to the same item as this
iterator; otherwise returns \c false.
@@ -2425,7 +2425,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa operator!=()
*/
-/*! \fn bool QHash::key_iterator::operator!=(key_iterator other) const
+/*! \fn template <class Key, class T> bool QHash<Key, T>::key_iterator::operator!=(key_iterator other) const
Returns \c true if \a other points to a different item than this
iterator; otherwise returns \c false.
@@ -2434,7 +2434,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
*/
/*!
- \fn QHash::key_iterator &QHash::key_iterator::operator++()
+ \fn template <class Key, class T> QHash<Key, T>::key_iterator &QHash<Key, T>::key_iterator::operator++()
The prefix ++ operator (\c{++i}) advances the iterator to the
next item in the hash and returns an iterator to the new current
@@ -2445,7 +2445,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa operator--()
*/
-/*! \fn QHash::key_iterator QHash::key_iterator::operator++(int)
+/*! \fn template <class Key, class T> QHash<Key, T>::key_iterator QHash<Key, T>::key_iterator::operator++(int)
\overload
@@ -2454,7 +2454,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
item.
*/
-/*! \fn QHash::key_iterator &QHash::key_iterator::operator--()
+/*! \fn template <class Key, class T> QHash<Key, T>::key_iterator &QHash<Key, T>::key_iterator::operator--()
The prefix -- operator (\c{--i}) makes the preceding item
current and returns an iterator pointing to the new current item.
@@ -2465,7 +2465,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa operator++()
*/
-/*! \fn QHash::key_iterator QHash::key_iterator::operator--(int)
+/*! \fn template <class Key, class T> QHash<Key, T>::key_iterator QHash<Key, T>::key_iterator::operator--(int)
\overload
@@ -2474,7 +2474,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
item.
*/
-/*! \fn const_iterator QHash::key_iterator::base() const
+/*! \fn template <class Key, class T> const_iterator QHash<Key, T>::key_iterator::base() const
Returns the underlying const_iterator this key_iterator is based on.
*/
@@ -2490,7 +2490,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa QKeyValueIterator
*/
-/*! \fn QDataStream &operator<<(QDataStream &out, const QHash<Key, T>& hash)
+/*! \fn template <class Key, class T> QDataStream &operator<<(QDataStream &out, const QHash<Key, T>& hash)
\relates QHash
Writes the hash \a hash to stream \a out.
@@ -2501,7 +2501,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa {Serializing Qt Data Types}
*/
-/*! \fn QDataStream &operator>>(QDataStream &in, QHash<Key, T> &hash)
+/*! \fn template <class Key, class T> QDataStream &operator>>(QDataStream &in, QHash<Key, T> &hash)
\relates QHash
Reads a hash from stream \a in into \a hash.
@@ -2568,12 +2568,12 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa QHash, QHashIterator, QMutableHashIterator, QMultiMap
*/
-/*! \fn QMultiHash::QMultiHash()
+/*! \fn template <class Key, class T> QMultiHash<Key, T>::QMultiHash()
Constructs an empty hash.
*/
-/*! \fn QMultiHash::QMultiHash(std::initializer_list<std::pair<Key,T> > list)
+/*! \fn template <class Key, class T> QMultiHash<Key, T>::QMultiHash(std::initializer_list<std::pair<Key,T> > list)
\since 5.1
Constructs a multi-hash with a copy of each of the elements in the
@@ -2583,7 +2583,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
compiled in C++11 mode.
*/
-/*! \fn QMultiHash::QMultiHash(const QHash<Key, T> &other)
+/*! \fn template <class Key, class T> QMultiHash<Key, T>::QMultiHash(const QHash<Key, T> &other)
Constructs a copy of \a other (which can be a QHash or a
QMultiHash).
@@ -2591,7 +2591,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa operator=()
*/
-/*! \fn QMultiHash::iterator QMultiHash::replace(const Key &key, const T &value)
+/*! \fn template <class Key, class T> QMultiHash<Key, T>::iterator QMultiHash<Key, T>::replace(const Key &key, const T &value)
Inserts a new item with the \a key and a value of \a value.
@@ -2604,7 +2604,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa insert()
*/
-/*! \fn QMultiHash::iterator QMultiHash::insert(const Key &key, const T &value)
+/*! \fn template <class Key, class T> QMultiHash<Key, T>::iterator QMultiHash<Key, T>::insert(const Key &key, const T &value)
Inserts a new item with the \a key and a value of \a value.
@@ -2616,7 +2616,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa replace()
*/
-/*! \fn QMultiHash &QMultiHash::operator+=(const QMultiHash &other)
+/*! \fn template <class Key, class T> QMultiHash &QMultiHash<Key, T>::operator+=(const QMultiHash &other)
Inserts all the items in the \a other hash into this hash
and returns a reference to this hash.
@@ -2624,7 +2624,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa insert()
*/
-/*! \fn QMultiHash QMultiHash::operator+(const QMultiHash &other) const
+/*! \fn template <class Key, class T> QMultiHash QMultiHash<Key, T>::operator+(const QMultiHash &other) const
Returns a hash that contains all the items in this hash in
addition to all the items in \a other. If a key is common to both
@@ -2634,7 +2634,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
*/
/*!
- \fn bool QMultiHash::contains(const Key &key, const T &value) const
+ \fn template <class Key, class T> bool QMultiHash<Key, T>::contains(const Key &key, const T &value) const
\since 4.3
Returns \c true if the hash contains an item with the \a key and
@@ -2644,7 +2644,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
*/
/*!
- \fn int QMultiHash::remove(const Key &key, const T &value)
+ \fn template <class Key, class T> int QMultiHash<Key, T>::remove(const Key &key, const T &value)
\since 4.3
Removes all the items that have the \a key and the value \a
@@ -2654,7 +2654,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
*/
/*!
- \fn int QMultiHash::count(const Key &key, const T &value) const
+ \fn template <class Key, class T> int QMultiHash<Key, T>::count(const Key &key, const T &value) const
\since 4.3
Returns the number of items with the \a key and \a value.
@@ -2663,7 +2663,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
*/
/*!
- \fn typename QHash<Key, T>::iterator QMultiHash::find(const Key &key, const T &value)
+ \fn template <class Key, class T> typename QHash<Key, T>::iterator QMultiHash<Key, T>::find(const Key &key, const T &value)
\since 4.3
Returns an iterator pointing to the item with the \a key and \a value.
@@ -2676,13 +2676,13 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
*/
/*!
- \fn typename QHash<Key, T>::const_iterator QMultiHash::find(const Key &key, const T &value) const
+ \fn template <class Key, class T> typename QHash<Key, T>::const_iterator QMultiHash<Key, T>::find(const Key &key, const T &value) const
\since 4.3
\overload
*/
/*!
- \fn typename QHash<Key, T>::const_iterator QMultiHash::constFind(const Key &key, const T &value) const
+ \fn template <class Key, class T> typename QHash<Key, T>::const_iterator QMultiHash<Key, T>::constFind(const Key &key, const T &value) const
\since 4.3
Returns an iterator pointing to the item with the \a key and the
@@ -2695,7 +2695,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
*/
/*!
- \fn uint qHash(const QHash<Key, T> &key, uint seed = 0)
+ \fn template <class Key, class T> uint qHash(const QHash<Key, T> &key, uint seed = 0)
\since 5.8
\relates QHash
@@ -2705,7 +2705,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
*/
/*!
- \fn uint qHash(const QMultiHash<Key, T> &key, uint seed = 0)
+ \fn template <class Key, class T> uint qHash(const QMultiHash<Key, T> &key, uint seed = 0)
\since 5.8
\relates QMultiHash
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/qhashfunctions.h b/src/corelib/tools/qhashfunctions.h
index f75b310e4e..e6ae7a0b85 100644
--- a/src/corelib/tools/qhashfunctions.h
+++ b/src/corelib/tools/qhashfunctions.h
@@ -90,7 +90,7 @@ Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(quint64 key, uint seed
Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(qint64 key, uint seed = 0) Q_DECL_NOTHROW { return qHash(quint64(key), seed); }
Q_CORE_EXPORT Q_DECL_CONST_FUNCTION uint qHash(float key, uint seed = 0) Q_DECL_NOTHROW;
Q_CORE_EXPORT Q_DECL_CONST_FUNCTION uint qHash(double key, uint seed = 0) Q_DECL_NOTHROW;
-#ifndef Q_OS_DARWIN
+#if !defined(Q_OS_DARWIN) || defined(Q_CLANG_QDOC)
Q_CORE_EXPORT Q_DECL_CONST_FUNCTION uint qHash(long double key, uint seed = 0) Q_DECL_NOTHROW;
#endif
Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(const QChar key, uint seed = 0) Q_DECL_NOTHROW { return qHash(key.unicode(), seed); }
diff --git a/src/corelib/tools/qiterator.qdoc b/src/corelib/tools/qiterator.qdoc
index 77cc412602..1a70784fab 100644
--- a/src/corelib/tools/qiterator.qdoc
+++ b/src/corelib/tools/qiterator.qdoc
@@ -25,6 +25,128 @@
**
****************************************************************************/
+/*! \class QKeyValueIterator
+ \inmodule QtCore
+ \since 5.10
+
+ \brief Iterator over the key/value pairs of an associative container.
+
+ The QKeyValueIterator class provides an STL-style iterator for returning
+ key/value pairs from associative containers like QHash and QMap. It
+ supports the same API as the STL associative containers, i.e. getting a
+ key/value pair when iterating through the container.
+
+ This will allow for better interoperability between QMap, QHash and friends
+ and STL-style algorithms.
+
+ \warning Iterators on implicitly shared containers do not work
+ exactly like STL-iterators. You should avoid copying a container
+ while iterators are active on that container. For more information,
+ read \l{Implicit sharing iterator problem}.
+*/
+
+/*! \typedef QKeyValueIterator::iterator_category
+ \internal
+*/
+
+/*! \typedef QKeyValueIterator::difference_type
+ \internal
+*/
+
+/*! \typedef QKeyValueIterator::value_type
+ \internal
+*/
+
+/*! \typedef QKeyValueIterator::pointer
+ \internal
+*/
+
+/*! \typedef QKeyValueIterator::reference
+ \internal
+*/
+
+/*! \fn template<typename Key, typename T, class Iterator> QKeyValueIterator<Key, T, Iterator>::QKeyValueIterator()
+
+ Constructs a default QKeyValueIterator.
+*/
+
+/*! \fn template<typename Key, typename T, class Iterator> QKeyValueIterator<Key, T, Iterator>::QKeyValueIterator(Iterator o)
+
+ Constructs a QKeyValueIterator on top of \a o.
+*/
+
+/*! \fn template<typename Key, typename T, class Iterator> const T &QKeyValueIterator<Key, T, Iterator>::operator*() const
+
+ Returns the current entry as a pair.
+*/
+
+/*! \fn template<typename Key, typename T, class Iterator> bool operator==(QKeyValueIterator<Key, T, Iterator> lhs, QKeyValueIterator<Key, T, Iterator> rhs)
+ \relates QKeyValueIterator
+
+ Returns \c true if \a rhs points to the same item as \a lhs otherwise returns
+ \c false.
+
+ \sa operator!=()
+*/
+
+/*! \fn template<typename Key, typename T, class Iterator> bool operator!=(QKeyValueIterator<Key, T, Iterator> lhs, QKeyValueIterator<Key, T, Iterator> rhs) const
+ \relates QKeyValueIterator
+
+ Returns \c true if \a rhs points to a different item than \a lhs otherwise
+ returns \c false.
+
+ \sa operator==()
+*/
+
+/*!
+ \fn template<typename Key, typename T, class Iterator> QKeyValueIterator &QKeyValueIterator<Key, T, Iterator>::operator++()
+
+ The prefix ++ operator (\c{++i}) advances the iterator to the
+ next item in the container and returns the iterator.
+
+ \note Advancing the iterator past its container's end() constitutes
+ undefined behavior.
+
+ \sa operator--()
+*/
+
+/*! \fn template<typename Key, typename T, class Iterator> QKeyValueIterator QKeyValueIterator<Key, T, Iterator>::operator++(int)
+
+ \overload
+
+ The postfix ++ operator (\c{i++}) advances the iterator to the
+ next item in the container and returns the iterator's prior value.
+
+ \note Advancing the iterator past its container's end() constitutes
+ undefined behavior.
+*/
+
+/*! \fn template<typename Key, typename T, class Iterator> QKeyValueIterator &QKeyValueIterator<Key, T, Iterator>::operator--()
+
+ The prefix -- operator (\c{--i}) backs the iterator up to the previous item
+ in the container and returns the iterator.
+
+ \note Backing up an iterator to before its container's begin() constitutes
+ undefined behavior.
+
+ \sa operator++()
+*/
+
+/*! \fn template<typename Key, typename T, class Iterator> QKeyValueIterator QKeyValueIterator<Key, T, Iterator>::operator--(int)
+
+ \overload
+
+ The postfix -- operator (\c{i--}) backs the iterator up to the previous item
+ in the container and returns the iterator's prior value.
+
+ \note Backing up an iterator to before its container's begin() constitutes
+ undefined behavior.
+*/
+
+/*! \fn template<typename Key, typename T, class Iterator> Iterator QKeyValueIterator<Key, T, Iterator>::base() const
+ Returns the underlying iterator this QKeyValueIterator is based on.
+*/
+
/*!
\class QListIterator
\inmodule QtCore
@@ -470,10 +592,10 @@
*/
/*!
- \fn QListIterator::QListIterator(const QList<T> &list)
- \fn QLinkedListIterator::QLinkedListIterator(const QLinkedList<T> &list)
- \fn QMutableListIterator::QMutableListIterator(QList<T> &list)
- \fn QMutableLinkedListIterator::QMutableLinkedListIterator(QLinkedList<T> &list)
+ \fn template <class T> QListIterator<T>::QListIterator(const QList<T> &list)
+ \fn template <class T> QLinkedListIterator<T>::QLinkedListIterator(const QLinkedList<T> &list)
+ \fn template <class T> QMutableListIterator<T>::QMutableListIterator(QList<T> &list)
+ \fn template <class T> QMutableLinkedListIterator<T>::QMutableLinkedListIterator(QLinkedList<T> &list)
Constructs an iterator for traversing \a list. The iterator is
set to be at the front of the list (before the first item).
@@ -482,8 +604,8 @@
*/
/*!
- \fn QVectorIterator::QVectorIterator(const QVector<T> &vector)
- \fn QMutableVectorIterator::QMutableVectorIterator(QVector<T> &vector)
+ \fn template <class T> QVectorIterator<T>::QVectorIterator(const QVector<T> &vector)
+ \fn template <class T> QMutableVectorIterator<T>::QMutableVectorIterator(QVector<T> &vector)
Constructs an iterator for traversing \a vector. The iterator is
set to be at the front of the vector (before the first item).
@@ -492,8 +614,8 @@
*/
/*!
- \fn QSetIterator::QSetIterator(const QSet<T> &set)
- \fn QMutableSetIterator::QMutableSetIterator(QSet<T> &set)
+ \fn template <class T> QSetIterator<T>::QSetIterator(const QSet<T> &set)
+ \fn template <class T> QMutableSetIterator<T>::QMutableSetIterator(QSet<T> &set)
Constructs an iterator for traversing \a set. The iterator is
set to be at the front of the set (before the first item).
@@ -501,10 +623,10 @@
\sa operator=()
*/
-/*! \fn QMutableListIterator &QMutableListIterator::operator=(QList<T> &list)
- \fn QMutableLinkedListIterator &QMutableLinkedListIterator::operator=(QLinkedList<T> &list)
- \fn QListIterator &QListIterator::operator=(const QList<T> &list)
- \fn QLinkedListIterator &QLinkedListIterator::operator=(const QLinkedList<T> &list)
+/*! \fn template <class T> QMutableListIterator &QMutableListIterator<T>::operator=(QList<T> &list)
+ \fn template <class T> QMutableLinkedListIterator &QMutableLinkedListIterator<T>::operator=(QLinkedList<T> &list)
+ \fn template <class T> QListIterator &QListIterator<T>::operator=(const QList<T> &list)
+ \fn template <class T> QLinkedListIterator &QLinkedListIterator<T>::operator=(const QLinkedList<T> &list)
Makes the iterator operate on \a list. The iterator is set to be
at the front of the list (before the first item).
@@ -512,8 +634,8 @@
\sa toFront(), toBack()
*/
-/*! \fn QVectorIterator &QVectorIterator::operator=(const QVector<T> &vector)
- \fn QMutableVectorIterator &QMutableVectorIterator::operator=(QVector<T> &vector)
+/*! \fn template <class T> QVectorIterator &QVectorIterator<T>::operator=(const QVector<T> &vector)
+ \fn template <class T> QMutableVectorIterator &QMutableVectorIterator<T>::operator=(QVector<T> &vector)
Makes the iterator operate on \a vector. The iterator is set to be
at the front of the vector (before the first item).
@@ -521,8 +643,8 @@
\sa toFront(), toBack()
*/
-/*! \fn QSetIterator &QSetIterator::operator=(const QSet<T> &set)
- \fn QMutableSetIterator &QMutableSetIterator::operator=(QSet<T> &set)
+/*! \fn template <class T> QSetIterator &QSetIterator<T>::operator=(const QSet<T> &set)
+ \fn template <class T> QMutableSetIterator &QMutableSetIterator<T>::operator=(QSet<T> &set)
Makes the iterator operate on \a set. The iterator is set to be
at the front of the set (before the first item).
@@ -530,14 +652,14 @@
\sa toFront(), toBack()
*/
-/*! \fn void QListIterator::toFront()
- \fn void QLinkedListIterator::toFront()
- \fn void QVectorIterator::toFront()
- \fn void QSetIterator::toFront()
- \fn void QMutableListIterator::toFront()
- \fn void QMutableLinkedListIterator::toFront()
- \fn void QMutableVectorIterator::toFront()
- \fn void QMutableSetIterator::toFront()
+/*! \fn template <class T> void QListIterator<T>::toFront()
+ \fn template <class T> void QLinkedListIterator<T>::toFront()
+ \fn template <class T> void QVectorIterator<T>::toFront()
+ \fn template <class T> void QSetIterator<T>::toFront()
+ \fn template <class T> void QMutableListIterator<T>::toFront()
+ \fn template <class T> void QMutableLinkedListIterator<T>::toFront()
+ \fn template <class T> void QMutableVectorIterator<T>::toFront()
+ \fn template <class T> void QMutableSetIterator<T>::toFront()
Moves the iterator to the front of the container (before the
first item).
@@ -545,14 +667,14 @@
\sa toBack(), next()
*/
-/*! \fn void QListIterator::toBack()
- \fn void QLinkedListIterator::toBack()
- \fn void QVectorIterator::toBack()
- \fn void QSetIterator::toBack()
- \fn void QMutableListIterator::toBack()
- \fn void QMutableLinkedListIterator::toBack()
- \fn void QMutableVectorIterator::toBack()
- \fn void QMutableSetIterator::toBack()
+/*! \fn template <class T> void QListIterator<T>::toBack()
+ \fn template <class T> void QLinkedListIterator<T>::toBack()
+ \fn template <class T> void QVectorIterator<T>::toBack()
+ \fn template <class T> void QSetIterator<T>::toBack()
+ \fn template <class T> void QMutableListIterator<T>::toBack()
+ \fn template <class T> void QMutableLinkedListIterator<T>::toBack()
+ \fn template <class T> void QMutableVectorIterator<T>::toBack()
+ \fn template <class T> void QMutableSetIterator<T>::toBack()
Moves the iterator to the back of the container (after the last
item).
@@ -560,14 +682,14 @@
\sa toFront(), previous()
*/
-/*! \fn bool QListIterator::hasNext() const
- \fn bool QLinkedListIterator::hasNext() const
- \fn bool QVectorIterator::hasNext() const
- \fn bool QSetIterator::hasNext() const
- \fn bool QMutableListIterator::hasNext() const
- \fn bool QMutableLinkedListIterator::hasNext() const
- \fn bool QMutableVectorIterator::hasNext() const
- \fn bool QMutableSetIterator::hasNext() const
+/*! \fn template <class T> bool QListIterator<T>::hasNext() const
+ \fn template <class T> bool QLinkedListIterator<T>::hasNext() const
+ \fn template <class T> bool QVectorIterator<T>::hasNext() const
+ \fn template <class T> bool QSetIterator<T>::hasNext() const
+ \fn template <class T> bool QMutableListIterator<T>::hasNext() const
+ \fn template <class T> bool QMutableLinkedListIterator<T>::hasNext() const
+ \fn template <class T> bool QMutableVectorIterator<T>::hasNext() const
+ \fn template <class T> bool QMutableSetIterator<T>::hasNext() const
Returns \c true if there is at least one item ahead of the iterator,
i.e. the iterator is \e not at the back of the container;
@@ -576,11 +698,11 @@
\sa hasPrevious(), next()
*/
-/*! \fn const T &QListIterator::next()
- \fn const T &QLinkedListIterator::next()
- \fn const T &QVectorIterator::next()
- \fn const T &QSetIterator::next()
- \fn const T &QMutableSetIterator::next()
+/*! \fn template <class T> const T &QListIterator<T>::next()
+ \fn template <class T> const T &QLinkedListIterator<T>::next()
+ \fn template <class T> const T &QVectorIterator<T>::next()
+ \fn template <class T> const T &QSetIterator<T>::next()
+ \fn template <class T> const T &QMutableSetIterator<T>::next()
Returns the next item and advances the iterator by one position.
@@ -590,9 +712,9 @@
\sa hasNext(), peekNext(), previous()
*/
-/*! \fn T &QMutableListIterator::next()
- \fn T &QMutableLinkedListIterator::next()
- \fn T &QMutableVectorIterator::next()
+/*! \fn template <class T> T &QMutableListIterator<T>::next()
+ \fn template <class T> T &QMutableLinkedListIterator<T>::next()
+ \fn template <class T> T &QMutableVectorIterator<T>::next()
Returns a reference to the next item, and advances the iterator
by one position.
@@ -603,11 +725,11 @@
\sa hasNext(), peekNext(), previous()
*/
-/*! \fn const T &QListIterator::peekNext() const
- \fn const T &QLinkedListIterator::peekNext() const
- \fn const T &QVectorIterator::peekNext() const
- \fn const T &QSetIterator::peekNext() const
- \fn const T &QMutableSetIterator::peekNext() const
+/*! \fn template <class T> const T &QListIterator<T>::peekNext() const
+ \fn template <class T> const T &QLinkedListIterator<T>::peekNext() const
+ \fn template <class T> const T &QVectorIterator<T>::peekNext() const
+ \fn template <class T> const T &QSetIterator<T>::peekNext() const
+ \fn template <class T> const T &QMutableSetIterator<T>::peekNext() const
Returns the next item without moving the iterator.
@@ -617,9 +739,9 @@
\sa hasNext(), next(), peekPrevious()
*/
-/*! \fn T &QMutableListIterator::peekNext() const
- \fn T &QMutableLinkedListIterator::peekNext() const
- \fn T &QMutableVectorIterator::peekNext() const
+/*! \fn template <class T> T &QMutableListIterator<T>::peekNext() const
+ \fn template <class T> T &QMutableLinkedListIterator<T>::peekNext() const
+ \fn template <class T> T &QMutableVectorIterator<T>::peekNext() const
Returns a reference to the next item, without moving the iterator.
@@ -629,14 +751,14 @@
\sa hasNext(), next(), peekPrevious()
*/
-/*! \fn bool QListIterator::hasPrevious() const
- \fn bool QLinkedListIterator::hasPrevious() const
- \fn bool QVectorIterator::hasPrevious() const
- \fn bool QSetIterator::hasPrevious() const
- \fn bool QMutableListIterator::hasPrevious() const
- \fn bool QMutableLinkedListIterator::hasPrevious() const
- \fn bool QMutableVectorIterator::hasPrevious() const
- \fn bool QMutableSetIterator::hasPrevious() const
+/*! \fn template <class T> bool QListIterator<T>::hasPrevious() const
+ \fn template <class T> bool QLinkedListIterator<T>::hasPrevious() const
+ \fn template <class T> bool QVectorIterator<T>::hasPrevious() const
+ \fn template <class T> bool QSetIterator<T>::hasPrevious() const
+ \fn template <class T> bool QMutableListIterator<T>::hasPrevious() const
+ \fn template <class T> bool QMutableLinkedListIterator<T>::hasPrevious() const
+ \fn template <class T> bool QMutableVectorIterator<T>::hasPrevious() const
+ \fn template <class T> bool QMutableSetIterator<T>::hasPrevious() const
Returns \c true if there is at least one item behind the iterator,
i.e. the iterator is \e not at the front of the container;
@@ -645,11 +767,11 @@
\sa hasNext(), previous()
*/
-/*! \fn const T &QListIterator::previous()
- \fn const T &QLinkedListIterator::previous()
- \fn const T &QVectorIterator::previous()
- \fn const T &QSetIterator::previous()
- \fn const T &QMutableSetIterator::previous()
+/*! \fn template <class T> const T &QListIterator<T>::previous()
+ \fn template <class T> const T &QLinkedListIterator<T>::previous()
+ \fn template <class T> const T &QVectorIterator<T>::previous()
+ \fn template <class T> const T &QSetIterator<T>::previous()
+ \fn template <class T> const T &QMutableSetIterator<T>::previous()
Returns the previous item and moves the iterator back by one
position.
@@ -660,9 +782,9 @@
\sa hasPrevious(), peekPrevious(), next()
*/
-/*! \fn T &QMutableListIterator::previous()
- \fn T &QMutableLinkedListIterator::previous()
- \fn T &QMutableVectorIterator::previous()
+/*! \fn template <class T> T &QMutableListIterator<T>::previous()
+ \fn template <class T> T &QMutableLinkedListIterator<T>::previous()
+ \fn template <class T> T &QMutableVectorIterator<T>::previous()
Returns a reference to the previous item and moves the iterator
back by one position.
@@ -673,11 +795,11 @@
\sa hasPrevious(), peekPrevious(), next()
*/
-/*! \fn const T &QListIterator::peekPrevious() const
- \fn const T &QLinkedListIterator::peekPrevious() const
- \fn const T &QVectorIterator::peekPrevious() const
- \fn const T &QSetIterator::peekPrevious() const
- \fn const T &QMutableSetIterator::peekPrevious() const
+/*! \fn template <class T> const T &QListIterator<T>::peekPrevious() const
+ \fn template <class T> const T &QLinkedListIterator<T>::peekPrevious() const
+ \fn template <class T> const T &QVectorIterator<T>::peekPrevious() const
+ \fn template <class T> const T &QSetIterator<T>::peekPrevious() const
+ \fn template <class T> const T &QMutableSetIterator<T>::peekPrevious() const
Returns the previous item without moving the iterator.
@@ -687,9 +809,9 @@
\sa hasPrevious(), previous(), peekNext()
*/
-/*! \fn T &QMutableListIterator::peekPrevious() const
- \fn T &QMutableLinkedListIterator::peekPrevious() const
- \fn T &QMutableVectorIterator::peekPrevious() const
+/*! \fn template <class T> T &QMutableListIterator<T>::peekPrevious() const
+ \fn template <class T> T &QMutableLinkedListIterator<T>::peekPrevious() const
+ \fn template <class T> T &QMutableVectorIterator<T>::peekPrevious() const
Returns a reference to the previous item, without moving the iterator.
@@ -699,14 +821,14 @@
\sa hasPrevious(), previous(), peekNext()
*/
-/*! \fn bool QListIterator::findNext(const T &value)
- \fn bool QLinkedListIterator::findNext(const T &value)
- \fn bool QVectorIterator::findNext(const T &value)
- \fn bool QSetIterator::findNext(const T &value)
- \fn bool QMutableListIterator::findNext(const T &value)
- \fn bool QMutableLinkedListIterator::findNext(const T &value)
- \fn bool QMutableVectorIterator::findNext(const T &value)
- \fn bool QMutableSetIterator::findNext(const T &value)
+/*! \fn template <class T> bool QListIterator<T>::findNext(const T &value)
+ \fn template <class T> bool QLinkedListIterator<T>::findNext(const T &value)
+ \fn template <class T> bool QVectorIterator<T>::findNext(const T &value)
+ \fn template <class T> bool QSetIterator<T>::findNext(const T &value)
+ \fn template <class T> bool QMutableListIterator<T>::findNext(const T &value)
+ \fn template <class T> bool QMutableLinkedListIterator<T>::findNext(const T &value)
+ \fn template <class T> bool QMutableVectorIterator<T>::findNext(const T &value)
+ \fn template <class T> bool QMutableSetIterator<T>::findNext(const T &value)
Searches for \a value starting from the current iterator position
forward. Returns \c true if \a value is found; otherwise returns \c false.
@@ -718,14 +840,14 @@
\sa findPrevious()
*/
-/*! \fn bool QListIterator::findPrevious(const T &value)
- \fn bool QLinkedListIterator::findPrevious(const T &value)
- \fn bool QVectorIterator::findPrevious(const T &value)
- \fn bool QSetIterator::findPrevious(const T &value)
- \fn bool QMutableListIterator::findPrevious(const T &value)
- \fn bool QMutableLinkedListIterator::findPrevious(const T &value)
- \fn bool QMutableVectorIterator::findPrevious(const T &value)
- \fn bool QMutableSetIterator::findPrevious(const T &value)
+/*! \fn template <class T> bool QListIterator<T>::findPrevious(const T &value)
+ \fn template <class T> bool QLinkedListIterator<T>::findPrevious(const T &value)
+ \fn template <class T> bool QVectorIterator<T>::findPrevious(const T &value)
+ \fn template <class T> bool QSetIterator<T>::findPrevious(const T &value)
+ \fn template <class T> bool QMutableListIterator<T>::findPrevious(const T &value)
+ \fn template <class T> bool QMutableLinkedListIterator<T>::findPrevious(const T &value)
+ \fn template <class T> bool QMutableVectorIterator<T>::findPrevious(const T &value)
+ \fn template <class T> bool QMutableSetIterator<T>::findPrevious(const T &value)
Searches for \a value starting from the current iterator position
backward. Returns \c true if \a value is found; otherwise returns
@@ -738,7 +860,7 @@
\sa findNext()
*/
-/*! \fn void QMutableListIterator::remove()
+/*! \fn template <class T> void QMutableListIterator<T>::remove()
Removes the last item that was jumped over using one of the
traversal functions (next(), previous(), findNext(), findPrevious()).
@@ -749,7 +871,7 @@
\sa insert(), setValue()
*/
-/*! \fn void QMutableLinkedListIterator::remove()
+/*! \fn template <class T> void QMutableLinkedListIterator<T>::remove()
Removes the last item that was jumped over using one of the
traversal functions (next(), previous(), findNext(), findPrevious()).
@@ -760,7 +882,7 @@
\sa insert(), setValue()
*/
-/*! \fn void QMutableVectorIterator::remove()
+/*! \fn template <class T> void QMutableVectorIterator<T>::remove()
Removes the last item that was jumped over using one of the
traversal functions (next(), previous(), findNext(), findPrevious()).
@@ -771,7 +893,7 @@
\sa insert(), setValue()
*/
-/*! \fn void QMutableSetIterator::remove()
+/*! \fn template <class T> void QMutableSetIterator<T>::remove()
Removes the last item that was jumped over using one of the
traversal functions (next(), previous(), findNext(), findPrevious()).
@@ -782,7 +904,7 @@
\sa value()
*/
-/*! \fn void QMutableListIterator::setValue(const T &value) const
+/*! \fn template <class T> void QMutableListIterator<T>::setValue(const T &value) const
Replaces the value of the last item that was jumped over using
one of the traversal functions with \a value.
@@ -796,7 +918,7 @@
\sa value(), remove(), insert()
*/
-/*! \fn void QMutableLinkedListIterator::setValue(const T &value) const
+/*! \fn template <class T> void QMutableLinkedListIterator<T>::setValue(const T &value) const
Replaces the value of the last item that was jumped over using
one of the traversal functions with \a value.
@@ -810,7 +932,7 @@
\sa value(), remove(), insert()
*/
-/*! \fn void QMutableVectorIterator::setValue(const T &value) const
+/*! \fn template <class T> void QMutableVectorIterator<T>::setValue(const T &value) const
Replaces the value of the last item that was jumped over using
one of the traversal functions with \a value.
@@ -824,10 +946,10 @@
\sa value(), remove(), insert()
*/
-/*! \fn const T &QMutableListIterator::value() const
- \fn const T &QMutableLinkedListIterator::value() const
- \fn const T &QMutableVectorIterator::value() const
- \fn const T &QMutableSetIterator::value() const
+/*! \fn template <class T> const T &QMutableListIterator<T>::value() const
+ \fn template <class T> const T &QMutableLinkedListIterator<T>::value() const
+ \fn template <class T> const T &QMutableVectorIterator<T>::value() const
+ \fn template <class T> const T &QMutableSetIterator<T>::value() const
Returns the value of the last item that was jumped over using one
of the traversal functions (next(), previous(), findNext(),
@@ -839,18 +961,18 @@
*/
/*!
- \fn T &QMutableListIterator::value()
- \fn T &QMutableLinkedListIterator::value()
- \fn T &QMutableVectorIterator::value()
+ \fn template <class T> T &QMutableListIterator<T>::value()
+ \fn template <class T> T &QMutableLinkedListIterator<T>::value()
+ \fn template <class T> T &QMutableVectorIterator<T>::value()
\overload
Returns a non-const reference to the value of the last item that
was jumped over using one of the traversal functions.
*/
-/*! \fn void QMutableListIterator::insert(const T &value)
- \fn void QMutableLinkedListIterator::insert(const T &value)
- \fn void QMutableVectorIterator::insert(const T &value)
+/*! \fn template <class T> void QMutableListIterator<T>::insert(const T &value)
+ \fn template <class T> void QMutableLinkedListIterator<T>::insert(const T &value)
+ \fn template <class T> void QMutableVectorIterator<T>::insert(const T &value)
Inserts \a value at the current iterator position. After the
call, the iterator is located just after the inserted item.
@@ -1092,8 +1214,8 @@
\sa QHashIterator, QHash::iterator
*/
-/*! \fn QMapIterator::QMapIterator(const QMap<Key, T> &map)
- \fn QMutableMapIterator::QMutableMapIterator(QMap<Key, T> &map)
+/*! \fn template <class Key, class T> QMapIterator<Key, T>::QMapIterator(const QMap<Key, T> &map)
+ \fn template <class Key, class T> QMutableMapIterator<Key, T>::QMutableMapIterator(QMap<Key, T> &map)
Constructs an iterator for traversing \a map. The iterator is set
to be at the front of the map (before the first item).
@@ -1101,8 +1223,8 @@
\sa operator=()
*/
-/*! \fn QHashIterator::QHashIterator(const QHash<Key, T> &hash)
- \fn QMutableHashIterator::QMutableHashIterator(QHash<Key, T> &hash)
+/*! \fn template <class Key, class T> QHashIterator<Key, T>::QHashIterator(const QHash<Key, T> &hash)
+ \fn template <class Key, class T> QMutableHashIterator<Key, T>::QMutableHashIterator(QHash<Key, T> &hash)
Constructs an iterator for traversing \a hash. The iterator is
set to be at the front of the hash (before the first item).
@@ -1110,8 +1232,8 @@
\sa operator=()
*/
-/*! \fn QMapIterator &QMapIterator::operator=(const QMap<Key, T> &map)
- \fn QMutableMapIterator &QMutableMapIterator::operator=(QMap<Key, T> &map)
+/*! \fn template <class Key, class T> QMapIterator &QMapIterator<Key, T>::operator=(const QMap<Key, T> &map)
+ \fn template <class Key, class T> QMutableMapIterator &QMutableMapIterator<Key, T>::operator=(QMap<Key, T> &map)
Makes the iterator operate on \a map. The iterator is set to be
at the front of the map (before the first item).
@@ -1119,8 +1241,8 @@
\sa toFront(), toBack()
*/
-/*! \fn QHashIterator &QHashIterator::operator=(const QHash<Key, T> &hash)
- \fn QMutableHashIterator &QMutableHashIterator::operator=(QHash<Key, T> &hash)
+/*! \fn template <class Key, class T> QHashIterator &QHashIterator<Key, T>::operator=(const QHash<Key, T> &hash)
+ \fn template <class Key, class T> QMutableHashIterator &QMutableHashIterator<Key, T>::operator=(QHash<Key, T> &hash)
Makes the iterator operate on \a hash. The iterator is set to be
at the front of the hash (before the first item).
@@ -1128,10 +1250,10 @@
\sa toFront(), toBack()
*/
-/*! \fn void QMapIterator::toFront()
- \fn void QHashIterator::toFront()
- \fn void QMutableMapIterator::toFront()
- \fn void QMutableHashIterator::toFront()
+/*! \fn template <class Key, class T> void QMapIterator<Key, T>::toFront()
+ \fn template <class Key, class T> void QHashIterator<Key, T>::toFront()
+ \fn template <class Key, class T> void QMutableMapIterator<Key, T>::toFront()
+ \fn template <class Key, class T> void QMutableHashIterator<Key, T>::toFront()
Moves the iterator to the front of the container (before the
first item).
@@ -1139,10 +1261,10 @@
\sa toBack(), next()
*/
-/*! \fn void QMapIterator::toBack()
- \fn void QHashIterator::toBack()
- \fn void QMutableMapIterator::toBack()
- \fn void QMutableHashIterator::toBack()
+/*! \fn template <class Key, class T> void QMapIterator<Key, T>::toBack()
+ \fn template <class Key, class T> void QHashIterator<Key, T>::toBack()
+ \fn template <class Key, class T> void QMutableMapIterator<Key, T>::toBack()
+ \fn template <class Key, class T> void QMutableHashIterator<Key, T>::toBack()
Moves the iterator to the back of the container (after the last
item).
@@ -1150,10 +1272,10 @@
\sa toFront(), previous()
*/
-/*! \fn bool QMapIterator::hasNext() const
- \fn bool QHashIterator::hasNext() const
- \fn bool QMutableMapIterator::hasNext() const
- \fn bool QMutableHashIterator::hasNext() const
+/*! \fn template <class Key, class T> bool QMapIterator<Key, T>::hasNext() const
+ \fn template <class Key, class T> bool QHashIterator<Key, T>::hasNext() const
+ \fn template <class Key, class T> bool QMutableMapIterator<Key, T>::hasNext() const
+ \fn template <class Key, class T> bool QMutableHashIterator<Key, T>::hasNext() const
Returns \c true if there is at least one item ahead of the iterator,
i.e. the iterator is \e not at the back of the container;
@@ -1162,8 +1284,8 @@
\sa hasPrevious(), next()
*/
-/*! \fn QMapIterator::Item QMapIterator::next()
- \fn QHashIterator::Item QHashIterator::next()
+/*! \fn template <class Key, class T> QMapIterator<Key, T>::Item QMapIterator<Key, T>::next()
+ \fn template <class Key, class T> QHashIterator<Key, T>::Item QHashIterator<Key, T>::next()
Returns the next item and advances the iterator by one position.
@@ -1176,8 +1298,8 @@
\sa hasNext(), peekNext(), previous()
*/
-/*! \fn QMutableMapIterator::Item QMutableMapIterator::next()
- \fn QMutableHashIterator::Item QMutableHashIterator::next()
+/*! \fn template <class Key, class T> QMutableMapIterator<Key, T>::Item QMutableMapIterator<Key, T>::next()
+ \fn template <class Key, class T> QMutableHashIterator<Key, T>::Item QMutableHashIterator<Key, T>::next()
Returns the next item and advances the iterator by one position.
@@ -1190,8 +1312,8 @@
\sa hasNext(), peekNext(), previous()
*/
-/*! \fn QMapIterator::Item QMapIterator::peekNext() const
- \fn QHashIterator::Item QHashIterator::peekNext() const
+/*! \fn template <class Key, class T> QMapIterator<Key, T>::Item QMapIterator<Key, T>::peekNext() const
+ \fn template <class Key, class T> QHashIterator<Key, T>::Item QHashIterator<Key, T>::peekNext() const
Returns the next item without moving the iterator.
@@ -1204,8 +1326,8 @@
\sa hasNext(), next(), peekPrevious()
*/
-/*! \fn QMutableMapIterator::Item QMutableMapIterator::peekNext() const
- \fn QMutableHashIterator::Item QMutableHashIterator::peekNext() const
+/*! \fn template <class Key, class T> QMutableMapIterator<Key, T>::Item QMutableMapIterator<Key, T>::peekNext() const
+ \fn template <class Key, class T> QMutableHashIterator<Key, T>::Item QMutableHashIterator<Key, T>::peekNext() const
Returns a reference to the next item without moving the iterator.
@@ -1218,10 +1340,10 @@
\sa hasNext(), next(), peekPrevious()
*/
-/*! \fn bool QMapIterator::hasPrevious() const
- \fn bool QHashIterator::hasPrevious() const
- \fn bool QMutableMapIterator::hasPrevious() const
- \fn bool QMutableHashIterator::hasPrevious() const
+/*! \fn template <class Key, class T> bool QMapIterator<Key, T>::hasPrevious() const
+ \fn template <class Key, class T> bool QHashIterator<Key, T>::hasPrevious() const
+ \fn template <class Key, class T> bool QMutableMapIterator<Key, T>::hasPrevious() const
+ \fn template <class Key, class T> bool QMutableHashIterator<Key, T>::hasPrevious() const
Returns \c true if there is at least one item behind the iterator,
i.e. the iterator is \e not at the front of the container;
@@ -1230,8 +1352,8 @@
\sa hasNext(), previous()
*/
-/*! \fn QMapIterator::Item QMapIterator::previous()
- \fn QHashIterator::Item QHashIterator::previous()
+/*! \fn template <class Key, class T> QMapIterator<Key, T>::Item QMapIterator<Key, T>::previous()
+ \fn template <class Key, class T> QHashIterator<Key, T>::Item QHashIterator<Key, T>::previous()
Returns the previous item and moves the iterator back by one
position.
@@ -1245,8 +1367,8 @@
\sa hasPrevious(), peekPrevious(), next()
*/
-/*! \fn QMutableMapIterator::Item QMutableMapIterator::previous()
- \fn QMutableHashIterator::Item QMutableHashIterator::previous()
+/*! \fn template <class Key, class T> QMutableMapIterator<Key, T>::Item QMutableMapIterator<Key, T>::previous()
+ \fn template <class Key, class T> QMutableHashIterator<Key, T>::Item QMutableHashIterator<Key, T>::previous()
Returns the previous item and moves the iterator back by one
position.
@@ -1260,8 +1382,8 @@
\sa hasPrevious(), peekPrevious(), next()
*/
-/*! \fn QMapIterator::Item QMapIterator::peekPrevious() const
- \fn QHashIterator::Item QHashIterator::peekPrevious() const
+/*! \fn template <class Key, class T> QMapIterator<Key, T>::Item QMapIterator<Key, T>::peekPrevious() const
+ \fn template <class Key, class T> QHashIterator<Key, T>::Item QHashIterator<Key, T>::peekPrevious() const
Returns the previous item without moving the iterator.
@@ -1274,8 +1396,8 @@
\sa hasPrevious(), previous(), peekNext()
*/
-/*! \fn QMutableMapIterator::Item QMutableMapIterator::peekPrevious() const
- \fn QMutableHashIterator::Item QMutableHashIterator::peekPrevious() const
+/*! \fn template <class Key, class T> QMutableMapIterator<Key, T>::Item QMutableMapIterator<Key, T>::peekPrevious() const
+ \fn template <class Key, class T> QMutableHashIterator<Key, T>::Item QMutableHashIterator<Key, T>::peekPrevious() const
Returns the previous item without moving the iterator.
@@ -1288,8 +1410,8 @@
\sa hasPrevious(), previous(), peekNext()
*/
-/*! \fn const T &QMapIterator::value() const
- \fn const T &QHashIterator::value() const
+/*! \fn template <class Key, class T> const T &QMapIterator<Key, T>::value() const
+ \fn template <class Key, class T> const T &QHashIterator<Key, T>::value() const
Returns the value of the last item that was jumped over using one
of the traversal functions (next(), previous(), findNext(),
@@ -1303,8 +1425,8 @@
*/
/*!
- \fn const T &QMutableMapIterator::value() const
- \fn const T &QMutableHashIterator::value() const
+ \fn template <class Key, class T> const T &QMutableMapIterator<Key, T>::value() const
+ \fn template <class Key, class T> const T &QMutableHashIterator<Key, T>::value() const
Returns the value of the last item that was jumped over using one
of the traversal functions (next(), previous(), findNext(),
@@ -1318,8 +1440,8 @@
*/
/*!
- \fn T &QMutableMapIterator::value()
- \fn T &QMutableHashIterator::value()
+ \fn template <class Key, class T> T &QMutableMapIterator<Key, T>::value()
+ \fn template <class Key, class T> T &QMutableHashIterator<Key, T>::value()
\overload
Returns a non-const reference to the value of
@@ -1327,10 +1449,10 @@
of the traversal functions.
*/
-/*! \fn const Key &QMapIterator::key() const
- \fn const Key &QHashIterator::key() const
- \fn const Key &QMutableMapIterator::key() const
- \fn const Key &QMutableHashIterator::key() const
+/*! \fn template <class Key, class T> const Key &QMapIterator<Key, T>::key() const
+ \fn template <class Key, class T> const Key &QHashIterator<Key, T>::key() const
+ \fn template <class Key, class T> const Key &QMutableMapIterator<Key, T>::key() const
+ \fn template <class Key, class T> const Key &QMutableHashIterator<Key, T>::key() const
Returns the key of the last item that was jumped over using one
of the traversal functions (next(), previous(), findNext(),
@@ -1343,10 +1465,10 @@
\sa value()
*/
-/*! \fn bool QMapIterator::findNext(const T &value)
- \fn bool QHashIterator::findNext(const T &value)
- \fn bool QMutableMapIterator::findNext(const T &value)
- \fn bool QMutableHashIterator::findNext(const T &value)
+/*! \fn template <class Key, class T> bool QMapIterator<Key, T>::findNext(const T &value)
+ \fn template <class Key, class T> bool QHashIterator<Key, T>::findNext(const T &value)
+ \fn template <class Key, class T> bool QMutableMapIterator<Key, T>::findNext(const T &value)
+ \fn template <class Key, class T> bool QMutableHashIterator<Key, T>::findNext(const T &value)
Searches for \a value starting from the current iterator position
forward. Returns \c true if a (key, value) pair with value \a value
@@ -1359,10 +1481,10 @@
\sa findPrevious()
*/
-/*! \fn bool QMapIterator::findPrevious(const T &value)
- \fn bool QHashIterator::findPrevious(const T &value)
- \fn bool QMutableMapIterator::findPrevious(const T &value)
- \fn bool QMutableHashIterator::findPrevious(const T &value)
+/*! \fn template <class Key, class T> bool QMapIterator<Key, T>::findPrevious(const T &value)
+ \fn template <class Key, class T> bool QHashIterator<Key, T>::findPrevious(const T &value)
+ \fn template <class Key, class T> bool QMutableMapIterator<Key, T>::findPrevious(const T &value)
+ \fn template <class Key, class T> bool QMutableHashIterator<Key, T>::findPrevious(const T &value)
Searches for \a value starting from the current iterator position
backward. Returns \c true if a (key, value) pair with value \a value
@@ -1375,8 +1497,8 @@
\sa findNext()
*/
-/*! \fn void QMutableMapIterator::remove()
- \fn void QMutableHashIterator::remove()
+/*! \fn template <class Key, class T> void QMutableMapIterator<Key, T>::remove()
+ \fn template <class Key, class T> void QMutableHashIterator<Key, T>::remove()
Removes the last item that was jumped over using one of the
traversal functions (next(), previous(), findNext(), findPrevious()).
@@ -1384,8 +1506,8 @@
\sa setValue()
*/
-/*! \fn void QMutableMapIterator::setValue(const T &value)
- \fn void QMutableHashIterator::setValue(const T &value)
+/*! \fn template <class Key, class T> void QMutableMapIterator<Key, T>::setValue(const T &value)
+ \fn template <class Key, class T> void QMutableHashIterator<Key, T>::setValue(const T &value)
Replaces the value of the last item that was jumped over using
one of the traversal functions with \a value.
diff --git a/src/corelib/tools/qlinkedlist.cpp b/src/corelib/tools/qlinkedlist.cpp
index 642d2a28a0..d9d93862e5 100644
--- a/src/corelib/tools/qlinkedlist.cpp
+++ b/src/corelib/tools/qlinkedlist.cpp
@@ -118,13 +118,13 @@ const QLinkedListData QLinkedListData::shared_null = {
\sa QLinkedListIterator, QMutableLinkedListIterator, QList, QVector
*/
-/*! \fn QLinkedList::QLinkedList()
+/*! \fn template <class T> QLinkedList<T>::QLinkedList()
Constructs an empty list.
*/
/*!
- \fn QLinkedList::QLinkedList(QLinkedList<T> &&other)
+ \fn template <class T> QLinkedList<T>::QLinkedList(QLinkedList<T> &&other)
Move-constructs a QLinkedList instance, making it point at the same
object that \a other was pointing to.
@@ -132,7 +132,7 @@ const QLinkedListData QLinkedListData::shared_null = {
\since 5.2
*/
-/*! \fn QLinkedList::QLinkedList(const QLinkedList<T> &other)
+/*! \fn template <class T> QLinkedList<T>::QLinkedList(const QLinkedList<T> &other)
Constructs a copy of \a other.
@@ -144,7 +144,7 @@ const QLinkedListData QLinkedListData::shared_null = {
\sa operator=()
*/
-/*! \fn QLinkedList::QLinkedList(std::initializer_list<T> list)
+/*! \fn template <class T> QLinkedList<T>::QLinkedList(std::initializer_list<T> list)
\since 5.2
Constructs a list from the std::initializer_list specified by \a list.
@@ -153,26 +153,26 @@ const QLinkedListData QLinkedListData::shared_null = {
initializer lists.
*/
-/*! \fn QLinkedList::~QLinkedList()
+/*! \fn template <class T> QLinkedList<T>::~QLinkedList()
Destroys the list. References to the values in the list, and all
iterators over this list, become invalid.
*/
-/*! \fn QLinkedList<T> &QLinkedList::operator=(const QLinkedList<T> &other)
+/*! \fn template <class T> QLinkedList<T> &QLinkedList<T>::operator=(const QLinkedList<T> &other)
Assigns \a other to this list and returns a reference to this
list.
*/
-/*! \fn void QLinkedList::swap(QLinkedList<T> &other)
+/*! \fn template <class T> void QLinkedList<T>::swap(QLinkedList<T> &other)
\since 4.8
Swaps list \a other with this list. This operation is very
fast and never fails.
*/
-/*! \fn bool QLinkedList::operator==(const QLinkedList<T> &other) const
+/*! \fn template <class T> bool QLinkedList<T>::operator==(const QLinkedList<T> &other) const
Returns \c true if \a other is equal to this list; otherwise returns
false.
@@ -186,7 +186,7 @@ const QLinkedListData QLinkedListData::shared_null = {
\sa operator!=()
*/
-/*! \fn bool QLinkedList::operator!=(const QLinkedList<T> &other) const
+/*! \fn template <class T> bool QLinkedList<T>::operator!=(const QLinkedList<T> &other) const
Returns \c true if \a other is not equal to this list; otherwise
returns \c false.
@@ -200,34 +200,34 @@ const QLinkedListData QLinkedListData::shared_null = {
\sa operator==()
*/
-/*! \fn int QLinkedList::size() const
+/*! \fn template <class T> int QLinkedList<T>::size() const
Returns the number of items in the list.
\sa isEmpty(), count()
*/
-/*! \fn void QLinkedList::detach()
+/*! \fn template <class T> void QLinkedList<T>::detach()
\internal
*/
-/*! \fn bool QLinkedList::isDetached() const
+/*! \fn template <class T> bool QLinkedList<T>::isDetached() const
\internal
*/
-/*! \fn void QLinkedList::setSharable(bool sharable)
+/*! \fn template <class T> void QLinkedList<T>::setSharable(bool sharable)
\internal
*/
-/*! \fn bool QLinkedList::isSharedWith(const QLinkedList<T> &other) const
+/*! \fn template <class T> bool QLinkedList<T>::isSharedWith(const QLinkedList<T> &other) const
\internal
*/
-/*! \fn bool QLinkedList::isEmpty() const
+/*! \fn template <class T> bool QLinkedList<T>::isEmpty() const
Returns \c true if the list contains no items; otherwise returns
false.
@@ -235,14 +235,14 @@ const QLinkedListData QLinkedListData::shared_null = {
\sa size()
*/
-/*! \fn void QLinkedList::clear()
+/*! \fn template <class T> void QLinkedList<T>::clear()
Removes all the items in the list.
\sa removeAll()
*/
-/*! \fn void QLinkedList::append(const T &value)
+/*! \fn template <class T> void QLinkedList<T>::append(const T &value)
Inserts \a value at the end of the list.
@@ -254,7 +254,7 @@ const QLinkedListData QLinkedListData::shared_null = {
\sa operator<<(), prepend(), insert()
*/
-/*! \fn void QLinkedList::prepend(const T &value)
+/*! \fn template <class T> void QLinkedList<T>::prepend(const T &value)
Inserts \a value at the beginning of the list.
@@ -266,7 +266,7 @@ const QLinkedListData QLinkedListData::shared_null = {
\sa append(), insert()
*/
-/*! \fn int QLinkedList::removeAll(const T &value)
+/*! \fn template <class T> int QLinkedList<T>::removeAll(const T &value)
Removes all occurrences of \a value in the list.
@@ -280,7 +280,7 @@ const QLinkedListData QLinkedListData::shared_null = {
*/
/*!
- \fn bool QLinkedList::removeOne(const T &value)
+ \fn template <class T> bool QLinkedList<T>::removeOne(const T &value)
\since 4.4
Removes the first occurrences of \a value in the list. Returns \c true on
@@ -295,7 +295,7 @@ const QLinkedListData QLinkedListData::shared_null = {
\sa insert()
*/
-/*! \fn bool QLinkedList::contains(const T &value) const
+/*! \fn template <class T> bool QLinkedList<T>::contains(const T &value) const
Returns \c true if the list contains an occurrence of \a value;
otherwise returns \c false.
@@ -306,7 +306,7 @@ const QLinkedListData QLinkedListData::shared_null = {
\sa QLinkedListIterator::findNext(), QLinkedListIterator::findPrevious()
*/
-/*! \fn int QLinkedList::count(const T &value) const
+/*! \fn template <class T> int QLinkedList<T>::count(const T &value) const
Returns the number of occurrences of \a value in the list.
@@ -316,7 +316,7 @@ const QLinkedListData QLinkedListData::shared_null = {
\sa contains()
*/
-/*! \fn bool QLinkedList::startsWith(const T &value) const
+/*! \fn template <class T> bool QLinkedList<T>::startsWith(const T &value) const
\since 4.5
Returns \c true if the list is not empty and its first
@@ -325,7 +325,7 @@ const QLinkedListData QLinkedListData::shared_null = {
\sa isEmpty(), first()
*/
-/*! \fn bool QLinkedList::endsWith(const T &value) const
+/*! \fn template <class T> bool QLinkedList<T>::endsWith(const T &value) const
\since 4.5
Returns \c true if the list is not empty and its last
@@ -334,7 +334,7 @@ const QLinkedListData QLinkedListData::shared_null = {
\sa isEmpty(), last()
*/
-/*! \fn QLinkedList::iterator QLinkedList::begin()
+/*! \fn template <class T> QLinkedList<T>::iterator QLinkedList<T>::begin()
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the first item in
the list.
@@ -342,12 +342,12 @@ const QLinkedListData QLinkedListData::shared_null = {
\sa constBegin(), end()
*/
-/*! \fn QLinkedList::const_iterator QLinkedList::begin() const
+/*! \fn template <class T> QLinkedList<T>::const_iterator QLinkedList<T>::begin() const
\overload
*/
-/*! \fn QLinkedList::const_iterator QLinkedList::cbegin() const
+/*! \fn template <class T> QLinkedList<T>::const_iterator QLinkedList<T>::cbegin() const
\since 5.0
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first item
@@ -356,7 +356,7 @@ const QLinkedListData QLinkedListData::shared_null = {
\sa begin(), cend()
*/
-/*! \fn QLinkedList::const_iterator QLinkedList::constBegin() const
+/*! \fn template <class T> QLinkedList<T>::const_iterator QLinkedList<T>::constBegin() const
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first item
in the list.
@@ -364,7 +364,7 @@ const QLinkedListData QLinkedListData::shared_null = {
\sa begin(), constEnd()
*/
-/*! \fn QLinkedList::iterator QLinkedList::end()
+/*! \fn template <class T> QLinkedList<T>::iterator QLinkedList<T>::end()
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item
after the last item in the list.
@@ -372,12 +372,12 @@ const QLinkedListData QLinkedListData::shared_null = {
\sa begin(), constEnd()
*/
-/*! \fn QLinkedList::const_iterator QLinkedList::end() const
+/*! \fn template <class T> QLinkedList<T>::const_iterator QLinkedList<T>::end() const
\overload
*/
-/*! \fn QLinkedList::const_iterator QLinkedList::cend() const
+/*! \fn template <class T> QLinkedList<T>::const_iterator QLinkedList<T>::cend() const
\since 5.0
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary
@@ -386,7 +386,7 @@ const QLinkedListData QLinkedListData::shared_null = {
\sa cbegin(), end()
*/
-/*! \fn QLinkedList::const_iterator QLinkedList::constEnd() const
+/*! \fn template <class T> QLinkedList<T>::const_iterator QLinkedList<T>::constEnd() const
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary
item after the last item in the list.
@@ -394,7 +394,7 @@ const QLinkedListData QLinkedListData::shared_null = {
\sa constBegin(), end()
*/
-/*! \fn QLinkedList::reverse_iterator QLinkedList::rbegin()
+/*! \fn template <class T> QLinkedList<T>::reverse_iterator QLinkedList<T>::rbegin()
\since 5.6
Returns a \l{STL-style iterators}{STL-style} reverse iterator pointing to the first
@@ -403,12 +403,12 @@ const QLinkedListData QLinkedListData::shared_null = {
\sa begin(), crbegin(), rend()
*/
-/*! \fn QLinkedList::const_reverse_iterator QLinkedList::rbegin() const
+/*! \fn template <class T> QLinkedList<T>::const_reverse_iterator QLinkedList<T>::rbegin() const
\since 5.6
\overload
*/
-/*! \fn QLinkedList::const_reverse_iterator QLinkedList::crbegin() const
+/*! \fn template <class T> QLinkedList<T>::const_reverse_iterator QLinkedList<T>::crbegin() const
\since 5.6
Returns a const \l{STL-style iterators}{STL-style} reverse iterator pointing to the first
@@ -417,7 +417,7 @@ const QLinkedListData QLinkedListData::shared_null = {
\sa begin(), rbegin(), rend()
*/
-/*! \fn QLinkedList::reverse_iterator QLinkedList::rend()
+/*! \fn template <class T> QLinkedList<T>::reverse_iterator QLinkedList<T>::rend()
\since 5.6
Returns a \l{STL-style iterators}{STL-style} reverse iterator pointing to one past
@@ -426,12 +426,12 @@ const QLinkedListData QLinkedListData::shared_null = {
\sa end(), crend(), rbegin()
*/
-/*! \fn QLinkedList::const_reverse_iterator QLinkedList::rend() const
+/*! \fn template <class T> QLinkedList<T>::const_reverse_iterator QLinkedList<T>::rend() const
\since 5.6
\overload
*/
-/*! \fn QLinkedList::const_reverse_iterator QLinkedList::crend() const
+/*! \fn template <class T> QLinkedList<T>::const_reverse_iterator QLinkedList<T>::crend() const
\since 5.6
Returns a const \l{STL-style iterators}{STL-style} reverse iterator pointing to one
@@ -440,7 +440,7 @@ const QLinkedListData QLinkedListData::shared_null = {
\sa end(), rend(), rbegin()
*/
-/*! \fn QLinkedList::iterator QLinkedList::insert(iterator before, const T &value)
+/*! \fn template <class T> QLinkedList<T>::iterator QLinkedList<T>::insert(iterator before, const T &value)
Inserts \a value in front of the item pointed to by the iterator
\a before. Returns an iterator pointing at the inserted item.
@@ -448,7 +448,7 @@ const QLinkedListData QLinkedListData::shared_null = {
\sa erase()
*/
-/*! \fn QLinkedList::iterator QLinkedList::erase(iterator pos)
+/*! \fn template <class T> QLinkedList<T>::iterator QLinkedList<T>::erase(iterator pos)
Removes the item pointed to by the iterator \a pos from the list,
and returns an iterator to the next item in the list (which may be
@@ -457,7 +457,7 @@ const QLinkedListData QLinkedListData::shared_null = {
\sa insert()
*/
-/*! \fn QLinkedList::iterator QLinkedList::erase(iterator begin, iterator end)
+/*! \fn template <class T> QLinkedList<T>::iterator QLinkedList<T>::erase(iterator begin, iterator end)
\overload
@@ -549,12 +549,12 @@ const QLinkedListData QLinkedListData::shared_null = {
Typedef for ptrdiff_t. Provided for STL compatibility.
*/
-/*! \fn int QLinkedList::count() const
+/*! \fn template <class T> int QLinkedList<T>::count() const
Same as size().
*/
-/*! \fn T& QLinkedList::first()
+/*! \fn template <class T> T& QLinkedList<T>::first()
Returns a reference to the first item in the list. This function
assumes that the list isn't empty.
@@ -562,12 +562,12 @@ const QLinkedListData QLinkedListData::shared_null = {
\sa last(), isEmpty()
*/
-/*! \fn const T& QLinkedList::first() const
+/*! \fn template <class T> const T& QLinkedList<T>::first() const
\overload
*/
-/*! \fn T& QLinkedList::last()
+/*! \fn template <class T> T& QLinkedList<T>::last()
Returns a reference to the last item in the list. This function
assumes that the list isn't empty.
@@ -575,12 +575,12 @@ const QLinkedListData QLinkedListData::shared_null = {
\sa first(), isEmpty()
*/
-/*! \fn const T& QLinkedList::last() const
+/*! \fn template <class T> const T& QLinkedList<T>::last() const
\overload
*/
-/*! \fn void QLinkedList::removeFirst()
+/*! \fn template <class T> void QLinkedList<T>::removeFirst()
Removes the first item in the list.
@@ -589,14 +589,14 @@ const QLinkedListData QLinkedListData::shared_null = {
\sa removeLast(), erase()
*/
-/*! \fn void QLinkedList::removeLast()
+/*! \fn template <class T> void QLinkedList<T>::removeLast()
Removes the last item in the list.
\sa removeFirst(), erase()
*/
-/*! \fn T QLinkedList::takeFirst()
+/*! \fn template <class T> T QLinkedList<T>::takeFirst()
Removes the first item in the list and returns it.
@@ -606,7 +606,7 @@ const QLinkedListData QLinkedListData::shared_null = {
\sa takeLast(), removeFirst()
*/
-/*! \fn T QLinkedList::takeLast()
+/*! \fn template <class T> T QLinkedList<T>::takeLast()
Removes the last item in the list and returns it.
@@ -616,59 +616,59 @@ const QLinkedListData QLinkedListData::shared_null = {
\sa takeFirst(), removeLast()
*/
-/*! \fn void QLinkedList::push_back(const T &value)
+/*! \fn template <class T> void QLinkedList<T>::push_back(const T &value)
This function is provided for STL compatibility. It is equivalent
to append(\a value).
*/
-/*! \fn void QLinkedList::push_front(const T &value)
+/*! \fn template <class T> void QLinkedList<T>::push_front(const T &value)
This function is provided for STL compatibility. It is equivalent
to prepend(\a value).
*/
-/*! \fn T& QLinkedList::front()
+/*! \fn template <class T> T& QLinkedList<T>::front()
This function is provided for STL compatibility. It is equivalent
to first().
*/
-/*! \fn const T& QLinkedList::front() const
+/*! \fn template <class T> const T& QLinkedList<T>::front() const
\overload
*/
-/*! \fn T& QLinkedList::back()
+/*! \fn template <class T> T& QLinkedList<T>::back()
This function is provided for STL compatibility. It is equivalent
to last().
*/
-/*! \fn const T& QLinkedList::back() const
+/*! \fn template <class T> const T& QLinkedList<T>::back() const
\overload
*/
-/*! \fn void QLinkedList::pop_front()
+/*! \fn template <class T> void QLinkedList<T>::pop_front()
This function is provided for STL compatibility. It is equivalent
to removeFirst().
*/
-/*! \fn void QLinkedList::pop_back()
+/*! \fn template <class T> void QLinkedList<T>::pop_back()
This function is provided for STL compatibility. It is equivalent
to removeLast().
*/
-/*! \fn bool QLinkedList::empty() const
+/*! \fn template <class T> bool QLinkedList<T>::empty() const
This function is provided for STL compatibility. It is equivalent
to isEmpty() and returns \c true if the list is empty.
*/
-/*! \fn QLinkedList<T> &QLinkedList::operator+=(const QLinkedList<T> &other)
+/*! \fn template <class T> QLinkedList<T> &QLinkedList<T>::operator+=(const QLinkedList<T> &other)
Appends the items of the \a other list to this list and returns a
reference to this list.
@@ -676,14 +676,14 @@ const QLinkedListData QLinkedListData::shared_null = {
\sa operator+(), append()
*/
-/*! \fn void QLinkedList::operator+=(const T &value)
+/*! \fn template <class T> void QLinkedList<T>::operator+=(const T &value)
\overload
Appends \a value to the list.
*/
-/*! \fn QLinkedList<T> QLinkedList::operator+(const QLinkedList<T> &other) const
+/*! \fn template <class T> QLinkedList<T> QLinkedList<T>::operator+(const QLinkedList<T> &other) const
Returns a list that contains all the items in this list followed
by all the items in the \a other list.
@@ -691,7 +691,7 @@ const QLinkedListData QLinkedListData::shared_null = {
\sa operator+=()
*/
-/*! \fn QLinkedList<T> &QLinkedList::operator<<(const QLinkedList<T> &other)
+/*! \fn template <class T> QLinkedList<T> &QLinkedList<T>::operator<<(const QLinkedList<T> &other)
Appends the items of the \a other list to this list and returns a
reference to this list.
@@ -699,7 +699,7 @@ const QLinkedListData QLinkedListData::shared_null = {
\sa operator+=(), append()
*/
-/*! \fn QLinkedList<T> &QLinkedList::operator<<(const T &value)
+/*! \fn template <class T> QLinkedList<T> &QLinkedList<T>::operator<<(const T &value)
\overload
@@ -777,7 +777,7 @@ const QLinkedListData QLinkedListData::shared_null = {
\sa QLinkedList::const_iterator, QMutableLinkedListIterator
*/
-/*! \fn QLinkedList::iterator::iterator()
+/*! \fn template <class T> QLinkedList<T>::iterator::iterator()
Constructs an uninitialized iterator.
@@ -788,7 +788,7 @@ const QLinkedListData QLinkedListData::shared_null = {
\sa QLinkedList::begin(), QLinkedList::end()
*/
-/*! \fn QLinkedList::iterator::iterator(Node *node)
+/*! \fn template <class T> QLinkedList<T>::iterator::iterator(Node *node)
\internal
*/
@@ -818,25 +818,25 @@ const QLinkedListData QLinkedListData::shared_null = {
\internal
*/
-/*! \fn QLinkedList::iterator::iterator(const iterator &other)
+/*! \fn template <class T> QLinkedList<T>::iterator::iterator(const iterator &other)
Constructs a copy of \a other.
*/
-/*! \fn QLinkedList::iterator &QLinkedList::iterator::operator=(const iterator &other)
+/*! \fn template <class T> QLinkedList<T>::iterator &QLinkedList<T>::iterator::operator=(const iterator &other)
Assigns \a other to this iterator.
*/
/*!
- \fn QLinkedList<T> &QLinkedList::operator=(QLinkedList<T> &&other)
+ \fn template <class T> QLinkedList<T> &QLinkedList<T>::operator=(QLinkedList<T> &&other)
Move-assigns \a other to this QLinkedList instance.
\since 5.2
*/
-/*! \fn T &QLinkedList::iterator::operator*() const
+/*! \fn template <class T> T &QLinkedList<T>::iterator::operator*() const
Returns a modifiable reference to the current item.
@@ -848,7 +848,7 @@ const QLinkedListData QLinkedListData::shared_null = {
\sa operator->()
*/
-/*! \fn T *QLinkedList::iterator::operator->() const
+/*! \fn template <class T> T *QLinkedList<T>::iterator::operator->() const
Returns a pointer to the current item.
@@ -856,8 +856,8 @@ const QLinkedListData QLinkedListData::shared_null = {
*/
/*!
- \fn bool QLinkedList::iterator::operator==(const iterator &other) const
- \fn bool QLinkedList::iterator::operator==(const const_iterator &other) const
+ \fn template <class T> bool QLinkedList<T>::iterator::operator==(const iterator &other) const
+ \fn template <class T> bool QLinkedList<T>::iterator::operator==(const const_iterator &other) const
Returns \c true if \a other points to the same item as this
iterator; otherwise returns \c false.
@@ -866,8 +866,8 @@ const QLinkedListData QLinkedListData::shared_null = {
*/
/*!
- \fn bool QLinkedList::iterator::operator!=(const iterator &other) const
- \fn bool QLinkedList::iterator::operator!=(const const_iterator &other) const
+ \fn template <class T> bool QLinkedList<T>::iterator::operator!=(const iterator &other) const
+ \fn template <class T> bool QLinkedList<T>::iterator::operator!=(const const_iterator &other) const
Returns \c true if \a other points to a different item than this
iterator; otherwise returns \c false.
@@ -875,7 +875,7 @@ const QLinkedListData QLinkedListData::shared_null = {
\sa operator==()
*/
-/*! \fn QLinkedList::iterator &QLinkedList::iterator::operator++()
+/*! \fn template <class T> QLinkedList<T>::iterator &QLinkedList<T>::iterator::operator++()
The prefix ++ operator (\c{++it}) advances the iterator to the
next item in the list and returns an iterator to the new current
@@ -887,7 +887,7 @@ const QLinkedListData QLinkedListData::shared_null = {
\sa operator--()
*/
-/*! \fn QLinkedList::iterator QLinkedList::iterator::operator++(int)
+/*! \fn template <class T> QLinkedList<T>::iterator QLinkedList<T>::iterator::operator++(int)
\overload
@@ -896,7 +896,7 @@ const QLinkedListData QLinkedListData::shared_null = {
current item.
*/
-/*! \fn QLinkedList::iterator &QLinkedList::iterator::operator--()
+/*! \fn template <class T> QLinkedList<T>::iterator &QLinkedList<T>::iterator::operator--()
The prefix -- operator (\c{--it}) makes the preceding item
current and returns an iterator to the new current item.
@@ -907,7 +907,7 @@ const QLinkedListData QLinkedListData::shared_null = {
\sa operator++()
*/
-/*! \fn QLinkedList::iterator QLinkedList::iterator::operator--(int)
+/*! \fn template <class T> QLinkedList<T>::iterator QLinkedList<T>::iterator::operator--(int)
\overload
@@ -915,7 +915,7 @@ const QLinkedListData QLinkedListData::shared_null = {
current and returns an iterator to the previously current item.
*/
-/*! \fn QLinkedList::iterator QLinkedList::iterator::operator+(int j) const
+/*! \fn template <class T> QLinkedList<T>::iterator QLinkedList<T>::iterator::operator+(int j) const
Returns an iterator to the item at \a j positions forward from
this iterator. (If \a j is negative, the iterator goes backward.)
@@ -926,7 +926,7 @@ const QLinkedListData QLinkedListData::shared_null = {
*/
-/*! \fn QLinkedList::iterator QLinkedList::iterator::operator-(int j) const
+/*! \fn template <class T> QLinkedList<T>::iterator QLinkedList<T>::iterator::operator-(int j) const
Returns an iterator to the item at \a j positions backward from
this iterator. (If \a j is negative, the iterator goes forward.)
@@ -936,7 +936,7 @@ const QLinkedListData QLinkedListData::shared_null = {
\sa operator+()
*/
-/*! \fn QLinkedList::iterator &QLinkedList::iterator::operator+=(int j)
+/*! \fn template <class T> QLinkedList<T>::iterator &QLinkedList<T>::iterator::operator+=(int j)
Advances the iterator by \a j items. (If \a j is negative, the
iterator goes backward.)
@@ -944,7 +944,7 @@ const QLinkedListData QLinkedListData::shared_null = {
\sa operator-=(), operator+()
*/
-/*! \fn QLinkedList::iterator &QLinkedList::iterator::operator-=(int j)
+/*! \fn template <class T> QLinkedList<T>::iterator &QLinkedList<T>::iterator::operator-=(int j)
Makes the iterator go back by \a j items. (If \a j is negative,
the iterator goes forward.)
@@ -997,7 +997,7 @@ const QLinkedListData QLinkedListData::shared_null = {
\sa QLinkedList::iterator, QLinkedListIterator
*/
-/*! \fn QLinkedList::const_iterator::const_iterator()
+/*! \fn template <class T> QLinkedList<T>::const_iterator::const_iterator()
Constructs an uninitialized iterator.
@@ -1008,7 +1008,7 @@ const QLinkedListData QLinkedListData::shared_null = {
\sa QLinkedList::constBegin(), QLinkedList::constEnd()
*/
-/*! \fn QLinkedList::const_iterator::const_iterator(Node *node)
+/*! \fn template <class T> QLinkedList<T>::const_iterator::const_iterator(Node *node)
\internal
*/
@@ -1038,37 +1038,36 @@ const QLinkedListData QLinkedListData::shared_null = {
\internal
*/
-/*! \fn QLinkedList::const_iterator::const_iterator(const const_iterator &other)
+/*! \fn template <class T> QLinkedList<T>::const_iterator::const_iterator(const const_iterator &other)
Constructs a copy of \a other.
*/
-/*! \fn QLinkedList::const_iterator::const_iterator(iterator other)
+/*! \fn template <class T> QLinkedList<T>::const_iterator::const_iterator(iterator other)
Constructs a copy of \a other.
*/
-/*! \fn QLinkedList::const_iterator &QLinkedList::const_iterator::operator=( \
- const const_iterator &other)
+/*! \fn template <class T> typename QLinkedList<T>::const_iterator &QLinkedList<T>::const_iterator::operator=(const const_iterator &other)
Assigns \a other to this iterator.
*/
-/*! \fn const T &QLinkedList::const_iterator::operator*() const
+/*! \fn template <class T> const T &QLinkedList<T>::const_iterator::operator*() const
Returns a reference to the current item.
\sa operator->()
*/
-/*! \fn const T *QLinkedList::const_iterator::operator->() const
+/*! \fn template <class T> const T *QLinkedList<T>::const_iterator::operator->() const
Returns a pointer to the current item.
\sa operator*()
*/
-/*! \fn bool QLinkedList::const_iterator::operator==(const const_iterator &other) const
+/*! \fn template <class T> bool QLinkedList<T>::const_iterator::operator==(const const_iterator &other) const
Returns \c true if \a other points to the same item as this
iterator; otherwise returns \c false.
@@ -1076,7 +1075,7 @@ const QLinkedListData QLinkedListData::shared_null = {
\sa operator!=()
*/
-/*! \fn bool QLinkedList::const_iterator::operator!=(const const_iterator &other) const
+/*! \fn template <class T> bool QLinkedList<T>::const_iterator::operator!=(const const_iterator &other) const
Returns \c true if \a other points to a different item than this
iterator; otherwise returns \c false.
@@ -1084,19 +1083,19 @@ const QLinkedListData QLinkedListData::shared_null = {
\sa operator==()
*/
-/*! \fn QLinkedList::const_iterator &QLinkedList::const_iterator::operator++()
+/*! \fn template <class T> QLinkedList<T>::const_iterator &QLinkedList<T>::const_iterator::operator++()
The prefix ++ operator (\c{++it}) advances the iterator to the
next item in the list and returns an iterator to the new current
item.
- Calling this function on QLinkedList::constEnd() leads to
+ Calling this function on QLinkedList<T>::constEnd() leads to
undefined results.
\sa operator--()
*/
-/*! \fn QLinkedList::const_iterator QLinkedList::const_iterator::operator++(int)
+/*! \fn template <class T> QLinkedList<T>::const_iterator QLinkedList<T>::const_iterator::operator++(int)
\overload
@@ -1105,7 +1104,7 @@ const QLinkedListData QLinkedListData::shared_null = {
current item.
*/
-/*! \fn QLinkedList::const_iterator &QLinkedList::const_iterator::operator--()
+/*! \fn template <class T> QLinkedList<T>::const_iterator &QLinkedList<T>::const_iterator::operator--()
The prefix -- operator (\c{--it}) makes the preceding item
current and returns an iterator to the new current item.
@@ -1116,7 +1115,7 @@ const QLinkedListData QLinkedListData::shared_null = {
\sa operator++()
*/
-/*! \fn QLinkedList::const_iterator QLinkedList::const_iterator::operator--(int)
+/*! \fn template <class T> QLinkedList<T>::const_iterator QLinkedList<T>::const_iterator::operator--(int)
\overload
@@ -1124,7 +1123,7 @@ const QLinkedListData QLinkedListData::shared_null = {
current and returns an iterator to the previously current item.
*/
-/*! \fn QLinkedList::const_iterator QLinkedList::const_iterator::operator+(int j) const
+/*! \fn template <class T> QLinkedList<T>::const_iterator QLinkedList<T>::const_iterator::operator+(int j) const
Returns an iterator to the item at \a j positions forward from
this iterator. (If \a j is negative, the iterator goes backward.)
@@ -1134,7 +1133,7 @@ const QLinkedListData QLinkedListData::shared_null = {
\sa operator-()
*/
-/*! \fn QLinkedList::const_iterator QLinkedList::const_iterator::operator-(int j) const
+/*! \fn template <class T> QLinkedList<T>::const_iterator QLinkedList<T>::const_iterator::operator-(int j) const
This function returns an iterator to the item at \a j positions backward from
this iterator. (If \a j is negative, the iterator goes forward.)
@@ -1144,7 +1143,7 @@ const QLinkedListData QLinkedListData::shared_null = {
\sa operator+()
*/
-/*! \fn QLinkedList::const_iterator &QLinkedList::const_iterator::operator+=(int j)
+/*! \fn template <class T> QLinkedList<T>::const_iterator &QLinkedList<T>::const_iterator::operator+=(int j)
Advances the iterator by \a j items. (If \a j is negative, the
iterator goes backward.)
@@ -1154,7 +1153,7 @@ const QLinkedListData QLinkedListData::shared_null = {
\sa operator-=(), operator+()
*/
-/*! \fn QLinkedList::const_iterator &QLinkedList::const_iterator::operator-=(int j)
+/*! \fn template <class T> QLinkedList<T>::const_iterator &QLinkedList<T>::const_iterator::operator-=(int j)
Makes the iterator go back by \a j items. (If \a j is negative,
the iterator goes forward.)
@@ -1164,7 +1163,7 @@ const QLinkedListData QLinkedListData::shared_null = {
\sa operator+=(), operator-()
*/
-/*! \fn QDataStream &operator<<(QDataStream &out, const QLinkedList<T> &list)
+/*! \fn template <class T> QDataStream &operator<<(QDataStream &out, const QLinkedList<T> &list)
\relates QLinkedList
Writes the linked list \a list to stream \a out.
@@ -1175,7 +1174,7 @@ const QLinkedListData QLinkedListData::shared_null = {
\sa{Serializing Qt Data Types}{Format of the QDataStream operators}
*/
-/*! \fn QDataStream &operator>>(QDataStream &in, QLinkedList<T> &list)
+/*! \fn template <class T> QDataStream &operator>>(QDataStream &in, QLinkedList<T> &list)
\relates QLinkedList
Reads a linked list from stream \a in into \a list.
@@ -1187,7 +1186,7 @@ const QLinkedListData QLinkedListData::shared_null = {
/*!
\since 4.1
- \fn QLinkedList<T> QLinkedList<T>::fromStdList(const std::list<T> &list)
+ \fn template <class T> QLinkedList<T> QLinkedList<T>::fromStdList(const std::list<T> &list)
Returns a QLinkedList object with the data contained in \a list.
The order of the elements in the QLinkedList is the same as in \a
@@ -1202,7 +1201,7 @@ const QLinkedListData QLinkedListData::shared_null = {
/*!
\since 4.1
- \fn std::list<T> QLinkedList<T>::toStdList() const
+ \fn template <class T> std::list<T> QLinkedList<T>::toStdList() const
Returns a std::list object with the data contained in this
QLinkedList. Example:
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.cpp b/src/corelib/tools/qlist.cpp
index 5f26e704c4..c01d0c2d61 100644
--- a/src/corelib/tools/qlist.cpp
+++ b/src/corelib/tools/qlist.cpp
@@ -515,7 +515,7 @@ void **QListData::erase(void **xi)
*/
/*!
- \fn QList::QList(QList<T> &&other)
+ \fn template <class T> QList<T>::QList(QList<T> &&other)
Move-constructs a QList instance, making it point at the same
object that \a other was pointing to.
@@ -524,7 +524,7 @@ void **QListData::erase(void **xi)
*/
/*!
- \fn QList<T> QList<T>::mid(int pos, int length) const
+ \fn template <class T> QList<T> QList<T>::mid(int pos, int length) const
Returns a sub-list which includes elements from this list,
starting at position \a pos. If \a length is -1 (the default), all
@@ -533,12 +533,12 @@ void **QListData::erase(void **xi)
are included.
*/
-/*! \fn QList::QList()
+/*! \fn template <class T> QList<T>::QList()
Constructs an empty list.
*/
-/*! \fn QList::QList(const QList<T> &other)
+/*! \fn template <class T> QList<T>::QList(const QList<T> &other)
Constructs a copy of \a other.
@@ -551,7 +551,7 @@ void **QListData::erase(void **xi)
\sa operator=()
*/
-/*! \fn inline QList::QList(std::initializer_list<T> args)
+/*! \fn template <class T> QList<T>::QList(std::initializer_list<T> args)
\since 4.8
Construct a list from the std::initializer_list specified by \a args.
@@ -560,34 +560,34 @@ void **QListData::erase(void **xi)
lists.
*/
-/*! \fn QList::~QList()
+/*! \fn template <class T> QList<T>::~QList()
Destroys the list. References to the values in the list and all
iterators of this list become invalid.
*/
-/*! \fn QList<T> &QList::operator=(const QList<T> &other)
+/*! \fn template <class T> QList<T> &QList<T>::operator=(const QList<T> &other)
Assigns \a other to this list and returns a reference to this
list.
*/
/*!
- \fn QList &QList::operator=(QList<T> &&other)
+ \fn template <class T> QList &QList<T>::operator=(QList<T> &&other)
Move-assigns \a other to this QList instance.
\since 5.2
*/
-/*! \fn void QList::swap(QList<T> &other)
+/*! \fn template <class T> void QList<T>::swap(QList<T> &other)
\since 4.8
Swaps list \a other with this list. This operation is very
fast and never fails.
*/
-/*! \fn bool QList::operator==(const QList<T> &other) const
+/*! \fn template <class T> bool QList<T>::operator==(const QList<T> &other) const
Returns \c true if \a other is equal to this list; otherwise returns
false.
@@ -601,7 +601,7 @@ void **QListData::erase(void **xi)
\sa operator!=()
*/
-/*! \fn bool QList::operator!=(const QList<T> &other) const
+/*! \fn template <class T> bool QList<T>::operator!=(const QList<T> &other) const
Returns \c true if \a other is not equal to this list; otherwise
returns \c false.
@@ -615,7 +615,7 @@ void **QListData::erase(void **xi)
\sa operator==()
*/
-/*! \fn bool operator<(const QList<T> &lhs, const QList<T> &rhs)
+/*! \fn template <class T> bool operator<(const QList<T> &lhs, const QList<T> &rhs)
\since 5.6
\relates QList
@@ -627,7 +627,7 @@ void **QListData::erase(void **xi)
of \c operator<().
*/
-/*! \fn bool operator<=(const QList<T> &lhs, const QList<T> &rhs)
+/*! \fn template <class T> bool operator<=(const QList<T> &lhs, const QList<T> &rhs)
\since 5.6
\relates QList
@@ -639,7 +639,7 @@ void **QListData::erase(void **xi)
of \c operator<().
*/
-/*! \fn bool operator>(const QList<T> &lhs, const QList<T> &rhs)
+/*! \fn template <class T> bool operator>(const QList<T> &lhs, const QList<T> &rhs)
\since 5.6
\relates QList
@@ -651,7 +651,7 @@ void **QListData::erase(void **xi)
of \c operator<().
*/
-/*! \fn bool operator>=(const QList<T> &lhs, const QList<T> &rhs)
+/*! \fn template <class T> bool operator>=(const QList<T> &lhs, const QList<T> &rhs)
\since 5.6
\relates QList
@@ -664,7 +664,7 @@ void **QListData::erase(void **xi)
*/
/*!
- \fn uint qHash(const QList<T> &key, uint seed = 0)
+ \fn template <class T> uint qHash(const QList<T> &key, uint seed = 0)
\since 5.6
\relates QList
@@ -675,19 +675,19 @@ void **QListData::erase(void **xi)
*/
/*!
- \fn int QList::size() const
+ \fn template <class T> int QList<T>::size() const
Returns the number of items in the list.
\sa isEmpty(), count()
*/
-/*! \fn void QList::detach()
+/*! \fn template <class T> void QList<T>::detach()
\internal
*/
-/*! \fn void QList::detachShared()
+/*! \fn template <class T> void QList<T>::detachShared()
\internal
@@ -696,22 +696,22 @@ void **QListData::erase(void **xi)
in case of cleanup work done in destructors on empty lists.
*/
-/*! \fn bool QList::isDetached() const
+/*! \fn template <class T> bool QList<T>::isDetached() const
\internal
*/
-/*! \fn void QList::setSharable(bool sharable)
+/*! \fn template <class T> void QList<T>::setSharable(bool sharable)
\internal
*/
-/*! \fn bool QList::isSharedWith(const QList<T> &other) const
+/*! \fn template <class T> bool QList<T>::isSharedWith(const QList<T> &other) const
\internal
*/
-/*! \fn bool QList::isEmpty() const
+/*! \fn template <class T> bool QList<T>::isEmpty() const
Returns \c true if the list contains no items; otherwise returns
false.
@@ -719,14 +719,14 @@ void **QListData::erase(void **xi)
\sa size()
*/
-/*! \fn void QList::clear()
+/*! \fn template <class T> void QList<T>::clear()
Removes all items from the list.
\sa removeAll()
*/
-/*! \fn const T &QList::at(int i) const
+/*! \fn template <class T> const T &QList<T>::at(int i) const
Returns the item at index position \a i in the list. \a i must be
a valid index position in the list (i.e., 0 <= \a i < size()).
@@ -736,7 +736,7 @@ void **QListData::erase(void **xi)
\sa value(), operator[]()
*/
-/*! \fn T &QList::operator[](int i)
+/*! \fn template <class T> T &QList<T>::operator[](int i)
Returns the item at index position \a i as a modifiable reference.
\a i must be a valid index position in the list (i.e., 0 <= \a i <
@@ -750,14 +750,14 @@ void **QListData::erase(void **xi)
\sa at(), value()
*/
-/*! \fn const T &QList::operator[](int i) const
+/*! \fn template <class T> const T &QList<T>::operator[](int i) const
\overload
Same as at(). This function runs in \l{Algorithmic Complexity}{constant time}.
*/
-/*! \fn QList::reserve(int alloc)
+/*! \fn template <class T> QList<T>::reserve(int alloc)
Reserve space for \a alloc elements.
@@ -770,7 +770,7 @@ void **QListData::erase(void **xi)
\since 4.7
*/
-/*! \fn void QList::append(const T &value)
+/*! \fn template <class T> void QList<T>::append(const T &value)
Inserts \a value at the end of the list.
@@ -787,7 +787,7 @@ void **QListData::erase(void **xi)
\sa operator<<(), prepend(), insert()
*/
-/*! \fn void QList::append(const QList<T> &value)
+/*! \fn template <class T> void QList<T>::append(const QList<T> &value)
\overload
@@ -798,7 +798,7 @@ void **QListData::erase(void **xi)
\sa operator<<(), operator+=()
*/
-/*! \fn void QList::prepend(const T &value)
+/*! \fn template <class T> void QList<T>::prepend(const T &value)
Inserts \a value at the beginning of the list.
@@ -815,7 +815,7 @@ void **QListData::erase(void **xi)
\sa append(), insert()
*/
-/*! \fn void QList::insert(int i, const T &value)
+/*! \fn template <class T> void QList<T>::insert(int i, const T &value)
Inserts \a value at index position \a i in the list. If \a i <= 0,
the value is prepended to the list. If \a i >= size(), the
@@ -827,7 +827,7 @@ void **QListData::erase(void **xi)
\sa append(), prepend(), replace(), removeAt()
*/
-/*! \fn QList::iterator QList::insert(iterator before, const T &value)
+/*! \fn template <class T> QList<T>::iterator QList<T>::insert(iterator before, const T &value)
\overload
@@ -838,7 +838,7 @@ void **QListData::erase(void **xi)
instead.
*/
-/*! \fn void QList::replace(int i, const T &value)
+/*! \fn template <class T> void QList<T>::replace(int i, const T &value)
Replaces the item at index position \a i with \a value. \a i must
be a valid index position in the list (i.e., 0 <= \a i < size()).
@@ -847,7 +847,7 @@ void **QListData::erase(void **xi)
*/
/*!
- \fn int QList::removeAll(const T &value)
+ \fn template <class T> int QList<T>::removeAll(const T &value)
Removes all occurrences of \a value in the list and returns the
number of entries removed.
@@ -862,7 +862,7 @@ void **QListData::erase(void **xi)
*/
/*!
- \fn bool QList::removeOne(const T &value)
+ \fn template <class T> bool QList<T>::removeOne(const T &value)
\since 4.4
Removes the first occurrence of \a value in the list and returns
@@ -877,7 +877,7 @@ void **QListData::erase(void **xi)
\sa removeAll(), removeAt(), takeAt(), replace()
*/
-/*! \fn void QList::removeAt(int i)
+/*! \fn template <class T> void QList<T>::removeAt(int i)
Removes the item at index position \a i. \a i must be a valid
index position in the list (i.e., 0 <= \a i < size()).
@@ -885,7 +885,7 @@ void **QListData::erase(void **xi)
\sa takeAt(), removeFirst(), removeLast(), removeOne()
*/
-/*! \fn T QList::takeAt(int i)
+/*! \fn template <class T> T QList<T>::takeAt(int i)
Removes the item at index position \a i and returns it. \a i must
be a valid index position in the list (i.e., 0 <= \a i < size()).
@@ -895,7 +895,7 @@ void **QListData::erase(void **xi)
\sa removeAt(), takeFirst(), takeLast()
*/
-/*! \fn T QList::takeFirst()
+/*! \fn template <class T> T QList<T>::takeFirst()
Removes the first item in the list and returns it. This is the
same as takeAt(0). This function assumes the list is not empty. To
@@ -910,7 +910,7 @@ void **QListData::erase(void **xi)
\sa takeLast(), takeAt(), removeFirst()
*/
-/*! \fn T QList::takeLast()
+/*! \fn template <class T> T QList<T>::takeLast()
Removes the last item in the list and returns it. This is the
same as takeAt(size() - 1). This function assumes the list is
@@ -926,7 +926,7 @@ void **QListData::erase(void **xi)
\sa takeFirst(), takeAt(), removeLast()
*/
-/*! \fn void QList::move(int from, int to)
+/*! \fn template <class T> void QList<T>::move(int from, int to)
Moves the item at index position \a from to index position \a to.
@@ -941,7 +941,7 @@ void **QListData::erase(void **xi)
\sa swap(), insert(), takeAt()
*/
-/*! \fn void QList::swap(int i, int j)
+/*! \fn template <class T> void QList<T>::swap(int i, int j)
Exchange the item at index position \a i with the item at index
position \a j. This function assumes that both \a i and \a j are
@@ -954,7 +954,7 @@ void **QListData::erase(void **xi)
\sa move()
*/
-/*! \fn int QList::indexOf(const T &value, int from = 0) const
+/*! \fn template <class T> int QList<T>::indexOf(const T &value, int from = 0) const
Returns the index position of the first occurrence of \a value in
the list, searching forward from index position \a from. Returns
@@ -973,7 +973,7 @@ void **QListData::erase(void **xi)
\sa lastIndexOf(), contains()
*/
-/*! \fn int QList::lastIndexOf(const T &value, int from = -1) const
+/*! \fn template <class T> int QList<T>::lastIndexOf(const T &value, int from = -1) const
Returns the index position of the last occurrence of \a value in
the list, searching backward from index position \a from. If \a
@@ -993,7 +993,7 @@ void **QListData::erase(void **xi)
\sa indexOf()
*/
-/*! \fn bool QList::contains(const T &value) const
+/*! \fn template <class T> bool QList<T>::contains(const T &value) const
Returns \c true if the list contains an occurrence of \a value;
otherwise returns \c false.
@@ -1004,7 +1004,7 @@ void **QListData::erase(void **xi)
\sa indexOf(), count()
*/
-/*! \fn int QList::count(const T &value) const
+/*! \fn template <class T> int QList<T>::count(const T &value) const
Returns the number of occurrences of \a value in the list.
@@ -1014,7 +1014,7 @@ void **QListData::erase(void **xi)
\sa contains(), indexOf()
*/
-/*! \fn bool QList::startsWith(const T &value) const
+/*! \fn template <class T> bool QList<T>::startsWith(const T &value) const
\since 4.5
Returns \c true if this list is not empty and its first
@@ -1023,7 +1023,7 @@ void **QListData::erase(void **xi)
\sa isEmpty(), contains()
*/
-/*! \fn bool QList::endsWith(const T &value) const
+/*! \fn template <class T> bool QList<T>::endsWith(const T &value) const
\since 4.5
Returns \c true if this list is not empty and its last
@@ -1032,7 +1032,7 @@ void **QListData::erase(void **xi)
\sa isEmpty(), contains()
*/
-/*! \fn QList::iterator QList::begin()
+/*! \fn template <class T> QList<T>::iterator QList<T>::begin()
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the first item in
the list.
@@ -1040,12 +1040,12 @@ void **QListData::erase(void **xi)
\sa constBegin(), end()
*/
-/*! \fn QList::const_iterator QList::begin() const
+/*! \fn template <class T> QList<T>::const_iterator QList<T>::begin() const
\overload
*/
-/*! \fn QList::const_iterator QList::cbegin() const
+/*! \fn template <class T> QList<T>::const_iterator QList<T>::cbegin() const
\since 5.0
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first item
@@ -1054,7 +1054,7 @@ void **QListData::erase(void **xi)
\sa begin(), cend()
*/
-/*! \fn QList::const_iterator QList::constBegin() const
+/*! \fn template <class T> QList<T>::const_iterator QList<T>::constBegin() const
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first item
in the list.
@@ -1062,7 +1062,7 @@ void **QListData::erase(void **xi)
\sa begin(), constEnd()
*/
-/*! \fn QList::iterator QList::end()
+/*! \fn template <class T> QList<T>::iterator QList<T>::end()
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item
after the last item in the list.
@@ -1070,12 +1070,12 @@ void **QListData::erase(void **xi)
\sa begin(), constEnd()
*/
-/*! \fn const_iterator QList::end() const
+/*! \fn template <class T> const_iterator QList<T>::end() const
\overload
*/
-/*! \fn QList::const_iterator QList::cend() const
+/*! \fn template <class T> QList<T>::const_iterator QList<T>::cend() const
\since 5.0
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary
@@ -1084,7 +1084,7 @@ void **QListData::erase(void **xi)
\sa cbegin(), end()
*/
-/*! \fn QList::const_iterator QList::constEnd() const
+/*! \fn template <class T> QList<T>::const_iterator QList<T>::constEnd() const
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary
item after the last item in the list.
@@ -1092,7 +1092,7 @@ void **QListData::erase(void **xi)
\sa constBegin(), end()
*/
-/*! \fn QList::reverse_iterator QList::rbegin()
+/*! \fn template <class T> QList<T>::reverse_iterator QList<T>::rbegin()
\since 5.6
Returns a \l{STL-style iterators}{STL-style} reverse iterator pointing to the first
@@ -1101,12 +1101,12 @@ void **QListData::erase(void **xi)
\sa begin(), crbegin(), rend()
*/
-/*! \fn QList::const_reverse_iterator QList::rbegin() const
+/*! \fn template <class T> QList<T>::const_reverse_iterator QList<T>::rbegin() const
\since 5.6
\overload
*/
-/*! \fn QList::const_reverse_iterator QList::crbegin() const
+/*! \fn template <class T> QList<T>::const_reverse_iterator QList<T>::crbegin() const
\since 5.6
Returns a const \l{STL-style iterators}{STL-style} reverse iterator pointing to the first
@@ -1115,7 +1115,7 @@ void **QListData::erase(void **xi)
\sa begin(), rbegin(), rend()
*/
-/*! \fn QList::reverse_iterator QList::rend()
+/*! \fn template <class T> QList<T>::reverse_iterator QList<T>::rend()
\since 5.6
Returns a \l{STL-style iterators}{STL-style} reverse iterator pointing to one past
@@ -1124,12 +1124,12 @@ void **QListData::erase(void **xi)
\sa end(), crend(), rbegin()
*/
-/*! \fn QList::const_reverse_iterator QList::rend() const
+/*! \fn template <class T> QList<T>::const_reverse_iterator QList<T>::rend() const
\since 5.6
\overload
*/
-/*! \fn QList::const_reverse_iterator QList::crend() const
+/*! \fn template <class T> QList<T>::const_reverse_iterator QList<T>::crend() const
\since 5.6
Returns a const \l{STL-style iterators}{STL-style} reverse iterator pointing to one
@@ -1138,7 +1138,7 @@ void **QListData::erase(void **xi)
\sa end(), rend(), rbegin()
*/
-/*! \fn QList::iterator QList::erase(iterator pos)
+/*! \fn template <class T> QList<T>::iterator QList<T>::erase(iterator pos)
Removes the item associated with the iterator \a pos from the
list, and returns an iterator to the next item in the list (which
@@ -1147,7 +1147,7 @@ void **QListData::erase(void **xi)
\sa insert(), removeAt()
*/
-/*! \fn QList::iterator QList::erase(iterator begin, iterator end)
+/*! \fn template <class T> QList<T>::iterator QList<T>::erase(iterator begin, iterator end)
\overload
@@ -1240,13 +1240,13 @@ void **QListData::erase(void **xi)
\sa QList::rbegin(), QList::rend(), QList::reverse_iterator, QList::const_iterator
*/
-/*! \fn int QList::count() const
+/*! \fn template <class T> int QList<T>::count() const
Returns the number of items in the list. This is effectively the
same as size().
*/
-/*! \fn int QList::length() const
+/*! \fn template <class T> int QList<T>::length() const
\since 4.5
This function is identical to count().
@@ -1254,7 +1254,7 @@ void **QListData::erase(void **xi)
\sa count()
*/
-/*! \fn T& QList::first()
+/*! \fn template <class T> T& QList<T>::first()
Returns a reference to the first item in the list. The list must
not be empty. If the list can be empty, call isEmpty() before
@@ -1263,12 +1263,12 @@ void **QListData::erase(void **xi)
\sa constFirst(), last(), isEmpty()
*/
-/*! \fn const T& QList::first() const
+/*! \fn template <class T> const T& QList<T>::first() const
\overload
*/
-/*! \fn const T& QList::constFirst() const
+/*! \fn template <class T> const T& QList<T>::constFirst() const
\since 5.6
Returns a const reference to the first item in the list. The list must
@@ -1278,7 +1278,7 @@ void **QListData::erase(void **xi)
\sa constLast(), isEmpty(), first()
*/
-/*! \fn T& QList::last()
+/*! \fn template <class T> T& QList<T>::last()
Returns a reference to the last item in the list. The list must
not be empty. If the list can be empty, call isEmpty() before
@@ -1287,12 +1287,12 @@ void **QListData::erase(void **xi)
\sa constLast(), first(), isEmpty()
*/
-/*! \fn const T& QList::last() const
+/*! \fn template <class T> const T& QList<T>::last() const
\overload
*/
-/*! \fn const T& QList::constLast() const
+/*! \fn template <class T> const T& QList<T>::constLast() const
\since 5.6
Returns a reference to the last item in the list. The list must
@@ -1302,7 +1302,7 @@ void **QListData::erase(void **xi)
\sa constFirst(), isEmpty(), last()
*/
-/*! \fn void QList::removeFirst()
+/*! \fn template <class T> void QList<T>::removeFirst()
Removes the first item in the list. Calling this function is
equivalent to calling removeAt(0). The list must not be empty. If
@@ -1312,7 +1312,7 @@ void **QListData::erase(void **xi)
\sa removeAt(), takeFirst()
*/
-/*! \fn void QList::removeLast()
+/*! \fn template <class T> void QList<T>::removeLast()
Removes the last item in the list. Calling this function is
equivalent to calling removeAt(size() - 1). The list must not be
@@ -1322,7 +1322,7 @@ void **QListData::erase(void **xi)
\sa removeAt(), takeLast()
*/
-/*! \fn T QList::value(int i) const
+/*! \fn template <class T> T QList<T>::value(int i) const
Returns the value at index position \a i in the list.
@@ -1334,7 +1334,7 @@ void **QListData::erase(void **xi)
\sa at(), operator[]()
*/
-/*! \fn T QList::value(int i, const T &defaultValue) const
+/*! \fn template <class T> T QList<T>::value(int i, const T &defaultValue) const
\overload
@@ -1342,63 +1342,63 @@ void **QListData::erase(void **xi)
\a defaultValue.
*/
-/*! \fn void QList::push_back(const T &value)
+/*! \fn template <class T> void QList<T>::push_back(const T &value)
This function is provided for STL compatibility. It is equivalent
to \l{QList::append()}{append(\a value)}.
*/
-/*! \fn void QList::push_front(const T &value)
+/*! \fn template <class T> void QList<T>::push_front(const T &value)
This function is provided for STL compatibility. It is equivalent
to \l{QList::prepend()}{prepend(\a value)}.
*/
-/*! \fn T& QList::front()
+/*! \fn template <class T> T& QList<T>::front()
This function is provided for STL compatibility. It is equivalent
to first(). The list must not be empty. If the list can be empty,
call isEmpty() before calling this function.
*/
-/*! \fn const T& QList::front() const
+/*! \fn template <class T> const T& QList<T>::front() const
\overload
*/
-/*! \fn T& QList::back()
+/*! \fn template <class T> T& QList<T>::back()
This function is provided for STL compatibility. It is equivalent
to last(). The list must not be empty. If the list can be empty,
call isEmpty() before calling this function.
*/
-/*! \fn const T& QList::back() const
+/*! \fn template <class T> const T& QList<T>::back() const
\overload
*/
-/*! \fn void QList::pop_front()
+/*! \fn template <class T> void QList<T>::pop_front()
This function is provided for STL compatibility. It is equivalent
to removeFirst(). The list must not be empty. If the list can be
empty, call isEmpty() before calling this function.
*/
-/*! \fn void QList::pop_back()
+/*! \fn template <class T> void QList<T>::pop_back()
This function is provided for STL compatibility. It is equivalent
to removeLast(). The list must not be empty. If the list can be
empty, call isEmpty() before calling this function.
*/
-/*! \fn bool QList::empty() const
+/*! \fn template <class T> bool QList<T>::empty() const
This function is provided for STL compatibility. It is equivalent
to isEmpty() and returns \c true if the list is empty.
*/
-/*! \fn QList<T> &QList::operator+=(const QList<T> &other)
+/*! \fn template <class T> QList<T> &QList<T>::operator+=(const QList<T> &other)
Appends the items of the \a other list to this list and returns a
reference to this list.
@@ -1406,7 +1406,7 @@ void **QListData::erase(void **xi)
\sa operator+(), append()
*/
-/*! \fn void QList::operator+=(const T &value)
+/*! \fn template <class T> void QList<T>::operator+=(const T &value)
\overload
@@ -1415,7 +1415,7 @@ void **QListData::erase(void **xi)
\sa append(), operator<<()
*/
-/*! \fn QList<T> QList::operator+(const QList<T> &other) const
+/*! \fn template <class T> QList<T> QList<T>::operator+(const QList<T> &other) const
Returns a list that contains all the items in this list followed
by all the items in the \a other list.
@@ -1423,7 +1423,7 @@ void **QListData::erase(void **xi)
\sa operator+=()
*/
-/*! \fn QList<T> &QList::operator<<(const QList<T> &other)
+/*! \fn template <class T> QList<T> &QList<T>::operator<<(const QList<T> &other)
Appends the items of the \a other list to this list and returns a
reference to this list.
@@ -1431,7 +1431,7 @@ void **QListData::erase(void **xi)
\sa operator+=(), append()
*/
-/*! \fn void QList::operator<<(const T &value)
+/*! \fn template <class T> void QList<T>::operator<<(const T &value)
\overload
@@ -1521,7 +1521,7 @@ void **QListData::erase(void **xi)
\internal
*/
-/*! \fn QList::iterator::iterator()
+/*! \fn template <class T> QList<T>::iterator::iterator()
Constructs an uninitialized iterator.
@@ -1532,17 +1532,17 @@ void **QListData::erase(void **xi)
\sa QList::begin(), QList::end()
*/
-/*! \fn QList::iterator::iterator(Node *node)
+/*! \fn template <class T> QList<T>::iterator::iterator(Node *node)
\internal
*/
-/*! \fn QList::iterator::iterator(const iterator &other)
+/*! \fn template <class T> QList<T>::iterator::iterator(const iterator &other)
Constructs a copy of \a other.
*/
-/*! \fn T &QList::iterator::operator*() const
+/*! \fn template <class T> T &QList<T>::iterator::operator*() const
Returns a modifiable reference to the current item.
@@ -1554,14 +1554,14 @@ void **QListData::erase(void **xi)
\sa operator->()
*/
-/*! \fn T *QList::iterator::operator->() const
+/*! \fn template <class T> T *QList<T>::iterator::operator->() const
Returns a pointer to the current item.
\sa operator*()
*/
-/*! \fn T &QList::iterator::operator[](difference_type j) const
+/*! \fn template <class T> T &QList<T>::iterator::operator[](difference_type j) const
Returns a modifiable reference to the item at position *this +
\a{j}.
@@ -1573,8 +1573,8 @@ void **QListData::erase(void **xi)
*/
/*!
- \fn bool QList::iterator::operator==(const iterator &other) const
- \fn bool QList::iterator::operator==(const const_iterator &other) const
+ \fn template <class T> bool QList<T>::iterator::operator==(const iterator &other) const
+ \fn template <class T> bool QList<T>::iterator::operator==(const const_iterator &other) const
Returns \c true if \a other points to the same item as this
iterator; otherwise returns \c false.
@@ -1583,8 +1583,8 @@ void **QListData::erase(void **xi)
*/
/*!
- \fn bool QList::iterator::operator!=(const iterator &other) const
- \fn bool QList::iterator::operator!=(const const_iterator &other) const
+ \fn template <class T> bool QList<T>::iterator::operator!=(const iterator &other) const
+ \fn template <class T> bool QList<T>::iterator::operator!=(const const_iterator &other) const
Returns \c true if \a other points to a different item than this
iterator; otherwise returns \c false.
@@ -1593,38 +1593,38 @@ void **QListData::erase(void **xi)
*/
/*!
- \fn bool QList::iterator::operator<(const iterator& other) const
- \fn bool QList::iterator::operator<(const const_iterator& other) const
+ \fn template <class T> bool QList<T>::iterator::operator<(const iterator& other) const
+ \fn template <class T> bool QList<T>::iterator::operator<(const const_iterator& other) const
Returns \c true if the item pointed to by this iterator is less than
the item pointed to by the \a other iterator.
*/
/*!
- \fn bool QList::iterator::operator<=(const iterator& other) const
- \fn bool QList::iterator::operator<=(const const_iterator& other) const
+ \fn template <class T> bool QList<T>::iterator::operator<=(const iterator& other) const
+ \fn template <class T> bool QList<T>::iterator::operator<=(const const_iterator& other) const
Returns \c true if the item pointed to by this iterator is less than
or equal to the item pointed to by the \a other iterator.
*/
/*!
- \fn bool QList::iterator::operator>(const iterator& other) const
- \fn bool QList::iterator::operator>(const const_iterator& other) const
+ \fn template <class T> bool QList<T>::iterator::operator>(const iterator& other) const
+ \fn template <class T> bool QList<T>::iterator::operator>(const const_iterator& other) const
Returns \c true if the item pointed to by this iterator is greater
than the item pointed to by the \a other iterator.
*/
/*!
- \fn bool QList::iterator::operator>=(const iterator& other) const
- \fn bool QList::iterator::operator>=(const const_iterator& other) const
+ \fn template <class T> bool QList<T>::iterator::operator>=(const iterator& other) const
+ \fn template <class T> bool QList<T>::iterator::operator>=(const const_iterator& other) const
Returns \c true if the item pointed to by this iterator is greater
than or equal to the item pointed to by the \a other iterator.
*/
-/*! \fn QList::iterator &QList::iterator::operator++()
+/*! \fn template <class T> QList<T>::iterator &QList<T>::iterator::operator++()
The prefix ++ operator (\c{++it}) advances the iterator to the
next item in the list and returns an iterator to the new current
@@ -1635,7 +1635,7 @@ void **QListData::erase(void **xi)
\sa operator--()
*/
-/*! \fn QList::iterator QList::iterator::operator++(int)
+/*! \fn template <class T> QList<T>::iterator QList<T>::iterator::operator++(int)
\overload
@@ -1644,7 +1644,7 @@ void **QListData::erase(void **xi)
current item.
*/
-/*! \fn QList::iterator &QList::iterator::operator--()
+/*! \fn template <class T> QList<T>::iterator &QList<T>::iterator::operator--()
The prefix -- operator (\c{--it}) makes the preceding item
current and returns an iterator to the new current item.
@@ -1654,7 +1654,7 @@ void **QListData::erase(void **xi)
\sa operator++()
*/
-/*! \fn QList::iterator QList::iterator::operator--(int)
+/*! \fn template <class T> QList<T>::iterator QList<T>::iterator::operator--(int)
\overload
@@ -1662,7 +1662,7 @@ void **QListData::erase(void **xi)
current and returns an iterator to the previously current item.
*/
-/*! \fn QList::iterator &QList::iterator::operator+=(difference_type j)
+/*! \fn template <class T> QList<T>::iterator &QList<T>::iterator::operator+=(difference_type j)
Advances the iterator by \a j items. (If \a j is negative, the
iterator goes backward.)
@@ -1670,7 +1670,7 @@ void **QListData::erase(void **xi)
\sa operator-=(), operator+()
*/
-/*! \fn QList::iterator &QList::iterator::operator-=(difference_type j)
+/*! \fn template <class T> QList<T>::iterator &QList<T>::iterator::operator-=(difference_type j)
Makes the iterator go back by \a j items. (If \a j is negative,
the iterator goes forward.)
@@ -1678,7 +1678,7 @@ void **QListData::erase(void **xi)
\sa operator+=(), operator-()
*/
-/*! \fn QList::iterator QList::iterator::operator+(difference_type j) const
+/*! \fn template <class T> QList<T>::iterator QList<T>::iterator::operator+(difference_type j) const
Returns an iterator to the item at \a j positions forward from
this iterator. (If \a j is negative, the iterator goes backward.)
@@ -1686,7 +1686,7 @@ void **QListData::erase(void **xi)
\sa operator-(), operator+=()
*/
-/*! \fn QList::iterator QList::iterator::operator-(difference_type j) const
+/*! \fn template <class T> QList<T>::iterator QList<T>::iterator::operator-(difference_type j) const
Returns an iterator to the item at \a j positions backward from
this iterator. (If \a j is negative, the iterator goes forward.)
@@ -1694,7 +1694,7 @@ void **QListData::erase(void **xi)
\sa operator+(), operator-=()
*/
-/*! \fn int QList::iterator::operator-(iterator other) const
+/*! \fn template <class T> int QList<T>::iterator::operator-(iterator other) const
Returns the number of items between the item pointed to by \a
other and the item pointed to by this iterator.
@@ -1750,7 +1750,7 @@ void **QListData::erase(void **xi)
\sa QList::iterator, QListIterator
*/
-/*! \fn QList::const_iterator::const_iterator()
+/*! \fn template <class T> QList<T>::const_iterator::const_iterator()
Constructs an uninitialized iterator.
@@ -1787,36 +1787,36 @@ void **QListData::erase(void **xi)
\internal
*/
-/*! \fn QList::const_iterator::const_iterator(Node *node)
+/*! \fn template <class T> QList<T>::const_iterator::const_iterator(Node *node)
\internal
*/
-/*! \fn QList::const_iterator::const_iterator(const const_iterator &other)
+/*! \fn template <class T> QList<T>::const_iterator::const_iterator(const const_iterator &other)
Constructs a copy of \a other.
*/
-/*! \fn QList::const_iterator::const_iterator(const iterator &other)
+/*! \fn template <class T> QList<T>::const_iterator::const_iterator(const iterator &other)
Constructs a copy of \a other.
*/
-/*! \fn const T &QList::const_iterator::operator*() const
+/*! \fn template <class T> const T &QList<T>::const_iterator::operator*() const
Returns the current item.
\sa operator->()
*/
-/*! \fn const T *QList::const_iterator::operator->() const
+/*! \fn template <class T> const T *QList<T>::const_iterator::operator->() const
Returns a pointer to the current item.
\sa operator*()
*/
-/*! \fn const T &QList::const_iterator::operator[](difference_type j) const
+/*! \fn template <class T> const T &QList<T>::const_iterator::operator[](difference_type j) const
Returns the item at position *this + \a{j}.
@@ -1826,7 +1826,7 @@ void **QListData::erase(void **xi)
\sa operator+()
*/
-/*! \fn bool QList::const_iterator::operator==(const const_iterator &other) const
+/*! \fn template <class T> bool QList<T>::const_iterator::operator==(const const_iterator &other) const
Returns \c true if \a other points to the same item as this
iterator; otherwise returns \c false.
@@ -1834,7 +1834,7 @@ void **QListData::erase(void **xi)
\sa operator!=()
*/
-/*! \fn bool QList::const_iterator::operator!=(const const_iterator &other) const
+/*! \fn template <class T> bool QList<T>::const_iterator::operator!=(const const_iterator &other) const
Returns \c true if \a other points to a different item than this
iterator; otherwise returns \c false.
@@ -1843,34 +1843,34 @@ void **QListData::erase(void **xi)
*/
/*!
- \fn bool QList::const_iterator::operator<(const const_iterator& other) const
+ \fn template <class T> bool QList<T>::const_iterator::operator<(const const_iterator& other) const
Returns \c true if the item pointed to by this iterator is less than
the item pointed to by the \a other iterator.
*/
/*!
- \fn bool QList::const_iterator::operator<=(const const_iterator& other) const
+ \fn template <class T> bool QList<T>::const_iterator::operator<=(const const_iterator& other) const
Returns \c true if the item pointed to by this iterator is less than
or equal to the item pointed to by the \a other iterator.
*/
/*!
- \fn bool QList::const_iterator::operator>(const const_iterator& other) const
+ \fn template <class T> bool QList<T>::const_iterator::operator>(const const_iterator& other) const
Returns \c true if the item pointed to by this iterator is greater
than the item pointed to by the \a other iterator.
*/
/*!
- \fn bool QList::const_iterator::operator>=(const const_iterator& other) const
+ \fn template <class T> bool QList<T>::const_iterator::operator>=(const const_iterator& other) const
Returns \c true if the item pointed to by this iterator is greater
than or equal to the item pointed to by the \a other iterator.
*/
-/*! \fn QList::const_iterator &QList::const_iterator::operator++()
+/*! \fn template <class T> QList<T>::const_iterator &QList<T>::const_iterator::operator++()
The prefix ++ operator (\c{++it}) advances the iterator to the
next item in the list and returns an iterator to the new current
@@ -1881,7 +1881,7 @@ void **QListData::erase(void **xi)
\sa operator--()
*/
-/*! \fn QList::const_iterator QList::const_iterator::operator++(int)
+/*! \fn template <class T> QList<T>::const_iterator QList<T>::const_iterator::operator++(int)
\overload
@@ -1890,7 +1890,7 @@ void **QListData::erase(void **xi)
current item.
*/
-/*! \fn QList::const_iterator &QList::const_iterator::operator--()
+/*! \fn template <class T> QList<T>::const_iterator &QList<T>::const_iterator::operator--()
The prefix -- operator (\c{--it}) makes the preceding item
current and returns an iterator to the new current item.
@@ -1900,7 +1900,7 @@ void **QListData::erase(void **xi)
\sa operator++()
*/
-/*! \fn QList::const_iterator QList::const_iterator::operator--(int)
+/*! \fn template <class T> QList<T>::const_iterator QList<T>::const_iterator::operator--(int)
\overload
@@ -1908,7 +1908,7 @@ void **QListData::erase(void **xi)
current and returns an iterator to the previously current item.
*/
-/*! \fn QList::const_iterator &QList::const_iterator::operator+=(difference_type j)
+/*! \fn template <class T> QList<T>::const_iterator &QList<T>::const_iterator::operator+=(difference_type j)
Advances the iterator by \a j items. (If \a j is negative, the
iterator goes backward.)
@@ -1916,7 +1916,7 @@ void **QListData::erase(void **xi)
\sa operator-=(), operator+()
*/
-/*! \fn QList::const_iterator &QList::const_iterator::operator-=(difference_type j)
+/*! \fn template <class T> QList<T>::const_iterator &QList<T>::const_iterator::operator-=(difference_type j)
Makes the iterator go back by \a j items. (If \a j is negative,
the iterator goes forward.)
@@ -1924,7 +1924,7 @@ void **QListData::erase(void **xi)
\sa operator+=(), operator-()
*/
-/*! \fn QList::const_iterator QList::const_iterator::operator+(difference_type j) const
+/*! \fn template <class T> QList<T>::const_iterator QList<T>::const_iterator::operator+(difference_type j) const
Returns an iterator to the item at \a j positions forward from
this iterator. (If \a j is negative, the iterator goes backward.)
@@ -1932,7 +1932,7 @@ void **QListData::erase(void **xi)
\sa operator-(), operator+=()
*/
-/*! \fn QList::const_iterator QList::const_iterator::operator-(difference_type j) const
+/*! \fn template <class T> QList<T>::const_iterator QList<T>::const_iterator::operator-(difference_type j) const
Returns an iterator to the item at \a j positions backward from
this iterator. (If \a j is negative, the iterator goes forward.)
@@ -1940,13 +1940,13 @@ void **QListData::erase(void **xi)
\sa operator+(), operator-=()
*/
-/*! \fn int QList::const_iterator::operator-(const_iterator other) const
+/*! \fn template <class T> int QList<T>::const_iterator::operator-(const_iterator other) const
Returns the number of items between the item pointed to by \a
other and the item pointed to by this iterator.
*/
-/*! \fn QDataStream &operator<<(QDataStream &out, const QList<T> &list)
+/*! \fn template <class T> QDataStream &operator<<(QDataStream &out, const QList<T> &list)
\relates QList
Writes the list \a list to stream \a out.
@@ -1957,7 +1957,7 @@ void **QListData::erase(void **xi)
\sa{Serializing Qt Data Types}{Format of the QDataStream operators}
*/
-/*! \fn QDataStream &operator>>(QDataStream &in, QList<T> &list)
+/*! \fn template <class T> QDataStream &operator>>(QDataStream &in, QList<T> &list)
\relates QList
Reads a list from stream \a in into \a list.
@@ -1968,7 +1968,7 @@ void **QListData::erase(void **xi)
\sa{Serializing Qt Data Types}{Format of the QDataStream operators}
*/
-/*! \fn QList<T> QList<T>::fromVector(const QVector<T> &vector)
+/*! \fn template <class T> QList<T> QList<T>::fromVector(const QVector<T> &vector)
Returns a QList object with the data contained in \a vector.
@@ -1979,7 +1979,7 @@ void **QListData::erase(void **xi)
\sa fromSet(), toVector(), QVector::toList()
*/
-/*! \fn QVector<T> QList<T>::toVector() const
+/*! \fn template <class T> QVector<T> QList<T>::toVector() const
Returns a QVector object with the data contained in this QList.
@@ -1990,7 +1990,7 @@ void **QListData::erase(void **xi)
\sa toSet(), fromVector(), QVector::fromList()
*/
-/*! \fn QList<T> QList<T>::fromSet(const QSet<T> &set)
+/*! \fn template <class T> QList<T> QList<T>::fromSet(const QSet<T> &set)
Returns a QList object with the data contained in \a set. The
order of the elements in the QList is undefined.
@@ -2002,7 +2002,7 @@ void **QListData::erase(void **xi)
\sa fromVector(), toSet(), QSet::toList()
*/
-/*! \fn QSet<T> QList<T>::toSet() const
+/*! \fn template <class T> QSet<T> QList<T>::toSet() const
Returns a QSet object with the data contained in this QList.
Since QSet doesn't allow duplicates, the resulting QSet might be
@@ -2015,7 +2015,7 @@ void **QListData::erase(void **xi)
\sa toVector(), fromSet(), QSet::fromList()
*/
-/*! \fn QList<T> QList<T>::fromStdList(const std::list<T> &list)
+/*! \fn template <class T> QList<T> QList<T>::fromStdList(const std::list<T> &list)
Returns a QList object with the data contained in \a list. The
order of the elements in the QList is the same as in \a list.
@@ -2027,7 +2027,7 @@ void **QListData::erase(void **xi)
\sa toStdList(), QVector::fromStdVector()
*/
-/*! \fn std::list<T> QList<T>::toStdList() const
+/*! \fn template <class T> std::list<T> QList<T>::toStdList() const
Returns a std::list object with the data contained in this QList.
Example:
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 a072ea411c..5598dfe237 100644
--- a/src/corelib/tools/qlocale.cpp
+++ b/src/corelib/tools/qlocale.cpp
@@ -64,6 +64,9 @@
#include "qstringbuilder.h"
#include "private/qnumeric_p.h"
#include <cmath>
+#ifndef QT_NO_SYSTEMLOCALE
+# include "qmutex.h"
+#endif
#ifdef Q_OS_WIN
# include <qt_windows.h>
# include <time.h>
@@ -107,31 +110,32 @@ QLocale::Language QLocalePrivate::codeToLanguage(QStringView code) Q_DECL_NOTHRO
return QLocale::Language((c - language_code_list)/3);
}
- // legacy codes
- if (uc1 == 'n' && uc2 == 'o' && uc3 == 0) { // no -> nb
- Q_STATIC_ASSERT(QLocale::Norwegian == QLocale::NorwegianBokmal);
- return QLocale::Norwegian;
- }
- if (uc1 == 't' && uc2 == 'l' && uc3 == 0) { // tl -> fil
- Q_STATIC_ASSERT(QLocale::Tagalog == QLocale::Filipino);
- return QLocale::Tagalog;
- }
- if (uc1 == 's' && uc2 == 'h' && uc3 == 0) { // sh -> sr[_Latn]
- Q_STATIC_ASSERT(QLocale::SerboCroatian == QLocale::Serbian);
- return QLocale::SerboCroatian;
- }
- if (uc1 == 'm' && uc2 == 'o' && uc3 == 0) { // mo -> ro
- Q_STATIC_ASSERT(QLocale::Moldavian == QLocale::Romanian);
- return QLocale::Moldavian;
+ if (uc3 == 0) {
+ // legacy codes
+ if (uc1 == 'n' && uc2 == 'o') { // no -> nb
+ Q_STATIC_ASSERT(QLocale::Norwegian == QLocale::NorwegianBokmal);
+ return QLocale::Norwegian;
+ }
+ if (uc1 == 't' && uc2 == 'l') { // tl -> fil
+ Q_STATIC_ASSERT(QLocale::Tagalog == QLocale::Filipino);
+ return QLocale::Tagalog;
+ }
+ if (uc1 == 's' && uc2 == 'h') { // sh -> sr[_Latn]
+ Q_STATIC_ASSERT(QLocale::SerboCroatian == QLocale::Serbian);
+ return QLocale::SerboCroatian;
+ }
+ if (uc1 == 'm' && uc2 == 'o') { // mo -> ro
+ Q_STATIC_ASSERT(QLocale::Moldavian == QLocale::Romanian);
+ return QLocale::Moldavian;
+ }
+ // Android uses the following deprecated codes
+ if (uc1 == 'i' && uc2 == 'w') // iw -> he
+ return QLocale::Hebrew;
+ if (uc1 == 'i' && uc2 == 'n') // in -> id
+ return QLocale::Indonesian;
+ if (uc1 == 'j' && uc2 == 'i') // ji -> yi
+ return QLocale::Yiddish;
}
- // Android uses the following deprecated codes
- if (uc1 == 'i' && uc2 == 'w' && uc3 == 0) // iw -> he
- return QLocale::Hebrew;
- if (uc1 == 'i' && uc2 == 'n' && uc3 == 0) // in -> id
- return QLocale::Indonesian;
- if (uc1 == 'j' && uc2 == 'i' && uc3 == 0) // ji -> yi
- return QLocale::Yiddish;
-
return QLocale::C;
}
@@ -593,8 +597,6 @@ static QLocalePrivate *c_private()
}
#ifndef QT_NO_SYSTEMLOCALE
-
-
/******************************************************************************
** Default system locale behavior
*/
@@ -683,14 +685,24 @@ void QLocalePrivate::updateSystemPrivate()
if (!res.isNull())
system_data->m_plus = res.toString().at(0).unicode();
}
-#endif
+#endif // !QT_NO_SYSTEMLOCALE
static const QLocaleData *systemData()
{
#ifndef QT_NO_SYSTEMLOCALE
- // copy over the information from the fallback locale and modify
- if (!system_data || system_data->m_language_id == 0)
- QLocalePrivate::updateSystemPrivate();
+ /*
+ Copy over the information from the fallback locale and modify.
+
+ This modifies (cross-thread) global state, so take care to only call it in
+ one thread.
+ */
+ {
+ static QBasicMutex systemDataMutex;
+ systemDataMutex.lock();
+ if (!system_data || system_data->m_language_id == 0)
+ QLocalePrivate::updateSystemPrivate();
+ systemDataMutex.unlock();
+ }
return system_data;
#else
@@ -3151,11 +3163,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.cpp b/src/corelib/tools/qmap.cpp
index afdd30e5c8..5a20c581e9 100644
--- a/src/corelib/tools/qmap.cpp
+++ b/src/corelib/tools/qmap.cpp
@@ -509,7 +509,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa QMapIterator, QMutableMapIterator, QHash, QSet
*/
-/*! \fn QMap::QMap()
+/*! \fn template <class Key, class T> QMap<Key, T>::QMap()
Constructs an empty map.
@@ -517,7 +517,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
*/
/*!
- \fn QMap::QMap(QMap<Key, T> &&other)
+ \fn template <class Key, class T> QMap<Key, T>::QMap(QMap<Key, T> &&other)
Move-constructs a QMap instance, making it point at the same
object that \a other was pointing to.
@@ -525,7 +525,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\since 5.2
*/
-/*! \fn QMap::QMap(const QMap<Key, T> &other)
+/*! \fn template <class Key, class T> QMap<Key, T>::QMap(const QMap<Key, T> &other)
Constructs a copy of \a other.
@@ -537,14 +537,14 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa operator=()
*/
-/*! \fn QMap::QMap(const std::map<Key, T> & other)
+/*! \fn template <class Key, class T> QMap<Key, T>::QMap(const std::map<Key, T> & other)
Constructs a copy of \a other.
\sa toStdMap()
*/
-/*! \fn QMap::QMap(std::initializer_list<std::pair<Key,T> > list)
+/*! \fn template <class Key, class T> QMap<Key, T>::QMap(std::initializer_list<std::pair<Key,T> > list)
\since 5.1
Constructs a map with a copy of each of the elements in the
@@ -554,45 +554,45 @@ void QMapDataBase::freeData(QMapDataBase *d)
compiled in C++11 mode.
*/
-/*! \fn std::map<Key, T> QMap::toStdMap() const
+/*! \fn template <class Key, class T> std::map<Key, T> QMap<Key, T>::toStdMap() const
Returns an STL map equivalent to this QMap.
*/
-/*! \fn QMap::~QMap()
+/*! \fn template <class Key, class T> QMap<Key, T>::~QMap()
Destroys the map. References to the values in the map, and all
iterators over this map, become invalid.
*/
-/*! \fn QMap<Key, T> &QMap::operator=(const QMap<Key, T> &other)
+/*! \fn template <class Key, class T> QMap<Key, T> &QMap<Key, T>::operator=(const QMap<Key, T> &other)
Assigns \a other to this map and returns a reference to this map.
*/
/*!
- \fn QMap<Key, T> &QMap::operator=(QMap<Key, T> &&other)
+ \fn template <class Key, class T> QMap<Key, T> &QMap<Key, T>::operator=(QMap<Key, T> &&other)
Move-assigns \a other to this QMap instance.
\since 5.2
*/
-/*! \fn void QMap::swap(QMap<Key, T> &other)
+/*! \fn template <class Key, class T> void QMap<Key, T>::swap(QMap<Key, T> &other)
\since 4.8
Swaps map \a other with this map. This operation is very
fast and never fails.
*/
-/*! \fn void QMultiMap::swap(QMultiMap<Key, T> &other)
+/*! \fn template <class Key, class T> void QMultiMap<Key, T>::swap(QMultiMap<Key, T> &other)
\since 4.8
Swaps map \a other with this map. This operation is very
fast and never fails.
*/
-/*! \fn bool QMap::operator==(const QMap<Key, T> &other) const
+/*! \fn template <class Key, class T> bool QMap<Key, T>::operator==(const QMap<Key, T> &other) const
Returns \c true if \a other is equal to this map; otherwise returns
false.
@@ -606,7 +606,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa operator!=()
*/
-/*! \fn bool QMap::operator!=(const QMap<Key, T> &other) const
+/*! \fn template <class Key, class T> bool QMap<Key, T>::operator!=(const QMap<Key, T> &other) const
Returns \c true if \a other is not equal to this map; otherwise
returns \c false.
@@ -620,7 +620,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa operator==()
*/
-/*! \fn int QMap::size() const
+/*! \fn template <class Key, class T> int QMap<Key, T>::size() const
Returns the number of (key, value) pairs in the map.
@@ -628,7 +628,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
*/
/*!
- \fn bool QMap::isEmpty() const
+ \fn template <class Key, class T> bool QMap<Key, T>::isEmpty() const
Returns \c true if the map contains no items; otherwise returns
false.
@@ -636,7 +636,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa size()
*/
-/*! \fn void QMap::detach()
+/*! \fn template <class Key, class T> void QMap<Key, T>::detach()
\internal
@@ -646,7 +646,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa isDetached()
*/
-/*! \fn bool QMap::isDetached() const
+/*! \fn template <class Key, class T> bool QMap<Key, T>::isDetached() const
\internal
@@ -656,24 +656,24 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa detach()
*/
-/*! \fn void QMap::setSharable(bool sharable)
+/*! \fn template <class Key, class T> void QMap<Key, T>::setSharable(bool sharable)
\internal
*/
-/*! \fn bool QMap::isSharedWith(const QMap<Key, T> &other) const
+/*! \fn template <class Key, class T> bool QMap<Key, T>::isSharedWith(const QMap<Key, T> &other) const
\internal
*/
-/*! \fn void QMap::clear()
+/*! \fn template <class Key, class T> void QMap<Key, T>::clear()
Removes all items from the map.
\sa remove()
*/
-/*! \fn int QMap::remove(const Key &key)
+/*! \fn template <class Key, class T> int QMap<Key, T>::remove(const Key &key)
Removes all the items that have the key \a key from the map.
Returns the number of items removed which is usually 1 but will be
@@ -683,7 +683,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa clear(), take(), QMultiMap::remove()
*/
-/*! \fn T QMap::take(const Key &key)
+/*! \fn template <class Key, class T> T QMap<Key, T>::take(const Key &key)
Removes the item with the key \a key from the map and returns
the value associated with it.
@@ -698,7 +698,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa remove()
*/
-/*! \fn bool QMap::contains(const Key &key) const
+/*! \fn template <class Key, class T> bool QMap<Key, T>::contains(const Key &key) const
Returns \c true if the map contains an item with key \a key;
otherwise returns \c false.
@@ -706,7 +706,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa count(), QMultiMap::contains()
*/
-/*! \fn const T QMap::value(const Key &key, const T &defaultValue) const
+/*! \fn template <class Key, class T> const T QMap<Key, T>::value(const Key &key, const T &defaultValue) const
Returns the value associated with the key \a key.
@@ -719,7 +719,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa key(), values(), contains(), operator[]()
*/
-/*! \fn T &QMap::operator[](const Key &key)
+/*! \fn template <class Key, class T> T &QMap<Key, T>::operator[](const Key &key)
Returns the value associated with the key \a key as a modifiable
reference.
@@ -733,14 +733,14 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa insert(), value()
*/
-/*! \fn const T QMap::operator[](const Key &key) const
+/*! \fn template <class Key, class T> const T QMap<Key, T>::operator[](const Key &key) const
\overload
Same as value().
*/
-/*! \fn QList<Key> QMap::uniqueKeys() const
+/*! \fn template <class Key, class T> QList<Key> QMap<Key, T>::uniqueKeys() const
\since 4.2
Returns a list containing all the keys in the map in ascending
@@ -751,7 +751,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa keys(), values()
*/
-/*! \fn QList<Key> QMap::keys() const
+/*! \fn template <class Key, class T> QList<Key> QMap<Key, T>::keys() const
Returns a list containing all the keys in the map in ascending
order. Keys that occur multiple times in the map (because items
@@ -766,7 +766,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa uniqueKeys(), values(), key()
*/
-/*! \fn QList<Key> QMap::keys(const T &value) const
+/*! \fn template <class Key, class T> QList<Key> QMap<Key, T>::keys(const T &value) const
\overload
@@ -779,7 +779,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
*/
/*!
- \fn Key QMap::key(const T &value, const Key &defaultKey) const
+ \fn template <class Key, class T> Key QMap<Key, T>::key(const T &value, const Key &defaultKey) const
\since 4.3
\overload
@@ -795,7 +795,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa value(), keys()
*/
-/*! \fn QList<T> QMap::values() const
+/*! \fn template <class Key, class T> QList<T> QMap<Key, T>::values() const
Returns a list containing all the values in the map, in ascending
order of their keys. If a key is associated with multiple values,
@@ -805,7 +805,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa keys(), value()
*/
-/*! \fn QList<T> QMap::values(const Key &key) const
+/*! \fn template <class Key, class T> QList<T> QMap<Key, T>::values(const Key &key) const
\overload
@@ -816,21 +816,21 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa count(), insertMulti()
*/
-/*! \fn int QMap::count(const Key &key) const
+/*! \fn template <class Key, class T> int QMap<Key, T>::count(const Key &key) const
Returns the number of items associated with key \a key.
\sa contains(), insertMulti(), QMultiMap::count()
*/
-/*! \fn int QMap::count() const
+/*! \fn template <class Key, class T> int QMap<Key, T>::count() const
\overload
Same as size().
*/
-/*! \fn QMap::iterator QMap::begin()
+/*! \fn template <class Key, class T> QMap<Key, T>::iterator QMap<Key, T>::begin()
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the first item in
the map.
@@ -838,12 +838,12 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa constBegin(), end()
*/
-/*! \fn QMap::const_iterator QMap::begin() const
+/*! \fn template <class Key, class T> QMap<Key, T>::const_iterator QMap<Key, T>::begin() const
\overload
*/
-/*! \fn QMap::const_iterator QMap::cbegin() const
+/*! \fn template <class Key, class T> QMap<Key, T>::const_iterator QMap<Key, T>::cbegin() const
\since 5.0
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first item
@@ -852,7 +852,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa begin(), cend()
*/
-/*! \fn QMap::const_iterator QMap::constBegin() const
+/*! \fn template <class Key, class T> QMap<Key, T>::const_iterator QMap<Key, T>::constBegin() const
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first item
in the map.
@@ -860,7 +860,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa begin(), constEnd()
*/
-/*! \fn QMap::key_iterator QMap::keyBegin() const
+/*! \fn template <class Key, class T> QMap<Key, T>::key_iterator QMap<Key, T>::keyBegin() const
\since 5.6
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first key
@@ -869,7 +869,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa keyEnd(), firstKey()
*/
-/*! \fn QMap::iterator QMap::end()
+/*! \fn template <class Key, class T> QMap<Key, T>::iterator QMap<Key, T>::end()
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item
after the last item in the map.
@@ -877,12 +877,12 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa begin(), constEnd()
*/
-/*! \fn QMap::const_iterator QMap::end() const
+/*! \fn template <class Key, class T> QMap<Key, T>::const_iterator QMap<Key, T>::end() const
\overload
*/
-/*! \fn QMap::const_iterator QMap::cend() const
+/*! \fn template <class Key, class T> QMap<Key, T>::const_iterator QMap<Key, T>::cend() const
\since 5.0
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary
@@ -891,7 +891,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa cbegin(), end()
*/
-/*! \fn QMap::const_iterator QMap::constEnd() const
+/*! \fn template <class Key, class T> QMap<Key, T>::const_iterator QMap<Key, T>::constEnd() const
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary
item after the last item in the map.
@@ -899,7 +899,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa constBegin(), end()
*/
-/*! \fn QMap::key_iterator QMap::keyEnd() const
+/*! \fn template <class Key, class T> QMap<Key, T>::key_iterator QMap<Key, T>::keyEnd() const
\since 5.6
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary
@@ -909,7 +909,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
*/
-/*! \fn QMap::key_value_iterator QMap::keyValueBegin()
+/*! \fn template <class Key, class T> QMap<Key, T>::key_value_iterator QMap<Key, T>::keyValueBegin()
\since 5.10
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the first entry
@@ -918,7 +918,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa keyValueEnd()
*/
-/*! \fn QMap::key_value_iterator QMap::keyValueEnd()
+/*! \fn template <class Key, class T> QMap<Key, T>::key_value_iterator QMap<Key, T>::keyValueEnd()
\since 5.10
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the imaginary
@@ -927,7 +927,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa keyValueBegin()
*/
-/*! \fn QMap::const_key_value_iterator QMap::keyValueBegin() const
+/*! \fn template <class Key, class T> QMap<Key, T>::const_key_value_iterator QMap<Key, T>::keyValueBegin() const
\since 5.10
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first entry
@@ -936,7 +936,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa keyValueEnd()
*/
-/*! \fn QMap::const_key_value_iterator QMap::constKeyValueBegin() const
+/*! \fn template <class Key, class T> QMap<Key, T>::const_key_value_iterator QMap<Key, T>::constKeyValueBegin() const
\since 5.10
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first entry
@@ -945,7 +945,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa keyValueBegin()
*/
-/*! \fn QMap::const_key_value_iterator QMap::keyValueEnd() const
+/*! \fn template <class Key, class T> QMap<Key, T>::const_key_value_iterator QMap<Key, T>::keyValueEnd() const
\since 5.10
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary
@@ -954,7 +954,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa keyValueBegin()
*/
-/*! \fn QMap::const_key_value_iterator QMap::constKeyValueEnd() const
+/*! \fn template <class Key, class T> QMap<Key, T>::const_key_value_iterator QMap<Key, T>::constKeyValueEnd() const
\since 5.10
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary
@@ -963,7 +963,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa constKeyValueBegin()
*/
-/*! \fn const Key &QMap::firstKey() const
+/*! \fn template <class Key, class T> const Key &QMap<Key, T>::firstKey() const
\since 5.2
Returns a reference to the smallest key in the map.
@@ -974,7 +974,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa lastKey(), first(), keyBegin(), isEmpty()
*/
-/*! \fn const Key &QMap::lastKey() const
+/*! \fn template <class Key, class T> const Key &QMap<Key, T>::lastKey() const
\since 5.2
Returns a reference to the largest key in the map.
@@ -985,7 +985,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa firstKey(), last(), keyEnd(), isEmpty()
*/
-/*! \fn T &QMap::first()
+/*! \fn template <class Key, class T> T &QMap<Key, T>::first()
\since 5.2
Returns a reference to the first value in the map, that is the value mapped
@@ -996,13 +996,13 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa last(), firstKey(), isEmpty()
*/
-/*! \fn const T &QMap::first() const
+/*! \fn template <class Key, class T> const T &QMap<Key, T>::first() const
\since 5.2
\overload
*/
-/*! \fn T &QMap::last()
+/*! \fn template <class Key, class T> T &QMap<Key, T>::last()
\since 5.2
Returns a reference to the last value in the map, that is the value mapped
@@ -1013,13 +1013,13 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa first(), lastKey(), isEmpty()
*/
-/*! \fn const T &QMap::last() const
+/*! \fn template <class Key, class T> const T &QMap<Key, T>::last() const
\since 5.2
\overload
*/
-/*! \fn QMap::iterator QMap::erase(iterator pos)
+/*! \fn template <class Key, class T> QMap<Key, T>::iterator QMap<Key, T>::erase(iterator pos)
Removes the (key, value) pair pointed to by the iterator \a pos
from the map, and returns an iterator to the next item in the
@@ -1028,7 +1028,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa remove()
*/
-/*! \fn QMap::iterator QMap::find(const Key &key)
+/*! \fn template <class Key, class T> QMap<Key, T>::iterator QMap<Key, T>::find(const Key &key)
Returns an iterator pointing to the item with key \a key in the
map.
@@ -1047,12 +1047,12 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa constFind(), value(), values(), lowerBound(), upperBound(), QMultiMap::find()
*/
-/*! \fn QMap::const_iterator QMap::find(const Key &key) const
+/*! \fn template <class Key, class T> QMap<Key, T>::const_iterator QMap<Key, T>::find(const Key &key) const
\overload
*/
-/*! \fn QMap::const_iterator QMap::constFind(const Key &key) const
+/*! \fn template <class Key, class T> QMap<Key, T>::const_iterator QMap<Key, T>::constFind(const Key &key) const
\since 4.1
Returns an const iterator pointing to the item with key \a key in the
@@ -1064,7 +1064,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa find(), QMultiMap::constFind()
*/
-/*! \fn QMap::iterator QMap::lowerBound(const Key &key)
+/*! \fn template <class Key, class T> QMap<Key, T>::iterator QMap<Key, T>::lowerBound(const Key &key)
Returns an iterator pointing to the first item with key \a key in
the map. If the map contains no item with key \a key, the
@@ -1085,12 +1085,12 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa upperBound(), find()
*/
-/*! \fn QMap::const_iterator QMap::lowerBound(const Key &key) const
+/*! \fn template <class Key, class T> QMap<Key, T>::const_iterator QMap<Key, T>::lowerBound(const Key &key) const
\overload
*/
-/*! \fn QMap::iterator QMap::upperBound(const Key &key)
+/*! \fn template <class Key, class T> QMap<Key, T>::iterator QMap<Key, T>::upperBound(const Key &key)
Returns an iterator pointing to the item that immediately follows
the last item with key \a key in the map. If the map contains no
@@ -1103,12 +1103,12 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa lowerBound(), find()
*/
-/*! \fn QMap::const_iterator QMap::upperBound(const Key &key) const
+/*! \fn template <class Key, class T> QMap<Key, T>::const_iterator QMap<Key, T>::upperBound(const Key &key) const
\overload
*/
-/*! \fn QMap::iterator QMap::insert(const Key &key, const T &value)
+/*! \fn template <class Key, class T> QMap<Key, T>::iterator QMap<Key, T>::insert(const Key &key, const T &value)
Inserts a new item with the key \a key and a value of \a value.
@@ -1121,7 +1121,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa insertMulti()
*/
-/*! \fn QMap::iterator QMap::insert(const_iterator pos, const Key &key, const T &value)
+/*! \fn template <class Key, class T> QMap<Key, T>::iterator QMap<Key, T>::insert(const_iterator pos, const Key &key, const T &value)
\overload
\since 5.1
Inserts a new item with the key \a key and value \a value and with hint \a pos
@@ -1150,7 +1150,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa insertMulti()
*/
-/*! \fn QMap::iterator QMap::insertMulti(const Key &key, const T &value)
+/*! \fn template <class Key, class T> QMap<Key, T>::iterator QMap<Key, T>::insertMulti(const Key &key, const T &value)
Inserts a new item with the key \a key and a value of \a value.
@@ -1162,7 +1162,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa insert(), values()
*/
-/*! \fn QMap::iterator QMap::insertMulti(const_iterator pos, const Key &key, const T &value)
+/*! \fn template <class Key, class T> QMap<Key, T>::iterator QMap<Key, T>::insertMulti(const_iterator pos, const Key &key, const T &value)
\overload
\since 5.1
Inserts a new item with the key \a key and value \a value and with hint \a pos
@@ -1182,7 +1182,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
*/
-/*! \fn QMap<Key, T> &QMap::unite(const QMap<Key, T> &other)
+/*! \fn template <class Key, class T> QMap<Key, T> &QMap<Key, T>::unite(const QMap<Key, T> &other)
Inserts all the items in the \a other map into this map. If a
key is common to both maps, the resulting map will contain the
@@ -1193,12 +1193,12 @@ void QMapDataBase::freeData(QMapDataBase *d)
/*! \typedef QMap::Iterator
- Qt-style synonym for QMap::iterator.
+ Qt-style synonym for QMap<Key, T>::iterator.
*/
/*! \typedef QMap::ConstIterator
- Qt-style synonym for QMap::const_iterator.
+ Qt-style synonym for QMap<Key, T>::const_iterator.
*/
/*! \typedef QMap::difference_type
@@ -1222,7 +1222,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
*/
/*!
- \fn bool QMap::empty() const
+ \fn template <class Key, class T> bool QMap<Key, T>::empty() const
This function is provided for STL compatibility. It is equivalent
to isEmpty(), returning true if the map is empty; otherwise
@@ -1230,14 +1230,14 @@ void QMapDataBase::freeData(QMapDataBase *d)
*/
/*!
- \fn QPair<iterator, iterator> QMap::equal_range(const Key &key)
+ \fn template <class Key, class T> QPair<iterator, iterator> QMap<Key, T>::equal_range(const Key &key)
Returns a pair of iterators delimiting the range of values \c{[first, second)}, that
are stored under \a key.
*/
/*!
- \fn QPair<const_iterator, const_iterator> QMap::equal_range(const Key &key) const
+ \fn template <class Key, class T> QPair<const_iterator, const_iterator> QMap<Key, T>::equal_range(const Key &key) const
\overload
\since 5.6
*/
@@ -1339,7 +1339,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\internal
*/
-/*! \fn QMap::iterator::iterator()
+/*! \fn template <class Key, class T> QMap<Key, T>::iterator::iterator()
Constructs an uninitialized iterator.
@@ -1350,12 +1350,12 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa QMap::begin(), QMap::end()
*/
-/*! \fn QMap::iterator::iterator(Node *)
+/*! \fn template <class Key, class T> QMap<Key, T>::iterator::iterator(Node *)
\internal
*/
-/*! \fn const Key &QMap::iterator::key() const
+/*! \fn template <class Key, class T> const Key &QMap<Key, T>::iterator::key() const
Returns the current item's key as a const reference.
@@ -1366,7 +1366,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa value()
*/
-/*! \fn T &QMap::iterator::value() const
+/*! \fn template <class Key, class T> T &QMap<Key, T>::iterator::value() const
Returns a modifiable reference to the current item's value.
@@ -1378,7 +1378,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa key(), operator*()
*/
-/*! \fn T &QMap::iterator::operator*() const
+/*! \fn template <class Key, class T> T &QMap<Key, T>::iterator::operator*() const
Returns a modifiable reference to the current item's value.
@@ -1387,7 +1387,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa key()
*/
-/*! \fn T *QMap::iterator::operator->() const
+/*! \fn template <class Key, class T> T *QMap<Key, T>::iterator::operator->() const
Returns a pointer to the current item's value.
@@ -1395,8 +1395,8 @@ void QMapDataBase::freeData(QMapDataBase *d)
*/
/*!
- \fn bool QMap::iterator::operator==(const iterator &other) const
- \fn bool QMap::iterator::operator==(const const_iterator &other) const
+ \fn template <class Key, class T> bool QMap<Key, T>::iterator::operator==(const iterator &other) const
+ \fn template <class Key, class T> bool QMap<Key, T>::iterator::operator==(const const_iterator &other) const
Returns \c true if \a other points to the same item as this
iterator; otherwise returns \c false.
@@ -1405,8 +1405,8 @@ void QMapDataBase::freeData(QMapDataBase *d)
*/
/*!
- \fn bool QMap::iterator::operator!=(const iterator &other) const
- \fn bool QMap::iterator::operator!=(const const_iterator &other) const
+ \fn template <class Key, class T> bool QMap<Key, T>::iterator::operator!=(const iterator &other) const
+ \fn template <class Key, class T> bool QMap<Key, T>::iterator::operator!=(const const_iterator &other) const
Returns \c true if \a other points to a different item than this
iterator; otherwise returns \c false.
@@ -1414,7 +1414,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa operator==()
*/
-/*! \fn QMap::iterator QMap::iterator::operator++()
+/*! \fn template <class Key, class T> QMap<Key, T>::iterator QMap<Key, T>::iterator::operator++()
The prefix ++ operator (\c{++i}) advances the iterator to the
next item in the map and returns an iterator to the new current
@@ -1425,7 +1425,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa operator--()
*/
-/*! \fn QMap::iterator QMap::iterator::operator++(int)
+/*! \fn template <class Key, class T> QMap<Key, T>::iterator QMap<Key, T>::iterator::operator++(int)
\overload
@@ -1434,7 +1434,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
current item.
*/
-/*! \fn QMap::iterator QMap::iterator::operator--()
+/*! \fn template <class Key, class T> QMap<Key, T>::iterator QMap<Key, T>::iterator::operator--()
The prefix -- operator (\c{--i}) makes the preceding item
current and returns an iterator pointing to the new current item.
@@ -1445,7 +1445,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa operator++()
*/
-/*! \fn QMap::iterator QMap::iterator::operator--(int)
+/*! \fn template <class Key, class T> QMap<Key, T>::iterator QMap<Key, T>::iterator::operator--(int)
\overload
@@ -1454,7 +1454,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
current item.
*/
-/*! \fn QMap::iterator QMap::iterator::operator+(int j) const
+/*! \fn template <class Key, class T> QMap<Key, T>::iterator QMap<Key, T>::iterator::operator+(int j) const
Returns an iterator to the item at \a j positions forward from
this iterator. (If \a j is negative, the iterator goes backward.)
@@ -1465,7 +1465,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
*/
-/*! \fn QMap::iterator QMap::iterator::operator-(int j) const
+/*! \fn template <class Key, class T> QMap<Key, T>::iterator QMap<Key, T>::iterator::operator-(int j) const
Returns an iterator to the item at \a j positions backward from
this iterator. (If \a j is negative, the iterator goes forward.)
@@ -1475,7 +1475,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa operator+()
*/
-/*! \fn QMap::iterator &QMap::iterator::operator+=(int j)
+/*! \fn template <class Key, class T> QMap<Key, T>::iterator &QMap<Key, T>::iterator::operator+=(int j)
Advances the iterator by \a j items. (If \a j is negative, the
iterator goes backward.)
@@ -1483,7 +1483,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa operator-=(), operator+()
*/
-/*! \fn QMap::iterator &QMap::iterator::operator-=(int j)
+/*! \fn template <class Key, class T> QMap<Key, T>::iterator &QMap<Key, T>::iterator::operator-=(int j)
Makes the iterator go back by \a j items. (If \a j is negative,
the iterator goes forward.)
@@ -1562,7 +1562,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\internal
*/
-/*! \fn QMap::const_iterator::const_iterator()
+/*! \fn template <class Key, class T> QMap<Key, T>::const_iterator::const_iterator()
Constructs an uninitialized iterator.
@@ -1573,31 +1573,31 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa QMap::constBegin(), QMap::constEnd()
*/
-/*! \fn QMap::const_iterator::const_iterator(const Node *)
+/*! \fn template <class Key, class T> QMap<Key, T>::const_iterator::const_iterator(const Node *)
\internal
*/
-/*! \fn QMap::const_iterator::const_iterator(const iterator &other)
+/*! \fn template <class Key, class T> QMap<Key, T>::const_iterator::const_iterator(const iterator &other)
Constructs a copy of \a other.
*/
-/*! \fn const Key &QMap::const_iterator::key() const
+/*! \fn template <class Key, class T> const Key &QMap<Key, T>::const_iterator::key() const
Returns the current item's key.
\sa value()
*/
-/*! \fn const T &QMap::const_iterator::value() const
+/*! \fn template <class Key, class T> const T &QMap<Key, T>::const_iterator::value() const
Returns the current item's value.
\sa key(), operator*()
*/
-/*! \fn const T &QMap::const_iterator::operator*() const
+/*! \fn template <class Key, class T> const T &QMap<Key, T>::const_iterator::operator*() const
Returns the current item's value.
@@ -1606,14 +1606,14 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa key()
*/
-/*! \fn const T *QMap::const_iterator::operator->() const
+/*! \fn template <class Key, class T> const T *QMap<Key, T>::const_iterator::operator->() const
Returns a pointer to the current item's value.
\sa value()
*/
-/*! \fn bool QMap::const_iterator::operator==(const const_iterator &other) const
+/*! \fn template <class Key, class T> bool QMap<Key, T>::const_iterator::operator==(const const_iterator &other) const
Returns \c true if \a other points to the same item as this
iterator; otherwise returns \c false.
@@ -1621,7 +1621,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa operator!=()
*/
-/*! \fn bool QMap::const_iterator::operator!=(const const_iterator &other) const
+/*! \fn template <class Key, class T> bool QMap<Key, T>::const_iterator::operator!=(const const_iterator &other) const
Returns \c true if \a other points to a different item than this
iterator; otherwise returns \c false.
@@ -1629,7 +1629,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa operator==()
*/
-/*! \fn QMap::const_iterator QMap::const_iterator::operator++()
+/*! \fn template <class Key, class T> QMap<Key, T>::const_iterator QMap<Key, T>::const_iterator::operator++()
The prefix ++ operator (\c{++i}) advances the iterator to the
next item in the map and returns an iterator to the new current
@@ -1640,7 +1640,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa operator--()
*/
-/*! \fn QMap::const_iterator QMap::const_iterator::operator++(int)
+/*! \fn template <class Key, class T> QMap<Key, T>::const_iterator QMap<Key, T>::const_iterator::operator++(int)
\overload
@@ -1649,7 +1649,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
current item.
*/
-/*! \fn QMap::const_iterator &QMap::const_iterator::operator--()
+/*! \fn template <class Key, class T> QMap<Key, T>::const_iterator &QMap<Key, T>::const_iterator::operator--()
The prefix -- operator (\c{--i}) makes the preceding item
current and returns an iterator pointing to the new current item.
@@ -1660,7 +1660,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa operator++()
*/
-/*! \fn QMap::const_iterator QMap::const_iterator::operator--(int)
+/*! \fn template <class Key, class T> QMap<Key, T>::const_iterator QMap<Key, T>::const_iterator::operator--(int)
\overload
@@ -1669,7 +1669,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
current item.
*/
-/*! \fn QMap::const_iterator QMap::const_iterator::operator+(int j) const
+/*! \fn template <class Key, class T> QMap<Key, T>::const_iterator QMap<Key, T>::const_iterator::operator+(int j) const
Returns an iterator to the item at \a j positions forward from
this iterator. (If \a j is negative, the iterator goes backward.)
@@ -1679,7 +1679,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa operator-()
*/
-/*! \fn QMap::const_iterator QMap::const_iterator::operator-(int j) const
+/*! \fn template <class Key, class T> QMap<Key, T>::const_iterator QMap<Key, T>::const_iterator::operator-(int j) const
Returns an iterator to the item at \a j positions backward from
this iterator. (If \a j is negative, the iterator goes forward.)
@@ -1689,7 +1689,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa operator+()
*/
-/*! \fn QMap::const_iterator &QMap::const_iterator::operator+=(int j)
+/*! \fn template <class Key, class T> QMap<Key, T>::const_iterator &QMap<Key, T>::const_iterator::operator+=(int j)
Advances the iterator by \a j items. (If \a j is negative, the
iterator goes backward.)
@@ -1699,7 +1699,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa operator-=(), operator+()
*/
-/*! \fn QMap::const_iterator &QMap::const_iterator::operator-=(int j)
+/*! \fn template <class Key, class T> QMap<Key, T>::const_iterator &QMap<Key, T>::const_iterator::operator-=(int j)
Makes the iterator go back by \a j items. (If \a j is negative,
the iterator goes forward.)
@@ -1766,17 +1766,17 @@ void QMapDataBase::freeData(QMapDataBase *d)
\internal
*/
-/*! \fn const T &QMap::key_iterator::operator*() const
+/*! \fn template <class Key, class T> const T &QMap<Key, T>::key_iterator::operator*() const
Returns the current item's key.
*/
-/*! \fn const T *QMap::key_iterator::operator->() const
+/*! \fn template <class Key, class T> const T *QMap<Key, T>::key_iterator::operator->() const
Returns a pointer to the current item's key.
*/
-/*! \fn bool QMap::key_iterator::operator==(key_iterator other) const
+/*! \fn template <class Key, class T> bool QMap<Key, T>::key_iterator::operator==(key_iterator other) const
Returns \c true if \a other points to the same item as this
iterator; otherwise returns \c false.
@@ -1784,7 +1784,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa operator!=()
*/
-/*! \fn bool QMap::key_iterator::operator!=(key_iterator other) const
+/*! \fn template <class Key, class T> bool QMap<Key, T>::key_iterator::operator!=(key_iterator other) const
Returns \c true if \a other points to a different item than this
iterator; otherwise returns \c false.
@@ -1793,7 +1793,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
*/
/*!
- \fn QMap::key_iterator &QMap::key_iterator::operator++()
+ \fn template <class Key, class T> QMap<Key, T>::key_iterator &QMap<Key, T>::key_iterator::operator++()
The prefix ++ operator (\c{++i}) advances the iterator to the
next item in the hash and returns an iterator to the new current
@@ -1804,7 +1804,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa operator--()
*/
-/*! \fn QMap::key_iterator QMap::key_iterator::operator++(int)
+/*! \fn template <class Key, class T> QMap<Key, T>::key_iterator QMap<Key, T>::key_iterator::operator++(int)
\overload
@@ -1813,7 +1813,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
item.
*/
-/*! \fn QMap::key_iterator &QMap::key_iterator::operator--()
+/*! \fn template <class Key, class T> QMap<Key, T>::key_iterator &QMap<Key, T>::key_iterator::operator--()
The prefix -- operator (\c{--i}) makes the preceding item
current and returns an iterator pointing to the new current item.
@@ -1824,7 +1824,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa operator++()
*/
-/*! \fn QMap::key_iterator QMap::key_iterator::operator--(int)
+/*! \fn template <class Key, class T> QMap<Key, T>::key_iterator QMap<Key, T>::key_iterator::operator--(int)
\overload
@@ -1833,10 +1833,22 @@ void QMapDataBase::freeData(QMapDataBase *d)
item.
*/
-/*! \fn const_iterator QMap::key_iterator::base() const
+/*! \fn template <class Key, class T> const_iterator QMap<Key, T>::key_iterator::base() const
Returns the underlying const_iterator this key_iterator is based on.
*/
+/*! \typedef QMap::const_key_value_iterator
+ \inmodule QtCore
+ \since 5.10
+ \brief The QMap::const_key_value_iterator typedef provides an STL-style iterator for QMap and QMultiMap.
+
+ QMap::const_key_value_iterator is essentially the same as QMap::const_iterator
+ with the difference that operator*() returns a key/value pair instead of a
+ value.
+
+ \sa QKeyValueIterator
+*/
+
/*! \typedef QMap::key_value_iterator
\inmodule QtCore
\since 5.10
@@ -1849,7 +1861,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa QKeyValueIterator
*/
-/*! \fn QDataStream &operator<<(QDataStream &out, const QMap<Key, T> &map)
+/*! \fn template <class Key, class T> QDataStream &operator<<(QDataStream &out, const QMap<Key, T> &map)
\relates QMap
Writes the map \a map to stream \a out.
@@ -1860,7 +1872,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa{Serializing Qt Data Types}{Format of the QDataStream operators}
*/
-/*! \fn QDataStream &operator>>(QDataStream &in, QMap<Key, T> &map)
+/*! \fn template <class Key, class T> QDataStream &operator>>(QDataStream &in, QMap<Key, T> &map)
\relates QMap
Reads a map from stream \a in into \a map.
@@ -1926,12 +1938,12 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa QMap, QMapIterator, QMutableMapIterator, QMultiHash
*/
-/*! \fn QMultiMap::QMultiMap()
+/*! \fn template <class Key, class T> QMultiMap<Key, T>::QMultiMap()
Constructs an empty map.
*/
-/*! \fn QMultiMap::QMultiMap(std::initializer_list<std::pair<Key,T> > list)
+/*! \fn template <class Key, class T> QMultiMap<Key, T>::QMultiMap(std::initializer_list<std::pair<Key,T> > list)
\since 5.1
Constructs a multi-map with a copy of each of the elements in the
@@ -1941,7 +1953,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
compiled in C++11 mode.
*/
-/*! \fn QMultiMap::QMultiMap(const QMap<Key, T> &other)
+/*! \fn template <class Key, class T> QMultiMap<Key, T>::QMultiMap(const QMap<Key, T> &other)
Constructs a copy of \a other (which can be a QMap or a
QMultiMap).
@@ -1949,7 +1961,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa operator=()
*/
-/*! \fn QMultiMap::iterator QMultiMap::replace(const Key &key, const T &value)
+/*! \fn template <class Key, class T> QMultiMap<Key, T>::iterator QMultiMap<Key, T>::replace(const Key &key, const T &value)
Inserts a new item with the key \a key and a value of \a value.
@@ -1962,7 +1974,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa insert()
*/
-/*! \fn QMultiMap::iterator QMultiMap::insert(const Key &key, const T &value)
+/*! \fn template <class Key, class T> QMultiMap<Key, T>::iterator QMultiMap<Key, T>::insert(const Key &key, const T &value)
Inserts a new item with the key \a key and a value of \a value.
@@ -1974,7 +1986,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa replace()
*/
-/*! \fn QMultiMap::iterator QMultiMap::insert(QMap<Key, T>::const_iterator pos, const Key &key, const T &value)
+/*! \fn template <class Key, class T> typename QMap<Key, T>::iterator QMultiMap<Key, T>::insert(typename QMap<Key, T>::const_iterator pos, const Key &key, const T &value)
\since 5.1
Inserts a new item with the key \a key and value \a value and with hint \a pos
@@ -1991,7 +2003,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
crash but there is also a risk that it will silently corrupt both the map and the \a pos map.
*/
-/*! \fn QMultiMap &QMultiMap::operator+=(const QMultiMap &other)
+/*! \fn template <class Key, class T> QMultiMap &QMultiMap<Key, T>::operator+=(const QMultiMap &other)
Inserts all the items in the \a other map into this map and
returns a reference to this map.
@@ -1999,7 +2011,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
\sa insert(), operator+()
*/
-/*! \fn QMultiMap QMultiMap::operator+(const QMultiMap &other) const
+/*! \fn template <class Key, class T> QMultiMap QMultiMap<Key, T>::operator+(const QMultiMap &other) const
Returns a map that contains all the items in this map in
addition to all the items in \a other. If a key is common to both
@@ -2009,7 +2021,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
*/
/*!
- \fn bool QMultiMap::contains(const Key &key, const T &value) const
+ \fn template <class Key, class T> bool QMultiMap<Key, T>::contains(const Key &key, const T &value) const
\since 4.3
Returns \c true if the map contains an item with key \a key and
@@ -2019,7 +2031,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
*/
/*!
- \fn int QMultiMap::remove(const Key &key, const T &value)
+ \fn template <class Key, class T> int QMultiMap<Key, T>::remove(const Key &key, const T &value)
\since 4.3
Removes all the items that have the key \a key and the value \a
@@ -2029,7 +2041,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
*/
/*!
- \fn int QMultiMap::count(const Key &key, const T &value) const
+ \fn template <class Key, class T> int QMultiMap<Key, T>::count(const Key &key, const T &value) const
\since 4.3
Returns the number of items with key \a key and value \a value.
@@ -2038,7 +2050,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
*/
/*!
- \fn typename QMap<Key, T>::iterator QMultiMap::find(const Key &key, const T &value)
+ \fn template <class Key, class T> typename QMap<Key, T>::iterator QMultiMap<Key, T>::find(const Key &key, const T &value)
\since 4.3
Returns an iterator pointing to the item with key \a key and
@@ -2054,7 +2066,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
*/
/*!
- \fn typename QMap<Key, T>::const_iterator QMultiMap::find(const Key &key, const T &value) const
+ \fn template <class Key, class T> typename QMap<Key, T>::const_iterator QMultiMap<Key, T>::find(const Key &key, const T &value) const
\since 4.3
\overload
@@ -2071,7 +2083,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
*/
/*!
- \fn typename QMap<Key, T>::const_iterator QMultiMap::constFind(const Key &key, const T &value) const
+ \fn template <class Key, class T> typename QMap<Key, T>::const_iterator QMultiMap<Key, T>::constFind(const Key &key, const T &value) const
\since 4.3
Returns an iterator pointing to the item with key \a key and the
diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h
index b400e69f0c..a5b9096835 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/qpair.qdoc b/src/corelib/tools/qpair.qdoc
index 9b9b1783ac..59e6931995 100644
--- a/src/corelib/tools/qpair.qdoc
+++ b/src/corelib/tools/qpair.qdoc
@@ -93,14 +93,14 @@
The second element in the pair.
*/
-/*! \fn QPair::QPair()
+/*! \fn template <class T1, class T2> QPair<T1, T2>::QPair()
Constructs an empty pair. The \c first and \c second elements are
initialized with \l{default-constructed value}s.
*/
/*!
- \fn QPair::QPair(const T1 &value1, const T2 &value2)
+ \fn template <class T1, class T2> QPair<T1, T2>::QPair(const T1 &value1, const T2 &value2)
Constructs a pair and initializes the \c first element with \a
value1 and the \c second element with \a value2.
@@ -109,7 +109,7 @@
*/
/*!
-\fn void QPair::swap(QPair &other)
+\fn template <class T1, class T2> void QPair<T1, T2>::swap(QPair &other)
\since 5.5
Swaps this pair with \a other.
@@ -125,7 +125,7 @@
*/
/*!
-\fn void swap(QPair<T1, T2> &lhs, QPair<T1, T2> &rhs)
+\fn template <class T1, class T2> void swap(QPair<T1, T2> &lhs, QPair<T1, T2> &rhs)
\overload
\relates QPair
\since 5.5
@@ -134,7 +134,7 @@
*/
/*!
- \fn QPair::QPair(const QPair<TT1, TT2> &p)
+ \fn template <class T1, class T2> template <typename TT1, typename TT2> QPair<T1, T2>::QPair(const QPair<TT1, TT2> &p)
\since 5.2
Constructs a pair from the other pair \a p, of types TT1 and TT2. This
@@ -145,14 +145,14 @@
*/
/*!
- \fn QPair::QPair(QPair<TT1, TT2> &&p)
+ \fn template <class T1, class T2> template <typename TT1, typename TT2> QPair<T1, T2>::QPair(QPair<TT1, TT2> &&p)
\since 5.2
Move-constructs a QPair instance, making it point to the same object that \a p was pointing to.
*/
/*!
- \fn QPair & QPair::operator=(const QPair<TT1, TT2> &p)
+ \fn template <class T1, class T2> template <typename TT1, typename TT2> QPair & QPair<T1, T2>::operator=(const QPair<TT1, TT2> &p)
\since 5.2
Copies pair \a p into this pair.
@@ -161,13 +161,13 @@
*/
/*!
- \fn QPair & QPair::operator=(QPair<TT1, TT2> &&p)
+ \fn template <class T1, class T2> template <typename TT1, typename TT2> QPair & QPair<T1, T2>::operator=(QPair<TT1, TT2> &&p)
\since 5.2
Move-assigns pair \a p into this pair instance.
*/
-/*! \fn bool operator==(const QPair<T1, T2> &p1, const QPair<T1, T2> &p2)
+/*! \fn template <class T1, class T2> bool operator==(const QPair<T1, T2> &p1, const QPair<T1, T2> &p2)
\relates QPair
@@ -179,7 +179,7 @@
implementation of \c operator==().
*/
-/*! \fn bool operator!=(const QPair<T1, T2> &p1, const QPair<T1, T2> &p2)
+/*! \fn template <class T1, class T2> bool operator!=(const QPair<T1, T2> &p1, const QPair<T1, T2> &p2)
\relates QPair
@@ -192,7 +192,7 @@
implementation of \c operator==().
*/
-/*! \fn bool operator<(const QPair<T1, T2> &p1, const QPair<T1, T2> &p2)
+/*! \fn template <class T1, class T2> bool operator<(const QPair<T1, T2> &p1, const QPair<T1, T2> &p2)
\relates QPair
@@ -205,7 +205,7 @@
implementation of \c operator<().
*/
-/*! \fn bool operator>(const QPair<T1, T2> &p1, const QPair<T1, T2> &p2)
+/*! \fn template <class T1, class T2> bool operator>(const QPair<T1, T2> &p1, const QPair<T1, T2> &p2)
\relates QPair
@@ -218,7 +218,7 @@
implementation of \c operator<().
*/
-/*! \fn bool operator<=(const QPair<T1, T2> &p1, const QPair<T1, T2> &p2)
+/*! \fn template <class T1, class T2> bool operator<=(const QPair<T1, T2> &p1, const QPair<T1, T2> &p2)
\relates QPair
@@ -231,7 +231,7 @@
implementation of \c operator<().
*/
-/*! \fn bool operator>=(const QPair<T1, T2> &p1, const QPair<T1, T2> &p2)
+/*! \fn template <class T1, class T2> bool operator>=(const QPair<T1, T2> &p1, const QPair<T1, T2> &p2)
\relates QPair
@@ -245,7 +245,7 @@
*/
/*!
- \fn QPair<T1, T2> qMakePair(const T1 &value1, const T2 &value2)
+ \fn template <class T1, class T2> QPair<T1, T2> qMakePair(const T1 &value1, const T2 &value2)
\relates QPair
@@ -258,7 +258,7 @@
usually requires less typing.
*/
-/*! \fn QDataStream &operator>>(QDataStream &in, QPair<T1, T2> &pair)
+/*! \fn template <class T1, class T2> QDataStream &operator>>(QDataStream &in, QPair<T1, T2> &pair)
\relates QPair
@@ -269,7 +269,7 @@
\sa {Serializing Qt Data Types}
*/
-/*! \fn QDataStream &operator<<(QDataStream &out, const QPair<T1, T2> &pair)
+/*! \fn template <class T1, class T2> QDataStream &operator<<(QDataStream &out, const QPair<T1, T2> &pair)
\relates QPair
diff --git a/src/corelib/tools/qringbuffer.cpp b/src/corelib/tools/qringbuffer.cpp
index 8fa378e935..c9ef3bc69a 100644
--- a/src/corelib/tools/qringbuffer.cpp
+++ b/src/corelib/tools/qringbuffer.cpp
@@ -44,6 +44,46 @@
QT_BEGIN_NAMESPACE
+void QRingChunk::allocate(int alloc)
+{
+ Q_ASSERT(alloc > 0 && size() == 0);
+
+ if (chunk.size() < alloc || isShared())
+ chunk = QByteArray(alloc, Qt::Uninitialized);
+}
+
+void QRingChunk::detach()
+{
+ Q_ASSERT(isShared());
+
+ const int chunkSize = size();
+ QByteArray x(chunkSize, Qt::Uninitialized);
+ ::memcpy(x.data(), chunk.constData() + headOffset, chunkSize);
+ chunk = qMove(x);
+ headOffset = 0;
+ tailOffset = chunkSize;
+}
+
+QByteArray QRingChunk::toByteArray()
+{
+ if (headOffset != 0 || tailOffset != chunk.size()) {
+ if (isShared())
+ return chunk.mid(headOffset, size());
+
+ if (headOffset != 0) {
+ char *ptr = chunk.data();
+ ::memmove(ptr, ptr + headOffset, size());
+ tailOffset -= headOffset;
+ headOffset = 0;
+ }
+
+ chunk.reserve(0); // avoid that resizing needlessly reallocates
+ chunk.resize(tailOffset);
+ }
+
+ return chunk;
+}
+
/*!
\internal
@@ -54,12 +94,11 @@ QT_BEGIN_NAMESPACE
const char *QRingBuffer::readPointerAtPosition(qint64 pos, qint64 &length) const
{
if (pos >= 0) {
- pos += head;
- for (int i = 0; i < buffers.size(); ++i) {
- length = (i == tailBuffer ? tail : buffers[i].size());
+ for (const QRingChunk &chunk : buffers) {
+ length = chunk.size();
if (length > pos) {
length -= pos;
- return buffers[i].constData() + pos;
+ return chunk.data() + pos;
}
pos -= length;
}
@@ -74,32 +113,31 @@ void QRingBuffer::free(qint64 bytes)
Q_ASSERT(bytes <= bufferSize);
while (bytes > 0) {
- const qint64 blockSize = buffers.constFirst().size() - head;
+ const qint64 chunkSize = buffers.constFirst().size();
- if (tailBuffer == 0 || blockSize > bytes) {
+ if (buffers.size() == 1 || chunkSize > bytes) {
+ QRingChunk &chunk = buffers.first();
// keep a single block around if it does not exceed
// the basic block size, to avoid repeated allocations
// between uses of the buffer
if (bufferSize <= bytes) {
- if (buffers.constFirst().size() <= basicBlockSize) {
+ if (chunk.capacity() <= basicBlockSize && !chunk.isShared()) {
+ chunk.reset();
bufferSize = 0;
- head = tail = 0;
} else {
clear(); // try to minify/squeeze us
}
} else {
Q_ASSERT(bytes < MaxByteArraySize);
- head += int(bytes);
+ chunk.advance(bytes);
bufferSize -= bytes;
}
return;
}
- bufferSize -= blockSize;
- bytes -= blockSize;
+ bufferSize -= chunkSize;
+ bytes -= chunkSize;
buffers.removeFirst();
- --tailBuffer;
- head = 0;
}
}
@@ -108,32 +146,25 @@ char *QRingBuffer::reserve(qint64 bytes)
if (bytes <= 0 || bytes >= MaxByteArraySize)
return 0;
+ const int chunkSize = qMax(basicBlockSize, int(bytes));
+ int tail = 0;
if (bufferSize == 0) {
if (buffers.isEmpty())
- buffers.append(QByteArray(qMax(basicBlockSize, int(bytes)), Qt::Uninitialized));
+ buffers.append(QRingChunk(chunkSize));
else
- buffers.first().resize(qMax(basicBlockSize, int(bytes)));
+ buffers.first().allocate(chunkSize);
} else {
- const qint64 newSize = bytes + tail;
+ const QRingChunk &chunk = buffers.constLast();
// if need a new buffer
- if (basicBlockSize == 0 || (newSize > buffers.constLast().capacity()
- && (tail >= basicBlockSize || newSize >= MaxByteArraySize))) {
- // shrink this buffer to its current size
- buffers.last().resize(tail);
-
- // create a new QByteArray
- buffers.append(QByteArray(qMax(basicBlockSize, int(bytes)), Qt::Uninitialized));
- ++tailBuffer;
- tail = 0;
- } else if (newSize > buffers.constLast().size()) {
- buffers.last().resize(qMax(basicBlockSize, int(newSize)));
- }
+ if (basicBlockSize == 0 || chunk.isShared() || bytes > chunk.available())
+ buffers.append(QRingChunk(chunkSize));
+ else
+ tail = chunk.size();
}
- char *writePtr = buffers.last().data() + tail;
+ buffers.last().grow(bytes);
bufferSize += bytes;
- tail += int(bytes);
- return writePtr;
+ return buffers.last().data() + tail;
}
/*!
@@ -146,29 +177,28 @@ char *QRingBuffer::reserveFront(qint64 bytes)
if (bytes <= 0 || bytes >= MaxByteArraySize)
return 0;
- if (head < bytes || basicBlockSize == 0) {
- if (head > 0) {
- buffers.first().remove(0, head);
- if (tailBuffer == 0)
- tail -= head;
- }
-
- head = qMax(basicBlockSize, int(bytes));
- if (bufferSize == 0) {
- if (buffers.isEmpty())
- buffers.prepend(QByteArray(head, Qt::Uninitialized));
- else
- buffers.first().resize(head);
- tail = head;
+ const int chunkSize = qMax(basicBlockSize, int(bytes));
+ if (bufferSize == 0) {
+ if (buffers.isEmpty())
+ buffers.prepend(QRingChunk(chunkSize));
+ else
+ buffers.first().allocate(chunkSize);
+ buffers.first().grow(chunkSize);
+ buffers.first().advance(chunkSize - bytes);
+ } else {
+ const QRingChunk &chunk = buffers.constFirst();
+ // if need a new buffer
+ if (basicBlockSize == 0 || chunk.isShared() || bytes > chunk.head()) {
+ buffers.prepend(QRingChunk(chunkSize));
+ buffers.first().grow(chunkSize);
+ buffers.first().advance(chunkSize - bytes);
} else {
- buffers.prepend(QByteArray(head, Qt::Uninitialized));
- ++tailBuffer;
+ buffers.first().advance(-bytes);
}
}
- head -= int(bytes);
bufferSize += bytes;
- return buffers.first().data() + head;
+ return buffers.first().data();
}
void QRingBuffer::chop(qint64 bytes)
@@ -176,30 +206,31 @@ void QRingBuffer::chop(qint64 bytes)
Q_ASSERT(bytes <= bufferSize);
while (bytes > 0) {
- if (tailBuffer == 0 || tail > bytes) {
+ const qint64 chunkSize = buffers.constLast().size();
+
+ if (buffers.size() == 1 || chunkSize > bytes) {
+ QRingChunk &chunk = buffers.last();
// keep a single block around if it does not exceed
// the basic block size, to avoid repeated allocations
// between uses of the buffer
- if (bufferSize <= bytes) {
- if (buffers.constFirst().size() <= basicBlockSize) {
+ if (bufferSize == bytes) {
+ if (chunk.capacity() <= basicBlockSize && !chunk.isShared()) {
+ chunk.reset();
bufferSize = 0;
- head = tail = 0;
} else {
clear(); // try to minify/squeeze us
}
} else {
Q_ASSERT(bytes < MaxByteArraySize);
- tail -= int(bytes);
+ chunk.grow(-bytes);
bufferSize -= bytes;
}
return;
}
- bufferSize -= tail;
- bytes -= tail;
+ bufferSize -= chunkSize;
+ bytes -= chunkSize;
buffers.removeLast();
- --tailBuffer;
- tail = buffers.constLast().size();
}
}
@@ -210,9 +241,6 @@ void QRingBuffer::clear()
buffers.erase(buffers.begin() + 1, buffers.end());
buffers.first().clear();
-
- head = tail = 0;
- tailBuffer = 0;
bufferSize = 0;
}
@@ -221,13 +249,12 @@ qint64 QRingBuffer::indexOf(char c, qint64 maxLength, qint64 pos) const
if (maxLength <= 0 || pos < 0)
return -1;
- qint64 index = -(pos + head);
- for (int i = 0; i < buffers.size(); ++i) {
- const qint64 nextBlockIndex = qMin(index + (i == tailBuffer ? tail : buffers[i].size()),
- maxLength);
+ qint64 index = -pos;
+ for (const QRingChunk &chunk : buffers) {
+ const qint64 nextBlockIndex = qMin(index + chunk.size(), maxLength);
if (nextBlockIndex > 0) {
- const char *ptr = buffers[i].constData();
+ const char *ptr = chunk.data();
if (index < 0) {
ptr -= index;
index = 0;
@@ -271,19 +298,8 @@ QByteArray QRingBuffer::read()
if (bufferSize == 0)
return QByteArray();
- QByteArray qba(buffers.takeFirst());
-
- qba.reserve(0); // avoid that resizing needlessly reallocates
- if (tailBuffer == 0) {
- qba.resize(tail);
- tail = 0;
- } else {
- --tailBuffer;
- }
- qba.remove(0, head); // does nothing if head is 0
- head = 0;
- bufferSize -= qba.size();
- return qba;
+ bufferSize -= buffers.constFirst().size();
+ return buffers.takeFirst().toByteArray();
}
/*!
@@ -296,13 +312,12 @@ qint64 QRingBuffer::peek(char *data, qint64 maxLength, qint64 pos) const
qint64 readSoFar = 0;
if (pos >= 0) {
- pos += head;
for (int i = 0; readSoFar < maxLength && i < buffers.size(); ++i) {
- qint64 blockLength = (i == tailBuffer ? tail : buffers[i].size());
+ qint64 blockLength = buffers[i].size();
if (pos < blockLength) {
blockLength = qMin(blockLength - pos, maxLength - readSoFar);
- memcpy(data + readSoFar, buffers[i].constData() + pos, blockLength);
+ memcpy(data + readSoFar, buffers[i].data() + pos, blockLength);
readSoFar += blockLength;
pos = 0;
} else {
@@ -335,18 +350,11 @@ void QRingBuffer::append(const char *data, qint64 size)
*/
void QRingBuffer::append(const QByteArray &qba)
{
- if (tail == 0) {
- if (buffers.isEmpty())
- buffers.append(qba);
- else
- buffers.last() = qba;
- } else {
- buffers.last().resize(tail);
- buffers.append(qba);
- ++tailBuffer;
- }
- tail = qba.size();
- bufferSize += tail;
+ if (bufferSize != 0 || buffers.isEmpty())
+ buffers.append(QRingChunk(qba));
+ else
+ buffers.last().assign(qba);
+ bufferSize += qba.size();
}
qint64 QRingBuffer::readLine(char *data, qint64 maxLength)
diff --git a/src/corelib/tools/qringbuffer_p.h b/src/corelib/tools/qringbuffer_p.h
index 558a456515..c232ae3c72 100644
--- a/src/corelib/tools/qringbuffer_p.h
+++ b/src/corelib/tools/qringbuffer_p.h
@@ -53,7 +53,7 @@
#include <QtCore/private/qglobal_p.h>
#include <QtCore/qbytearray.h>
-#include <QtCore/qlist.h>
+#include <QtCore/qvector.h>
QT_BEGIN_NAMESPACE
@@ -61,11 +61,129 @@ QT_BEGIN_NAMESPACE
#define QRINGBUFFER_CHUNKSIZE 4096
#endif
+class QRingChunk
+{
+public:
+ // initialization and cleanup
+ inline QRingChunk() Q_DECL_NOTHROW :
+ headOffset(0), tailOffset(0)
+ {
+ }
+ inline QRingChunk(const QRingChunk &other) Q_DECL_NOTHROW :
+ chunk(other.chunk), headOffset(other.headOffset), tailOffset(other.tailOffset)
+ {
+ }
+ explicit inline QRingChunk(int alloc) :
+ chunk(alloc, Qt::Uninitialized), headOffset(0), tailOffset(0)
+ {
+ }
+ explicit inline QRingChunk(const QByteArray &qba) Q_DECL_NOTHROW :
+ chunk(qba), headOffset(0), tailOffset(qba.size())
+ {
+ }
+
+ inline QRingChunk &operator=(const QRingChunk &other) Q_DECL_NOTHROW
+ {
+ chunk = other.chunk;
+ headOffset = other.headOffset;
+ tailOffset = other.tailOffset;
+ return *this;
+ }
+ inline QRingChunk(QRingChunk &&other) Q_DECL_NOTHROW :
+ chunk(other.chunk), headOffset(other.headOffset), tailOffset(other.tailOffset)
+ {
+ other.headOffset = other.tailOffset = 0;
+ }
+ inline QRingChunk &operator=(QRingChunk &&other) Q_DECL_NOTHROW
+ {
+ swap(other);
+ return *this;
+ }
+
+ inline void swap(QRingChunk &other) Q_DECL_NOTHROW
+ {
+ chunk.swap(other.chunk);
+ qSwap(headOffset, other.headOffset);
+ qSwap(tailOffset, other.tailOffset);
+ }
+
+ // allocating and sharing
+ void allocate(int alloc);
+ inline bool isShared() const
+ {
+ return !chunk.isDetached();
+ }
+ Q_CORE_EXPORT void detach();
+ QByteArray toByteArray();
+
+ // getters
+ inline int head() const
+ {
+ return headOffset;
+ }
+ inline int size() const
+ {
+ return tailOffset - headOffset;
+ }
+ inline int capacity() const
+ {
+ return chunk.size();
+ }
+ inline int available() const
+ {
+ return chunk.size() - tailOffset;
+ }
+ inline const char *data() const
+ {
+ return chunk.constData() + headOffset;
+ }
+ inline char *data()
+ {
+ if (isShared())
+ detach();
+ return chunk.data() + headOffset;
+ }
+
+ // array management
+ inline void advance(int offset)
+ {
+ Q_ASSERT(headOffset + offset >= 0);
+ Q_ASSERT(size() - offset > 0);
+
+ headOffset += offset;
+ }
+ inline void grow(int offset)
+ {
+ Q_ASSERT(size() + offset > 0);
+ Q_ASSERT(head() + size() + offset <= capacity());
+
+ tailOffset += offset;
+ }
+ inline void assign(const QByteArray &qba)
+ {
+ chunk = qba;
+ headOffset = 0;
+ tailOffset = qba.size();
+ }
+ inline void reset()
+ {
+ headOffset = tailOffset = 0;
+ }
+ inline void clear()
+ {
+ assign(QByteArray());
+ }
+
+private:
+ QByteArray chunk;
+ int headOffset, tailOffset;
+};
+
class QRingBuffer
{
public:
explicit inline QRingBuffer(int growth = QRINGBUFFER_CHUNKSIZE) :
- head(0), tail(0), tailBuffer(0), basicBlockSize(growth), bufferSize(0) { }
+ bufferSize(0), basicBlockSize(growth) { }
inline void setChunkSize(int size) {
basicBlockSize = size;
@@ -76,11 +194,11 @@ public:
}
inline qint64 nextDataBlockSize() const {
- return (tailBuffer == 0 ? tail : buffers.first().size()) - head;
+ return bufferSize == 0 ? Q_INT64_C(0) : buffers.first().size();
}
inline const char *readPointer() const {
- return bufferSize == 0 ? Q_NULLPTR : (buffers.first().constData() + head);
+ return bufferSize == 0 ? nullptr : buffers.first().data();
}
Q_CORE_EXPORT const char *readPointerAtPosition(qint64 pos, qint64 &length) const;
@@ -114,14 +232,8 @@ public:
void ungetChar(char c)
{
- if (head > 0) {
- --head;
- buffers.first()[head] = c;
- ++bufferSize;
- } else {
- char *ptr = reserveFront(1);
- *ptr = c;
- }
+ char *ptr = reserveFront(1);
+ *ptr = c;
}
@@ -152,13 +264,12 @@ public:
}
private:
- QList<QByteArray> buffers;
- int head, tail;
- int tailBuffer; // always buffers.size() - 1
- int basicBlockSize;
+ QVector<QRingChunk> buffers;
qint64 bufferSize;
+ int basicBlockSize;
};
+Q_DECLARE_SHARED(QRingChunk)
Q_DECLARE_TYPEINFO(QRingBuffer, Q_MOVABLE_TYPE);
QT_END_NAMESPACE
diff --git a/src/corelib/tools/qscopedpointer.cpp b/src/corelib/tools/qscopedpointer.cpp
index 8d84b3beca..605758dcc3 100644
--- a/src/corelib/tools/qscopedpointer.cpp
+++ b/src/corelib/tools/qscopedpointer.cpp
@@ -126,27 +126,34 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn QScopedPointer::QScopedPointer(T *p = 0)
+ \fn template <typename T, typename Cleanup> QScopedPointer<T, Cleanup>::QScopedPointer(T *p = 0)
Constructs this QScopedPointer instance and sets its pointer to \a p.
*/
/*!
- \fn QScopedPointer::~QScopedPointer()
+ \fn template <typename T, typename Cleanup> QScopedPointer<T, Cleanup>::~QScopedPointer()
Destroys this QScopedPointer object. Delete the object its pointer points
to.
*/
/*!
- \fn T *QScopedPointer::data() const
+ \fn template <typename T, typename Cleanup> T *QScopedPointer<T, Cleanup>::data() const
Returns the value of the pointer referenced by this object. QScopedPointer
still owns the object pointed to.
*/
/*!
- \fn T &QScopedPointer::operator*() const
+ \fn template <typename T, typename Cleanup> T *QScopedPointer::get() const
+ \since 5.11
+
+ Same as data().
+*/
+
+/*!
+ \fn template <typename T, typename Cleanup> T &QScopedPointer<T, Cleanup>::operator*() const
Provides access to the scoped pointer's object.
@@ -155,7 +162,7 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn T *QScopedPointer::operator->() const
+ \fn template <typename T, typename Cleanup> T *QScopedPointer<T, Cleanup>::operator->() const
Provides access to the scoped pointer's object.
@@ -165,7 +172,7 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn QScopedPointer::operator bool() const
+ \fn template <typename T, typename Cleanup> QScopedPointer<T, Cleanup>::operator bool() const
Returns \c true if this object is not \c null. This function is suitable
for use in \tt if-constructs, like:
@@ -176,7 +183,7 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn bool operator==(const QScopedPointer<T, Cleanup> &lhs, const QScopedPointer<T, Cleanup> &rhs)
+ \fn template <typename T, typename Cleanup> bool operator==(const QScopedPointer<T, Cleanup> &lhs, const QScopedPointer<T, Cleanup> &rhs)
Equality operator. Returns \c true if the scoped pointers
\a lhs and \a rhs are pointing to the same object.
@@ -185,7 +192,7 @@ QT_BEGIN_NAMESPACE
/*!
- \fn bool operator!=(const QScopedPointer<T, Cleanup> &lhs, const QScopedPointer<T, Cleanup> &rhs)
+ \fn template <typename T, typename Cleanup> bool operator!=(const QScopedPointer<T, Cleanup> &lhs, const QScopedPointer<T, Cleanup> &rhs)
Inequality operator. Returns \c true if the scoped pointers
\a lhs and \a rhs are \e not pointing to the same object.
@@ -193,7 +200,7 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn bool operator==(const QScopedPointer<T, Cleanup> &lhs, std::nullptr_t)
+ \fn template <typename T, typename Cleanup> bool operator==(const QScopedPointer<T, Cleanup> &lhs, std::nullptr_t)
\relates QScopedPointer
\since 5.8
@@ -203,7 +210,7 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn bool operator==(std::nullptr_t, const QScopedPointer<T, Cleanup> &rhs)
+ \fn template <typename T, typename Cleanup> bool operator==(std::nullptr_t, const QScopedPointer<T, Cleanup> &rhs)
\relates QScopedPointer
\since 5.8
@@ -213,7 +220,7 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn bool operator!=(const QScopedPointer<T, Cleanup> &lhs, std::nullptr_t)
+ \fn template <typename T, typename Cleanup> bool operator!=(const QScopedPointer<T, Cleanup> &lhs, std::nullptr_t)
\relates QScopedPointer
\since 5.8
@@ -224,7 +231,7 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn bool operator!=(std::nullptr_t, const QScopedPointer<T, Cleanup> &rhs)
+ \fn template <typename T, typename Cleanup> bool operator!=(std::nullptr_t, const QScopedPointer<T, Cleanup> &rhs)
\relates QScopedPointer
\since 5.8
@@ -235,13 +242,13 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn bool QScopedPointer::isNull() const
+ \fn template <typename T, typename Cleanup> bool QScopedPointer<T, Cleanup>::isNull() const
Returns \c true if this object is holding a pointer that is \c null.
*/
/*!
- \fn void QScopedPointer::reset(T *other = 0)
+ \fn template <typename T, typename Cleanup> void QScopedPointer<T, Cleanup>::reset(T *other = 0)
Deletes the existing object it is pointing to if any, and sets its pointer to
\a other. QScopedPointer now owns \a other and will delete it in its
@@ -249,7 +256,7 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn T *QScopedPointer::take()
+ \fn template <typename T, typename Cleanup> T *QScopedPointer<T, Cleanup>::take()
Returns the value of the pointer referenced by this object. The pointer of this
QScopedPointer object will be reset to \c null.
@@ -257,7 +264,7 @@ QT_BEGIN_NAMESPACE
Callers of this function take ownership of the pointer.
*/
-/*! \fn bool QScopedPointer::operator!() const
+/*! \fn template <typename T, typename Cleanup> bool QScopedPointer<T, Cleanup>::operator!() const
Returns \c true if the pointer referenced by this object is \c null, otherwise
returns \c false.
@@ -265,7 +272,7 @@ QT_BEGIN_NAMESPACE
\sa isNull()
*/
-/*! \fn void QScopedPointer::swap(QScopedPointer<T, Cleanup> &other)
+/*! \fn template <typename T, typename Cleanup> void QScopedPointer<T, Cleanup>::swap(QScopedPointer<T, Cleanup> &other)
Swap this pointer with \a other.
*/
@@ -297,20 +304,20 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn QScopedArrayPointer::QScopedArrayPointer()
+ \fn template <typename T, typename Cleanup> QScopedArrayPointer<T, Cleanup>::QScopedArrayPointer()
Constructs a QScopedArrayPointer instance.
*/
/*!
- \fn QScopedArrayPointer::QScopedArrayPointer(D * p)
+ \fn template <typename T, typename Cleanup> template <typename D> QScopedArrayPointer<T, Cleanup>::QScopedArrayPointer(D * p)
Constructs a QScopedArrayPointer and stores the array of objects
pointed to by \a p.
*/
/*!
- \fn T *QScopedArrayPointer::operator[](int i)
+ \fn template <typename T, typename Cleanup> T *QScopedArrayPointer<T, Cleanup>::operator[](int i)
Provides access to entry \a i of the scoped pointer's array of
objects.
@@ -321,7 +328,7 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn T *QScopedArrayPointer::operator[](int i) const
+ \fn template <typename T, typename Cleanup> T *QScopedArrayPointer<T, Cleanup>::operator[](int i) const
Provides access to entry \a i of the scoped pointer's array of
objects.
@@ -331,4 +338,8 @@ QT_BEGIN_NAMESPACE
\sa isNull()
*/
+/*! \fn template <typename T, typename Cleanup> void QScopedArrayPointer<T, Cleanup>::swap(QScopedArrayPointer<T, Cleanup> &other)
+ Swap this pointer with \a other.
+ */
+
QT_END_NAMESPACE
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/qset.qdoc b/src/corelib/tools/qset.qdoc
index 93f157fdc5..48863f2399 100644
--- a/src/corelib/tools/qset.qdoc
+++ b/src/corelib/tools/qset.qdoc
@@ -96,14 +96,14 @@
*/
/*!
- \fn QSet::QSet()
+ \fn template <class T> QSet<T>::QSet()
Constructs an empty set.
\sa clear()
*/
-/*! \fn QSet::QSet(std::initializer_list<T> list)
+/*! \fn template <class T> QSet<T>::QSet(std::initializer_list<T> list)
\since 5.1
Constructs a set with a copy of each of the elements in the
@@ -114,14 +114,14 @@
*/
/*!
- \fn void QSet::swap(QSet<T> &other)
+ \fn template <class T> void QSet<T>::swap(QSet<T> &other)
Swaps set \a other with this set. This operation is very fast and
never fails.
*/
/*!
- \fn bool QSet::operator==(const QSet<T> &other) const
+ \fn template <class T> bool QSet<T>::operator==(const QSet<T> &other) const
Returns \c true if the \a other set is equal to this set; otherwise
returns \c false.
@@ -134,7 +134,7 @@
*/
/*!
- \fn bool QSet::operator!=(const QSet<T> &other) const
+ \fn template <class T> bool QSet<T>::operator!=(const QSet<T> &other) const
Returns \c true if the \a other set is not equal to this set; otherwise
returns \c false.
@@ -147,7 +147,7 @@
*/
/*!
- \fn int QSet::size() const
+ \fn template <class T> int QSet<T>::size() const
Returns the number of items in the set.
@@ -155,7 +155,7 @@
*/
/*!
- \fn bool QSet::isEmpty() const
+ \fn template <class T> bool QSet<T>::isEmpty() const
Returns \c true if the set contains no elements; otherwise returns
false.
@@ -164,7 +164,7 @@
*/
/*!
- \fn int QSet::capacity() const
+ \fn template <class T> int QSet<T>::capacity() const
Returns the number of buckets in the set's internal hash
table.
@@ -177,7 +177,7 @@
\sa reserve(), squeeze()
*/
-/*! \fn void QSet::reserve(int size)
+/*! \fn template <class T> void QSet<T>::reserve(int size)
Ensures that the set's internal hash table consists of at
least \a size buckets.
@@ -201,7 +201,7 @@
*/
/*!
- \fn void QSet::squeeze()
+ \fn template <class T> void QSet<T>::squeeze()
Reduces the size of the set's internal hash table to save
memory.
@@ -214,7 +214,7 @@
*/
/*!
- \fn void QSet::detach()
+ \fn template <class T> void QSet<T>::detach()
\internal
@@ -224,7 +224,7 @@
\sa isDetached()
*/
-/*! \fn bool QSet::isDetached() const
+/*! \fn template <class T> bool QSet<T>::isDetached() const
\internal
@@ -235,12 +235,12 @@
*/
/*!
- \fn void QSet::setSharable(bool sharable)
+ \fn template <class T> void QSet<T>::setSharable(bool sharable)
\internal
*/
/*!
- \fn void QSet::clear()
+ \fn template <class T> void QSet<T>::clear()
Removes all elements from the set.
@@ -248,7 +248,7 @@
*/
/*!
- \fn bool QSet::remove(const T &value)
+ \fn template <class T> bool QSet<T>::remove(const T &value)
Removes any occurrence of item \a value from the set. Returns
true if an item was actually removed; otherwise returns \c false.
@@ -257,7 +257,7 @@
*/
/*!
- \fn QSet::iterator QSet::erase(const_iterator pos)
+ \fn template <class T> QSet<T>::iterator QSet<T>::erase(const_iterator pos)
\since 5.7
Removes the item at the iterator position \a pos from the set, and
@@ -271,12 +271,12 @@
*/
/*!
- \fn QSet::iterator QSet::erase(iterator pos)
+ \fn template <class T> QSet<T>::iterator QSet<T>::erase(iterator pos)
\since 4.2
\overload
*/
-/*! \fn QSet::const_iterator QSet::find(const T &value) const
+/*! \fn template <class T> QSet<T>::const_iterator QSet<T>::find(const T &value) const
\since 4.2
Returns a const iterator positioned at the item \a value in the
@@ -286,7 +286,7 @@
\sa constFind(), contains()
*/
-/*! \fn QSet::iterator QSet::find(const T &value)
+/*! \fn template <class T> QSet<T>::iterator QSet<T>::find(const T &value)
\since 4.2
\overload
@@ -295,7 +295,7 @@
returns end().
*/
-/*! \fn QSet::const_iterator QSet::constFind(const T &value) const
+/*! \fn template <class T> QSet<T>::const_iterator QSet<T>::constFind(const T &value) const
\since 4.2
Returns a const iterator positioned at the item \a value in the
@@ -306,7 +306,7 @@
*/
/*!
- \fn bool QSet::contains(const T &value) const
+ \fn template <class T> bool QSet<T>::contains(const T &value) const
Returns \c true if the set contains item \a value; otherwise returns
false.
@@ -315,7 +315,7 @@
*/
/*!
- \fn bool QSet::contains(const QSet<T> &other) const
+ \fn template <class T> bool QSet<T>::contains(const QSet<T> &other) const
\since 4.6
Returns \c true if the set contains all items from the \a other set;
@@ -324,7 +324,7 @@
\sa insert(), remove(), find()
*/
-/*! \fn QSet::const_iterator QSet::begin() const
+/*! \fn template <class T> QSet<T>::const_iterator QSet<T>::begin() const
Returns a const \l{STL-style iterators}{STL-style iterator} positioned at the first
item in the set.
@@ -332,7 +332,7 @@
\sa constBegin(), end()
*/
-/*! \fn QSet::iterator QSet::begin()
+/*! \fn template <class T> QSet<T>::iterator QSet<T>::begin()
\since 4.2
\overload
@@ -340,7 +340,7 @@
item in the set.
*/
-/*! \fn QSet::const_iterator QSet::cbegin() const
+/*! \fn template <class T> QSet<T>::const_iterator QSet<T>::cbegin() const
\since 5.0
Returns a const \l{STL-style iterators}{STL-style iterator} positioned at the first
@@ -349,7 +349,7 @@
\sa begin(), cend()
*/
-/*! \fn QSet::const_iterator QSet::constBegin() const
+/*! \fn template <class T> QSet<T>::const_iterator QSet<T>::constBegin() const
Returns a const \l{STL-style iterators}{STL-style iterator} positioned at the first
item in the set.
@@ -357,7 +357,7 @@
\sa begin(), constEnd()
*/
-/*! \fn QSet::const_iterator QSet::end() const
+/*! \fn template <class T> QSet<T>::const_iterator QSet<T>::end() const
Returns a const \l{STL-style iterators}{STL-style iterator} positioned at the imaginary
item after the last item in the set.
@@ -365,7 +365,7 @@
\sa constEnd(), begin()
*/
-/*! \fn QSet::iterator QSet::end()
+/*! \fn template <class T> QSet<T>::iterator QSet<T>::end()
\since 4.2
\overload
@@ -373,7 +373,7 @@
imaginary item after the last item in the set.
*/
-/*! \fn QSet::const_iterator QSet::cend() const
+/*! \fn template <class T> QSet<T>::const_iterator QSet<T>::cend() const
\since 5.0
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary
@@ -382,7 +382,7 @@
\sa cbegin(), end()
*/
-/*! \fn QSet::const_iterator QSet::constEnd() const
+/*! \fn template <class T> QSet<T>::const_iterator QSet<T>::constEnd() const
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary
item after the last item in the set.
@@ -390,7 +390,7 @@
\sa constBegin(), end()
*/
-/*! \fn QSet::reverse_iterator QSet::rbegin()
+/*! \fn template <class T> QSet<T>::reverse_iterator QSet<T>::rbegin()
\since 5.6
Returns a \l{STL-style iterators}{STL-style} reverse iterator pointing to the first
@@ -399,12 +399,12 @@
\sa begin(), crbegin(), rend()
*/
-/*! \fn QSet::const_reverse_iterator QSet::rbegin() const
+/*! \fn template <class T> QSet<T>::const_reverse_iterator QSet<T>::rbegin() const
\since 5.6
\overload
*/
-/*! \fn QSet::const_reverse_iterator QSet::crbegin() const
+/*! \fn template <class T> QSet<T>::const_reverse_iterator QSet<T>::crbegin() const
\since 5.6
Returns a const \l{STL-style iterators}{STL-style} reverse iterator pointing to the first
@@ -413,7 +413,7 @@
\sa begin(), rbegin(), rend()
*/
-/*! \fn QSet::reverse_iterator QSet::rend()
+/*! \fn template <class T> QSet<T>::reverse_iterator QSet<T>::rend()
\since 5.6
Returns a \l{STL-style iterators}{STL-style} reverse iterator pointing to one past
@@ -422,12 +422,12 @@
\sa end(), crend(), rbegin()
*/
-/*! \fn QSet::const_reverse_iterator QSet::rend() const
+/*! \fn template <class T> QSet<T>::const_reverse_iterator QSet<T>::rend() const
\since 5.6
\overload
*/
-/*! \fn QSet::const_reverse_iterator QSet::crend() const
+/*! \fn template <class T> QSet<T>::const_reverse_iterator QSet<T>::crend() const
\since 5.6
Returns a const \l{STL-style iterators}{STL-style} reverse iterator pointing to one
@@ -530,7 +530,7 @@
*/
/*!
- \fn QSet::insert(const T &value)
+ \fn template <class T> QSet<T>::insert(const T &value)
Inserts item \a value into the set, if \a value isn't already
in the set, and returns an iterator pointing at the inserted
@@ -540,7 +540,7 @@
*/
/*!
- \fn QSet<T> &QSet::unite(const QSet<T> &other)
+ \fn template <class T> QSet<T> &QSet<T>::unite(const QSet<T> &other)
Each item in the \a other set that isn't already in this set is
inserted into this set. A reference to this set is returned.
@@ -549,7 +549,7 @@
*/
/*!
- \fn QSet<T> &QSet::intersect(const QSet<T> &other)
+ \fn template <class T> QSet<T> &QSet<T>::intersect(const QSet<T> &other)
Removes all items from this set that are not contained in the
\a other set. A reference to this set is returned.
@@ -558,7 +558,7 @@
*/
/*!
- \fn bool QSet::intersects(const QSet<T> &other) const
+ \fn template <class T> bool QSet<T>::intersects(const QSet<T> &other) const
\since 5.6
Returns \c true if this set has at least one item in common with
@@ -568,7 +568,7 @@
*/
/*!
- \fn QSet<T> &QSet::subtract(const QSet<T> &other)
+ \fn template <class T> QSet<T> &QSet<T>::subtract(const QSet<T> &other)
Removes all items from this set that are contained in the
\a other set. Returns a reference to this set.
@@ -577,22 +577,22 @@
*/
/*!
- \fn bool QSet::empty() const
+ \fn template <class T> bool QSet<T>::empty() const
Returns \c true if the set is empty. This function is provided
for STL compatibility. It is equivalent to isEmpty().
*/
/*!
- \fn bool QSet::count() const
+ \fn template <class T> bool QSet<T>::count() const
Same as size().
*/
/*!
- \fn QSet<T> &QSet::operator<<(const T &value)
- \fn QSet<T> &QSet::operator+=(const T &value)
- \fn QSet<T> &QSet::operator|=(const T &value)
+ \fn template <class T> QSet<T> &QSet<T>::operator<<(const T &value)
+ \fn template <class T> QSet<T> &QSet<T>::operator+=(const T &value)
+ \fn template <class T> QSet<T> &QSet<T>::operator|=(const T &value)
Inserts a new item \a value and returns a reference to the set.
If \a value already exists in the set, the set is left unchanged.
@@ -601,7 +601,7 @@
*/
/*!
- \fn QSet<T> &QSet::operator-=(const T &value)
+ \fn template <class T> QSet<T> &QSet<T>::operator-=(const T &value)
Removes the occurrence of item \a value from the set, if
it is found, and returns a reference to the set. If the
@@ -611,8 +611,8 @@
*/
/*!
- \fn QSet<T> &QSet::operator|=(const QSet<T> &other)
- \fn QSet<T> &QSet::operator+=(const QSet<T> &other)
+ \fn template <class T> QSet<T> &QSet<T>::operator|=(const QSet<T> &other)
+ \fn template <class T> QSet<T> &QSet<T>::operator+=(const QSet<T> &other)
Same as unite(\a other).
@@ -620,7 +620,7 @@
*/
/*!
- \fn QSet<T> &QSet::operator&=(const QSet<T> &other)
+ \fn template <class T> QSet<T> &QSet<T>::operator&=(const QSet<T> &other)
Same as intersect(\a other).
@@ -628,7 +628,7 @@
*/
/*!
- \fn QSet<T> &QSet::operator&=(const T &value)
+ \fn template <class T> QSet<T> &QSet<T>::operator&=(const T &value)
\overload
@@ -638,7 +638,7 @@
/*!
- \fn QSet<T> &QSet::operator-=(const QSet<T> &other)
+ \fn template <class T> QSet<T> &QSet<T>::operator-=(const QSet<T> &other)
Same as subtract(\a{other}).
@@ -646,8 +646,8 @@
*/
/*!
- \fn QSet<T> QSet::operator|(const QSet<T> &other) const
- \fn QSet<T> QSet::operator+(const QSet<T> &other) const
+ \fn template <class T> QSet<T> QSet<T>::operator|(const QSet<T> &other) const
+ \fn template <class T> QSet<T> QSet<T>::operator+(const QSet<T> &other) const
Returns a new QSet that is the union of this set and the
\a other set.
@@ -656,7 +656,7 @@
*/
/*!
- \fn QSet<T> QSet::operator&(const QSet<T> &other) const
+ \fn template <class T> QSet<T> QSet<T>::operator&(const QSet<T> &other) const
Returns a new QSet that is the intersection of this set and the
\a other set.
@@ -665,7 +665,7 @@
*/
/*!
- \fn QSet<T> QSet::operator-(const QSet<T> &other) const
+ \fn template <class T> QSet<T> QSet<T>::operator-(const QSet<T> &other) const
Returns a new QSet that is the set difference of this set and
the \a other set, i.e., this set - \a other set.
@@ -766,8 +766,8 @@
*/
/*!
- \fn QSet::iterator::iterator()
- \fn QSet::const_iterator::const_iterator()
+ \fn template <class T> QSet<T>::iterator::iterator()
+ \fn template <class T> QSet<T>::const_iterator::const_iterator()
Constructs an uninitialized iterator.
@@ -779,8 +779,8 @@
*/
/*!
- \fn QSet::iterator::iterator(typename Hash::iterator i)
- \fn QSet::const_iterator::const_iterator(typename Hash::const_iterator i)
+ \fn template <class T> QSet<T>::iterator::iterator(typename Hash::iterator i)
+ \fn template <class T> QSet<T>::const_iterator::const_iterator(typename Hash::const_iterator i)
\internal
*/
@@ -822,14 +822,14 @@
*/
/*!
- \fn QSet::iterator::iterator(const iterator &other)
- \fn QSet::const_iterator::const_iterator(const const_iterator &other)
+ \fn template <class T> QSet<T>::iterator::iterator(const iterator &other)
+ \fn template <class T> QSet<T>::const_iterator::const_iterator(const const_iterator &other)
Constructs a copy of \a other.
*/
/*!
- \fn QSet::const_iterator::const_iterator(const iterator &other)
+ \fn template <class T> QSet<T>::const_iterator::const_iterator(const iterator &other)
\since 4.2
\overload
@@ -837,15 +837,15 @@
*/
/*!
- \fn QSet::iterator &QSet::iterator::operator=(const iterator &other)
- \fn QSet::const_iterator &QSet::const_iterator::operator=(const const_iterator &other)
+ \fn template <class T> QSet<T>::iterator &QSet<T>::iterator::operator=(const iterator &other)
+ \fn template <class T> QSet<T>::const_iterator &QSet<T>::const_iterator::operator=(const const_iterator &other)
Assigns \a other to this iterator.
*/
/*!
- \fn const T &QSet::iterator::operator*() const
- \fn const T &QSet::const_iterator::operator*() const
+ \fn template <class T> const T &QSet<T>::iterator::operator*() const
+ \fn template <class T> const T &QSet<T>::const_iterator::operator*() const
Returns a reference to the current item.
@@ -853,8 +853,8 @@
*/
/*!
- \fn const T *QSet::iterator::operator->() const
- \fn const T *QSet::const_iterator::operator->() const
+ \fn template <class T> const T *QSet<T>::iterator::operator->() const
+ \fn template <class T> const T *QSet<T>::const_iterator::operator->() const
Returns a pointer to the current item.
@@ -862,8 +862,8 @@
*/
/*!
- \fn bool QSet::iterator::operator==(const iterator &other) const
- \fn bool QSet::const_iterator::operator==(const const_iterator &other) const
+ \fn template <class T> bool QSet<T>::iterator::operator==(const iterator &other) const
+ \fn template <class T> bool QSet<T>::const_iterator::operator==(const const_iterator &other) const
Returns \c true if \a other points to the same item as this
iterator; otherwise returns \c false.
@@ -872,15 +872,15 @@
*/
/*!
- \fn bool QSet::iterator::operator==(const const_iterator &other) const
- \fn bool QSet::iterator::operator!=(const const_iterator &other) const
+ \fn template <class T> bool QSet<T>::iterator::operator==(const const_iterator &other) const
+ \fn template <class T> bool QSet<T>::iterator::operator!=(const const_iterator &other) const
\overload
*/
/*!
- \fn bool QSet::iterator::operator!=(const iterator &other) const
- \fn bool QSet::const_iterator::operator!=(const const_iterator &other) const
+ \fn template <class T> bool QSet<T>::iterator::operator!=(const iterator &other) const
+ \fn template <class T> bool QSet<T>::const_iterator::operator!=(const const_iterator &other) const
Returns \c true if \a other points to a different item than this
iterator; otherwise returns \c false.
@@ -889,22 +889,22 @@
*/
/*!
- \fn QSet::iterator &QSet::iterator::operator++()
- \fn QSet::const_iterator &QSet::const_iterator::operator++()
+ \fn template <class T> QSet<T>::iterator &QSet<T>::iterator::operator++()
+ \fn template <class T> QSet<T>::const_iterator &QSet<T>::const_iterator::operator++()
The prefix ++ operator (\c{++it}) advances the iterator to the
next item in the set and returns an iterator to the new current
item.
- Calling this function on QSet::constEnd() leads to
+ Calling this function on QSet<T>::constEnd() leads to
undefined results.
\sa operator--()
*/
/*!
- \fn QSet::iterator QSet::iterator::operator++(int)
- \fn QSet::const_iterator QSet::const_iterator::operator++(int)
+ \fn template <class T> QSet<T>::iterator QSet<T>::iterator::operator++(int)
+ \fn template <class T> QSet<T>::const_iterator QSet<T>::const_iterator::operator++(int)
\overload
@@ -914,8 +914,8 @@
*/
/*!
- \fn QSet::iterator &QSet::iterator::operator--()
- \fn QSet::const_iterator &QSet::const_iterator::operator--()
+ \fn template <class T> QSet<T>::iterator &QSet<T>::iterator::operator--()
+ \fn template <class T> QSet<T>::const_iterator &QSet<T>::const_iterator::operator--()
The prefix -- operator (\c{--it}) makes the preceding item
current and returns an iterator to the new current item.
@@ -927,8 +927,8 @@
*/
/*!
- \fn QSet::iterator QSet::iterator::operator--(int)
- \fn QSet::const_iterator QSet::const_iterator::operator--(int)
+ \fn template <class T> QSet<T>::iterator QSet<T>::iterator::operator--(int)
+ \fn template <class T> QSet<T>::const_iterator QSet<T>::const_iterator::operator--(int)
\overload
@@ -937,8 +937,8 @@
*/
/*!
- \fn QSet::iterator QSet::iterator::operator+(int j) const
- \fn QSet::const_iterator QSet::const_iterator::operator+(int j) const
+ \fn template <class T> QSet<T>::iterator QSet<T>::iterator::operator+(int j) const
+ \fn template <class T> QSet<T>::const_iterator QSet<T>::const_iterator::operator+(int j) const
Returns an iterator to the item at \a j positions forward from
this iterator. (If \a j is negative, the iterator goes backward.)
@@ -949,8 +949,8 @@
*/
/*!
- \fn QSet::iterator QSet::iterator::operator-(int j) const
- \fn QSet::const_iterator QSet::const_iterator::operator-(int j) const
+ \fn template <class T> QSet<T>::iterator QSet<T>::iterator::operator-(int j) const
+ \fn template <class T> QSet<T>::const_iterator QSet<T>::const_iterator::operator-(int j) const
Returns an iterator to the item at \a j positions backward from
this iterator. (If \a j is negative, the iterator goes forward.)
@@ -961,8 +961,8 @@
*/
/*!
- \fn QSet::iterator &QSet::iterator::operator+=(int j)
- \fn QSet::const_iterator &QSet::const_iterator::operator+=(int j)
+ \fn template <class T> QSet<T>::iterator &QSet<T>::iterator::operator+=(int j)
+ \fn template <class T> QSet<T>::const_iterator &QSet<T>::const_iterator::operator+=(int j)
Advances the iterator by \a j items. (If \a j is negative, the
iterator goes backward.)
@@ -973,8 +973,8 @@
*/
/*!
- \fn QSet::iterator &QSet::iterator::operator-=(int j)
- \fn QSet::const_iterator &QSet::const_iterator::operator-=(int j)
+ \fn template <class T> QSet<T>::iterator &QSet<T>::iterator::operator-=(int j)
+ \fn template <class T> QSet<T>::const_iterator &QSet<T>::const_iterator::operator-=(int j)
Makes the iterator go back by \a j items. (If \a j is negative,
the iterator goes forward.)
@@ -984,7 +984,7 @@
\sa operator+=(), operator-()
*/
-/*! \fn QList<T> QSet<T>::toList() const
+/*! \fn template <class T> QList<T> QSet<T>::toList() const
Returns a new QList containing the elements in the set. The
order of the elements in the QList is undefined.
@@ -996,7 +996,7 @@
\sa fromList(), QList::fromSet()
*/
-/*! \fn QList<T> QSet<T>::values() const
+/*! \fn template <class T> QList<T> QSet<T>::values() const
Returns a new QList containing the elements in the set. The
order of the elements in the QList is undefined.
@@ -1007,7 +1007,7 @@
*/
-/*! \fn QSet<T> QSet<T>::fromList(const QList<T> &list)
+/*! \fn template <class T> QSet<T> QSet<T>::fromList(const QList<T> &list)
Returns a new QSet object containing the data contained in \a
list. Since QSet doesn't allow duplicates, the resulting QSet
@@ -1022,7 +1022,7 @@
*/
/*!
- \fn QDataStream &operator<<(QDataStream &out, const QSet<T> &set)
+ \fn template <class T> QDataStream &operator<<(QDataStream &out, const QSet<T> &set)
\relates QSet
Writes the \a set to stream \a out.
@@ -1033,7 +1033,7 @@
*/
/*!
- \fn QDataStream &operator>>(QDataStream &in, QSet<T> &set)
+ \fn template <class T> QDataStream &operator>>(QDataStream &in, QSet<T> &set)
\relates QSet
Reads a set from stream \a in into \a set.
@@ -1044,7 +1044,7 @@
*/
/*!
- \fn uint qHash(const QSet<T> &key, uint seed = 0)
+ \fn template <class T> uint qHash(const QSet<T> &key, uint seed = 0)
\relates QHash
\since 5.5
diff --git a/src/corelib/tools/qshareddata.cpp b/src/corelib/tools/qshareddata.cpp
index 14bc70734d..f95d75c4a8 100644
--- a/src/corelib/tools/qshareddata.cpp
+++ b/src/corelib/tools/qshareddata.cpp
@@ -59,9 +59,9 @@ QT_BEGIN_NAMESPACE
Constructs a QSharedData object with a reference count of 0.
*/
-/*! \fn QSharedData::QSharedData(const QSharedData& other)
+/*! \fn QSharedData::QSharedData(const QSharedData& )
Constructs a QSharedData object with reference count 0.
- \a other is ignored.
+ The parameter is ignored.
*/
/*!
@@ -248,86 +248,86 @@ QT_BEGIN_NAMESPACE
\internal
*/
-/*! \fn T& QSharedDataPointer::operator*()
+/*! \fn template <class T> T& QSharedDataPointer<T>::operator*()
Provides access to the shared data object's members.
This function calls detach().
*/
-/*! \fn const T& QSharedDataPointer::operator*() const
+/*! \fn template <class T> const T& QSharedDataPointer<T>::operator*() const
Provides const access to the shared data object's members.
This function does \e not call detach().
*/
-/*! \fn T* QSharedDataPointer::operator->()
+/*! \fn template <class T> T* QSharedDataPointer<T>::operator->()
Provides access to the shared data object's members.
This function calls detach().
*/
-/*! \fn const T* QSharedDataPointer::operator->() const
+/*! \fn template <class T> const T* QSharedDataPointer<T>::operator->() const
Provides const access to the shared data object's members.
This function does \e not call detach().
*/
-/*! \fn QSharedDataPointer::operator T*()
+/*! \fn template <class T> QSharedDataPointer<T>::operator T*()
Returns a pointer to the shared data object.
This function calls detach().
\sa data(), constData()
*/
-/*! \fn QSharedDataPointer::operator const T*() const
+/*! \fn template <class T> QSharedDataPointer<T>::operator const T*() const
Returns a pointer to the shared data object.
This function does \e not call detach().
*/
-/*! \fn T* QSharedDataPointer::data()
+/*! \fn template <class T> T* QSharedDataPointer<T>::data()
Returns a pointer to the shared data object.
This function calls detach().
\sa constData()
*/
-/*! \fn const T* QSharedDataPointer::data() const
+/*! \fn template <class T> const T* QSharedDataPointer<T>::data() const
Returns a pointer to the shared data object.
This function does \e not call detach().
*/
-/*! \fn const T* QSharedDataPointer::constData() const
+/*! \fn template <class T> const T* QSharedDataPointer<T>::constData() const
Returns a const pointer to the shared data object.
This function does \e not call detach().
\sa data()
*/
-/*! \fn void QSharedDataPointer::swap(QSharedDataPointer &other)
+/*! \fn template <class T> void QSharedDataPointer<T>::swap(QSharedDataPointer &other)
Swap this instance's shared data pointer with the shared
data pointer in \a other.
*/
/*!
- \fn QSharedDataPointer<T> &QSharedDataPointer::operator=(QSharedDataPointer<T> &&other)
+ \fn template <class T> QSharedDataPointer<T> &QSharedDataPointer<T>::operator=(QSharedDataPointer<T> &&other)
Move-assigns \a other to this QSharedDataPointer instance.
\since 5.2
*/
-/*! \fn bool QSharedDataPointer::operator==(const QSharedDataPointer<T>& other) const
+/*! \fn template <class T> bool QSharedDataPointer<T>::operator==(const QSharedDataPointer<T>& other) const
Returns \c true if \a other and \e this have the same \e{d pointer}.
This function does \e not call detach().
*/
-/*! \fn bool QSharedDataPointer::operator!=(const QSharedDataPointer<T>& other) const
+/*! \fn template <class T> bool QSharedDataPointer<T>::operator!=(const QSharedDataPointer<T>& other) const
Returns \c true if \a other and \e this do \e not have the same
\e{d pointer}. This function does \e not call detach().
*/
-/*! \fn QSharedDataPointer::QSharedDataPointer()
+/*! \fn template <class T> QSharedDataPointer<T>::QSharedDataPointer()
Constructs a QSharedDataPointer initialized with a null \e{d pointer}.
*/
/*!
- \fn QSharedDataPointer::QSharedDataPointer(QSharedDataPointer &&o)
+ \fn template <class T> QSharedDataPointer<T>::QSharedDataPointer(QSharedDataPointer &&o)
Move-constructs a QSharedDataPointer instance, making it point at the same
object that \a o was pointing to.
@@ -335,45 +335,45 @@ QT_BEGIN_NAMESPACE
\since 5.2
*/
-/*! \fn QSharedDataPointer::~QSharedDataPointer()
+/*! \fn template <class T> QSharedDataPointer<T>::~QSharedDataPointer()
Decrements the reference count of the shared data object.
If the reference count becomes 0, the shared data object
is deleted. \e This is then destroyed.
*/
-/*! \fn QSharedDataPointer::QSharedDataPointer(T* sharedData)
+/*! \fn template <class T> QSharedDataPointer<T>::QSharedDataPointer(T* data)
Constructs a QSharedDataPointer with \e{d pointer} set to
- \a sharedData and increments \a{sharedData}'s reference count.
+ \a data and increments \a{data}'s reference count.
*/
-/*! \fn QSharedDataPointer::QSharedDataPointer(const QSharedDataPointer<T>& other)
+/*! \fn template <class T> QSharedDataPointer<T>::QSharedDataPointer(const QSharedDataPointer<T>& o)
Sets the \e{d pointer} of \e this to the \e{d pointer} in
- \a other and increments the reference count of the shared
+ \a o and increments the reference count of the shared
data object.
*/
-/*! \fn QSharedDataPointer<T>& QSharedDataPointer::operator=(const QSharedDataPointer<T>& other)
+/*! \fn template <class T> QSharedDataPointer<T>& QSharedDataPointer<T>::operator=(const QSharedDataPointer<T>& o)
Sets the \e{d pointer} of \e this to the \e{d pointer} of
- \a other and increments the reference count of the shared
+ \a o and increments the reference count of the shared
data object. The reference count of the old shared data
object of \e this is decremented. If the reference count
of the old shared data object becomes 0, the old shared
data object is deleted.
*/
-/*! \fn QSharedDataPointer& QSharedDataPointer::operator=(T* sharedData)
- Sets the \e{d pointer} og \e this to \a sharedData and increments
- \a{sharedData}'s reference count. The reference count of the old
+/*! \fn template <class T> QSharedDataPointer& QSharedDataPointer<T>::operator=(T* o)
+ Sets the \e{d pointer} og \e this to \a o and increments
+ \a{o}'s reference count. The reference count of the old
shared data object of \e this is decremented. If the reference
count of the old shared data object becomes 0, the old shared data
object is deleted.
*/
-/*! \fn bool QSharedDataPointer::operator!() const
+/*! \fn template <class T> bool QSharedDataPointer<T>::operator!() const
Returns \c true if the \e{d pointer} of \e this is null.
*/
-/*! \fn void QSharedDataPointer::detach()
+/*! \fn template <class T> void QSharedDataPointer<T>::detach()
If the shared data object's reference count is greater than 1, this
function creates a deep copy of the shared data object and sets the
\e{d pointer} of \e this to the copy.
@@ -383,7 +383,7 @@ QT_BEGIN_NAMESPACE
required. You don't need to call it yourself.
*/
-/*! \fn T *QSharedDataPointer::clone()
+/*! \fn template <class T> T *QSharedDataPointer<T>::clone()
\since 4.5
Creates and returns a deep copy of the current data. This function
@@ -449,71 +449,71 @@ QT_BEGIN_NAMESPACE
\sa QSharedData, QSharedDataPointer
*/
-/*! \fn T& QExplicitlySharedDataPointer::operator*() const
+/*! \fn template <class T> T& QExplicitlySharedDataPointer<T>::operator*() const
Provides access to the shared data object's members.
*/
-/*! \fn T* QExplicitlySharedDataPointer::operator->()
+/*! \fn template <class T> T* QExplicitlySharedDataPointer<T>::operator->()
Provides access to the shared data object's members.
*/
-/*! \fn const T* QExplicitlySharedDataPointer::operator->() const
+/*! \fn template <class T> const T* QExplicitlySharedDataPointer<T>::operator->() const
Provides const access to the shared data object's members.
*/
-/*! \fn T* QExplicitlySharedDataPointer::data() const
+/*! \fn template <class T> T* QExplicitlySharedDataPointer<T>::data() const
Returns a pointer to the shared data object.
*/
-/*! \fn const T* QExplicitlySharedDataPointer::constData() const
+/*! \fn template <class T> const T* QExplicitlySharedDataPointer<T>::constData() const
Returns a const pointer to the shared data object.
\sa data()
*/
-/*! \fn void QExplicitlySharedDataPointer::swap(QExplicitlySharedDataPointer &other)
+/*! \fn template <class T> void QExplicitlySharedDataPointer<T>::swap(QExplicitlySharedDataPointer &other)
Swap this instance's explicitly shared data pointer with
the explicitly shared data pointer in \a other.
*/
-/*! \fn bool QExplicitlySharedDataPointer::operator==(const QExplicitlySharedDataPointer<T>& other) const
+/*! \fn template <class T> bool QExplicitlySharedDataPointer<T>::operator==(const QExplicitlySharedDataPointer<T>& other) const
Returns \c true if \a other and \e this have the same \e{d pointer}.
*/
/*!
- \fn QExplicitlySharedDataPointer<T> &QExplicitlySharedDataPointer::operator=(QExplicitlySharedDataPointer<T> &&other)
+ \fn template <class T> QExplicitlySharedDataPointer<T> &QExplicitlySharedDataPointer<T>::operator=(QExplicitlySharedDataPointer<T> &&other)
Move-assigns \a other to this QExplicitlySharedDataPointer instance.
\since 5.2
*/
-/*! \fn bool QExplicitlySharedDataPointer::operator==(const T* ptr) const
+/*! \fn template <class T> bool QExplicitlySharedDataPointer<T>::operator==(const T* ptr) const
Returns \c true if the \e{d pointer} of \e this is \a ptr.
*/
-/*! \fn bool QExplicitlySharedDataPointer::operator!=(const QExplicitlySharedDataPointer<T>& other) const
+/*! \fn template <class T> bool QExplicitlySharedDataPointer<T>::operator!=(const QExplicitlySharedDataPointer<T>& other) const
Returns \c true if \a other and \e this do \e not have the same
\e{d pointer}.
*/
-/*! \fn bool QExplicitlySharedDataPointer::operator!=(const T* ptr) const
+/*! \fn template <class T> bool QExplicitlySharedDataPointer<T>::operator!=(const T* ptr) const
Returns \c true if the \e{d pointer} of \e this is \e not \a ptr.
*/
-/*! \fn QExplicitlySharedDataPointer::QExplicitlySharedDataPointer()
+/*! \fn template <class T> QExplicitlySharedDataPointer<T>::QExplicitlySharedDataPointer()
Constructs a QExplicitlySharedDataPointer initialized with a null
\e{d pointer}.
*/
-/*! \fn QExplicitlySharedDataPointer::~QExplicitlySharedDataPointer()
+/*! \fn template <class T> QExplicitlySharedDataPointer<T>::~QExplicitlySharedDataPointer()
Decrements the reference count of the shared data object.
If the reference count becomes 0, the shared data object
is deleted. \e This is then destroyed.
*/
/*!
- \fn QExplicitlySharedDataPointer::QExplicitlySharedDataPointer(QExplicitlySharedDataPointer &&o)
+ \fn template <class T> QExplicitlySharedDataPointer<T>::QExplicitlySharedDataPointer(QExplicitlySharedDataPointer &&o)
Move-constructs a QExplicitlySharedDataPointer instance, making it point at the same
object that \a o was pointing to.
@@ -521,24 +521,24 @@ QT_BEGIN_NAMESPACE
\since 5.2
*/
-/*! \fn QExplicitlySharedDataPointer::QExplicitlySharedDataPointer(T* sharedData)
+/*! \fn template <class T> QExplicitlySharedDataPointer<T>::QExplicitlySharedDataPointer(T* data)
Constructs a QExplicitlySharedDataPointer with \e{d pointer}
- set to \a sharedData and increments \a{sharedData}'s reference
+ set to \a data and increments \a{data}'s reference
count.
*/
-/*! \fn QExplicitlySharedDataPointer::QExplicitlySharedDataPointer(const QExplicitlySharedDataPointer<T>& other)
+/*! \fn template <class T> QExplicitlySharedDataPointer<T>::QExplicitlySharedDataPointer(const QExplicitlySharedDataPointer<T>& o)
This standard copy constructor sets the \e {d pointer} of \e this to
- the \e {d pointer} in \a other and increments the reference count of
+ the \e {d pointer} in \a o and increments the reference count of
the shared data object.
*/
-/*! \fn QExplicitlySharedDataPointer::QExplicitlySharedDataPointer(const QExplicitlySharedDataPointer<X>& other)
- This copy constructor is different in that it allows \a other to be
+/*! \fn template <class T> template <class X> QExplicitlySharedDataPointer<T>::QExplicitlySharedDataPointer(const QExplicitlySharedDataPointer<X>& o)
+ This copy constructor is different in that it allows \a o to be
a different type of explicitly shared data pointer but one that has
a compatible shared data object.
- By default, the \e{d pointer} of \a other (of type \c{X *}) gets
+ By default, the \e{d pointer} of \a o (of type \c{X *}) gets
implicitly converted to the type \c{T *}; the result of this
conversion is set as the \e{d pointer} of \e{this}, and the
reference count of the shared data object is incremented.
@@ -546,7 +546,7 @@ QT_BEGIN_NAMESPACE
However, if the macro
\c{QT_ENABLE_QEXPLICITLYSHAREDDATAPOINTER_STATICCAST} is defined
before including the \c{QExplicitlySharedDataPointer} header, then
- the \e{d pointer} of \a other undergoes a \c{static_cast} to the
+ the \e{d pointer} of \a o undergoes a \c{static_cast} to the
type \c{T *}. The result of the cast is then set as the
\e{d pointer} of \e{this}, and the reference count of the shared data
object is incremented.
@@ -566,39 +566,39 @@ QT_BEGIN_NAMESPACE
compile without modifications.
*/
-/*! \fn QExplicitlySharedDataPointer<T>& QExplicitlySharedDataPointer::operator=(const QExplicitlySharedDataPointer<T>& other)
+/*! \fn template <class T> QExplicitlySharedDataPointer<T>& QExplicitlySharedDataPointer<T>::operator=(const QExplicitlySharedDataPointer<T>& o)
Sets the \e{d pointer} of \e this to the \e{d pointer} of
- \a other and increments the reference count of the shared
+ \a o and increments the reference count of the shared
data object. The reference count of the old shared data
object of \e this is decremented. If the reference count
of the old shared data object becomes 0, the old shared
data object is deleted.
*/
-/*! \fn QExplicitlySharedDataPointer& QExplicitlySharedDataPointer::operator=(T* sharedData)
- Sets the \e{d pointer} of \e this to \a sharedData and
- increments \a{sharedData}'s reference count. The reference
+/*! \fn template <class T> QExplicitlySharedDataPointer& QExplicitlySharedDataPointer<T>::operator=(T* o)
+ Sets the \e{d pointer} of \e this to \a o and
+ increments \a{o}'s reference count. The reference
count of the old shared data object of \e this is decremented.
If the reference count of the old shared data object becomes
0, the old shared data object is deleted.
*/
-/*! \fn void QExplicitlySharedDataPointer::reset()
+/*! \fn template <class T> void QExplicitlySharedDataPointer<T>::reset()
Resets \e this to be null. i.e., this function sets the
\e{d pointer} of \e this to 0, but first it decrements
the reference count of the shared data object and deletes
the shared data object if the reference count became 0.
*/
-/*! \fn QExplicitlySharedDataPointer::operator bool () const
+/*! \fn template <class T> QExplicitlySharedDataPointer<T>::operator bool () const
Returns \c true if the \e{d pointer} of \e this is \e not null.
*/
-/*! \fn bool QExplicitlySharedDataPointer::operator!() const
+/*! \fn template <class T> bool QExplicitlySharedDataPointer<T>::operator!() const
Returns \c true if the \e{d pointer} of \e this is null.
*/
-/*! \fn void QExplicitlySharedDataPointer::detach()
+/*! \fn template <class T> void QExplicitlySharedDataPointer<T>::detach()
If the shared data object's reference count is greater than 1, this
function creates a deep copy of the shared data object and sets the
\e{d pointer} of \e this to the copy.
@@ -610,7 +610,7 @@ QT_BEGIN_NAMESPACE
everywhere in your code, consider using QSharedDataPointer instead.
*/
-/*! \fn T *QExplicitlySharedDataPointer::clone()
+/*! \fn template <class T> T *QExplicitlySharedDataPointer<T>::clone()
\since 4.5
Creates and returns a deep copy of the current data. This function
@@ -618,7 +618,7 @@ QT_BEGIN_NAMESPACE
order to create the new copy. This function uses the \e {operator
new} and calls the copy constructor of the type T.
- See QSharedDataPointer::clone() for an explanation of how to use it.
+ See QSharedDataPointer<T>::clone() for an explanation of how to use it.
*/
/*!
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..756e7bb59b 100644
--- a/src/corelib/tools/qsharedpointer.cpp
+++ b/src/corelib/tools/qsharedpointer.cpp
@@ -429,20 +429,20 @@
*/
/*!
- \fn QSharedPointer::QSharedPointer()
+ \fn template <class T> QSharedPointer<T>::QSharedPointer()
Creates a QSharedPointer that points to null (0).
*/
/*!
- \fn QSharedPointer::~QSharedPointer()
+ \fn template <class T> QSharedPointer<T>::~QSharedPointer()
Destroys this QSharedPointer object. If it is the last reference to
the pointer stored, this will delete the pointer as well.
*/
/*!
- \fn QSharedPointer::QSharedPointer(X *ptr)
+ \fn template <class T> template <typename X> QSharedPointer<T>::QSharedPointer(X *ptr)
Creates a QSharedPointer that points to \a ptr. The pointer \a ptr
becomes managed by this QSharedPointer and must not be passed to
@@ -455,13 +455,13 @@
*/
/*!
- \fn QSharedPointer::QSharedPointer(X *ptr, Deleter deleter)
+ \fn template <class T> template <typename X, typename Deleter> QSharedPointer<T>::QSharedPointer(X *ptr, Deleter d)
Creates a QSharedPointer that points to \a ptr. The pointer \a ptr
becomes managed by this QSharedPointer and must not be passed to
another QSharedPointer object or deleted outside this object.
- The \a deleter parameter specifies the custom deleter for this
+ The deleter parameter \a d specifies the custom deleter for this
object. The custom deleter is called, instead of the operator delete(),
when the strong reference count drops to 0. This is useful,
for instance, for calling \l {QObject::}{deleteLater()} on a QObject instead:
@@ -495,7 +495,7 @@
*/
/*!
- \fn QSharedPointer::QSharedPointer(std::nullptr_t)
+ \fn template <class T> QSharedPointer<T>::QSharedPointer(std::nullptr_t)
\since 5.8
Creates a QSharedPointer that is null. This is equivalent to the
@@ -503,15 +503,19 @@
*/
/*!
- \fn QSharedPointer::QSharedPointer(std::nullptr_t, Deleter)
+ \fn template <class T> template <typename Deleter> QSharedPointer<T>::QSharedPointer(std::nullptr_t, Deleter d)
\since 5.8
Creates a QSharedPointer that is null. This is equivalent to the
QSharedPointer default constructor.
+
+ The deleter parameter \a d specifies the custom deleter for this
+ object. The custom deleter is called, instead of the operator
+ delete(), when the strong reference count drops to 0.
*/
/*!
- \fn QSharedPointer::QSharedPointer(const QSharedPointer<T> &other)
+ \fn template <class T> QSharedPointer<T>::QSharedPointer(const QSharedPointer<T> &other)
Creates a QSharedPointer object that shares \a other's pointer.
@@ -521,7 +525,7 @@
*/
/*!
- \fn QSharedPointer::QSharedPointer(const QWeakPointer<T> &other)
+ \fn template <class T> QSharedPointer<T>::QSharedPointer(const QWeakPointer<T> &other)
Creates a QSharedPointer by promoting the weak reference \a other
to strong reference and sharing its pointer.
@@ -534,7 +538,7 @@
*/
/*!
- \fn QSharedPointer &QSharedPointer::operator=(const QSharedPointer<T> &other)
+ \fn template <class T> QSharedPointer &QSharedPointer<T>::operator=(const QSharedPointer<T> &other)
Makes this object share \a other's pointer. The current pointer
reference is discarded and, if it was the last, the pointer will
@@ -546,7 +550,7 @@
*/
/*!
- \fn QSharedPointer &QSharedPointer::operator=(const QWeakPointer<T> &other)
+ \fn template <class T> QSharedPointer &QSharedPointer<T>::operator=(const QWeakPointer<T> &other)
Promotes \a other to a strong reference and makes this object
share a reference to the pointer referenced by it. The current pointer
@@ -559,7 +563,7 @@
*/
/*!
- \fn void QSharedPointer::swap(QSharedPointer<T> &other);
+ \fn template <class T> void QSharedPointer<T>::swap(QSharedPointer<T> &other);
\since 5.3
Swaps this shared pointer instance with \a other. This function is
@@ -567,7 +571,7 @@
*/
/*!
- \fn T *QSharedPointer::data() const
+ \fn template <class T> T *QSharedPointer<T>::data() const
Returns the value of the pointer referenced by this object.
@@ -577,7 +581,16 @@
*/
/*!
- \fn T &QSharedPointer::operator *() const
+ \fn T *QSharedPointer::get() const
+ \since 5.11
+
+ Same as data().
+
+ This function is provided for API compatibility with \c{std::shared_ptr}.
+*/
+
+/*!
+ \fn template <class T> T &QSharedPointer<T>::operator *() const
Provides access to the shared pointer's members.
@@ -585,7 +598,7 @@
*/
/*!
- \fn T *QSharedPointer::operator ->() const
+ \fn template <class T> T *QSharedPointer<T>::operator ->() const
Provides access to the shared pointer's members.
@@ -593,14 +606,14 @@
*/
/*!
- \fn bool QSharedPointer::isNull() const
+ \fn template <class T> bool QSharedPointer<T>::isNull() const
Returns \c true if this object is holding a reference to a null
pointer.
*/
/*!
- \fn QSharedPointer::operator bool() const
+ \fn template <class T> QSharedPointer<T>::operator bool() const
Returns \c true if this object is not null. This function is suitable
for use in \tt if-constructs, like:
@@ -613,7 +626,7 @@
*/
/*!
- \fn bool QSharedPointer::operator !() const
+ \fn template <class T> bool QSharedPointer<T>::operator !() const
Returns \c true if this object is null. This function is suitable
for use in \tt if-constructs, like:
@@ -626,7 +639,7 @@
*/
/*!
- \fn QSharedPointer<X> QSharedPointer::staticCast() const
+ \fn template <class T> template <class X> QSharedPointer<X> QSharedPointer<T>::staticCast() const
Performs a static cast from this pointer's type to \tt X and returns
a QSharedPointer that shares the reference. This function can be
@@ -641,7 +654,7 @@
*/
/*!
- \fn QSharedPointer<X> QSharedPointer::dynamicCast() const
+ \fn template <class T> template <class X> QSharedPointer<X> QSharedPointer<T>::dynamicCast() const
Performs a dynamic cast from this pointer's type to \tt X and
returns a QSharedPointer that shares the reference. If this
@@ -658,7 +671,7 @@
*/
/*!
- \fn QSharedPointer<X> QSharedPointer::constCast() const
+ \fn template <class T> template <class X> QSharedPointer<X> QSharedPointer<T>::constCast() const
Performs a \tt const_cast from this pointer's type to \tt X and returns
a QSharedPointer that shares the reference. This function can be
@@ -669,7 +682,7 @@
*/
/*!
- \fn QSharedPointer<X> QSharedPointer::objectCast() const
+ \fn template <class T> template <class X> QSharedPointer<X> QSharedPointer<T>::objectCast() const
\since 4.6
Performs a \l qobject_cast() from this pointer's type to \tt X and
@@ -687,7 +700,7 @@
*/
/*!
- \fn QSharedPointer<T> QSharedPointer::create()
+ \fn template <class T> QSharedPointer<T> QSharedPointer<T>::create()
\since 5.1
Creates a QSharedPointer object and allocates a new item of type \tt T. The
@@ -699,7 +712,7 @@
*/
/*!
- \fn QSharedPointer<T> QSharedPointer::create(...)
+ \fn template <class T> QSharedPointer<T> QSharedPointer<T>::create(...)
\overload
\since 5.1
@@ -724,7 +737,7 @@
*/
/*!
- \fn QWeakPointer<T> QSharedPointer::toWeakRef() const
+ \fn template <class T> QWeakPointer<T> QSharedPointer<T>::toWeakRef() const
Returns a weak reference object that shares the pointer referenced
by this object.
@@ -733,7 +746,7 @@
*/
/*!
- \fn void QSharedPointer::clear()
+ \fn template <class T> void QSharedPointer<T>::clear()
Clears this QSharedPointer object, dropping the reference that it
may have had to the pointer. If this was the last reference, then
@@ -741,14 +754,14 @@
*/
/*!
- \fn void QSharedPointer::reset()
+ \fn template <class T> void QSharedPointer<T>::reset()
\since 5.0
Same as clear(). For std::shared_ptr compatibility.
*/
/*!
- \fn void QSharedPointer::reset(T *t)
+ \fn template <class T> void QSharedPointer<T>::reset(T *t)
\since 5.0
Resets this QSharedPointer object to point to \a t
@@ -759,31 +772,31 @@
*/
/*!
- \fn void QSharedPointer::reset(T *t, Deleter deleter)
+ \fn template <class T> template <typename Deleter> void QSharedPointer<T>::reset(T *t, Deleter deleter)
\since 5.0
Resets this QSharedPointer object to point to \a t
- instead, with deleter \a deleter. Equivalent to:
+ instead, with the Deleter \a deleter. Equivalent to:
\code
QSharedPointer<T> other(t, deleter); this->swap(other);
\endcode
*/
/*!
- \fn QWeakPointer::QWeakPointer()
+ \fn template <class T> QWeakPointer<T>::QWeakPointer()
Creates a QWeakPointer that points to nothing.
*/
/*!
- \fn QWeakPointer::~QWeakPointer()
+ \fn template <class T> QWeakPointer<T>::~QWeakPointer()
Destroys this QWeakPointer object. The pointer referenced
by this object will not be deleted.
*/
/*!
- \fn QWeakPointer::QWeakPointer(const QWeakPointer<T> &other)
+ \fn template <class T> QWeakPointer<T>::QWeakPointer(const QWeakPointer<T> &other)
Creates a QWeakPointer that holds a weak reference to the
pointer referenced by \a other.
@@ -794,7 +807,7 @@
*/
/*!
- \fn QWeakPointer::QWeakPointer(const QSharedPointer<T> &other)
+ \fn template <class T> QWeakPointer<T>::QWeakPointer(const QSharedPointer<T> &other)
Creates a QWeakPointer that holds a weak reference to the
pointer referenced by \a other.
@@ -805,12 +818,12 @@
*/
/*!
- \fn QWeakPointer::QWeakPointer(const QObject *obj)
+ \fn template <class T> QWeakPointer<T>::QWeakPointer(const QObject *other)
\since 4.6
\deprecated
Creates a QWeakPointer that holds a weak reference directly to the
- QObject \a obj. This constructor is only available if the template type
+ QObject \a other. This constructor is only available if the template type
\tt T is QObject or derives from it (otherwise a compilation error will
result).
@@ -824,19 +837,19 @@
*/
/*!
- \fn QWeakPointer &QWeakPointer::operator=(const QObject *obj)
+ \fn template <class T> QWeakPointer &QWeakPointer<T>::operator=(const QObject *other)
\since 4.6
\deprecated
Makes this QWeakPointer hold a weak reference directly to the QObject
- \a obj. This function is only available if the template type \tt T is
+ \a other. This function is only available if the template type \tt T is
QObject or derives from it.
\sa QPointer
*/
/*!
- \fn QWeakPointer &QWeakPointer::operator=(const QWeakPointer<T> &other)
+ \fn template <class T> QWeakPointer &QWeakPointer<T>::operator=(const QWeakPointer<T> &other)
Makes this object share \a other's pointer. The current pointer
reference is discarded but is not deleted.
@@ -847,7 +860,7 @@
*/
/*!
- \fn QWeakPointer &QWeakPointer::operator=(const QSharedPointer<T> &other)
+ \fn template <class T> QWeakPointer &QWeakPointer<T>::operator=(const QSharedPointer<T> &other)
Makes this object share \a other's pointer. The current pointer
reference is discarded but is not deleted.
@@ -858,7 +871,7 @@
*/
/*!
- \fn void QWeakPointer::swap(QWeakPointer<T> &other)
+ \fn template <class T> void QWeakPointer<T>::swap(QWeakPointer<T> &other)
\since 5.4
Swaps this weak pointer instance with \a other. This function is
@@ -866,7 +879,7 @@
*/
/*!
- \fn bool QWeakPointer::isNull() const
+ \fn template <class T> bool QWeakPointer<T>::isNull() const
Returns \c true if this object is holding a reference to a null
pointer.
@@ -878,7 +891,7 @@
*/
/*!
- \fn QWeakPointer::operator bool() const
+ \fn template <class T> QWeakPointer<T>::operator bool() const
Returns \c true if this object is not null. This function is suitable
for use in \tt if-constructs, like:
@@ -896,7 +909,7 @@
*/
/*!
- \fn bool QWeakPointer::operator !() const
+ \fn template <class T> bool QWeakPointer<T>::operator !() const
Returns \c true if this object is null. This function is suitable
for use in \tt if-constructs, like:
@@ -914,7 +927,7 @@
*/
/*!
- \fn T *QWeakPointer::data() const
+ \fn template <class T> T *QWeakPointer<T>::data() const
\since 4.6
Returns the value of the pointer being tracked by this QWeakPointer,
@@ -956,7 +969,7 @@
*/
/*!
- \fn QSharedPointer<T> QWeakPointer::toStrongRef() const
+ \fn template <class T> QSharedPointer<T> QWeakPointer<T>::toStrongRef() const
Promotes this weak reference to a strong one and returns a
QSharedPointer object holding that reference. When promoting to
@@ -989,7 +1002,7 @@
*/
/*!
- \fn QSharedPointer<T> QWeakPointer::lock() const
+ \fn template <class T> QSharedPointer<T> QWeakPointer<T>::lock() const
\since 5.4
Same as toStrongRef().
@@ -998,14 +1011,14 @@
*/
/*!
- \fn void QWeakPointer::clear()
+ \fn template <class T> void QWeakPointer<T>::clear()
Clears this QWeakPointer object, dropping the reference that it
may have had to the pointer.
*/
/*!
- \fn QSharedPointer<T> QEnableSharedFromThis::sharedFromThis()
+ \fn template <class T> QSharedPointer<T> QEnableSharedFromThis<T>::sharedFromThis()
\since 5.4
If \c this (that is, the subclass instance invoking this method) is being
@@ -1014,7 +1027,7 @@
*/
/*!
- \fn QSharedPointer<const T> QEnableSharedFromThis::sharedFromThis() const
+ \fn template <class T> QSharedPointer<const T> QEnableSharedFromThis<T>::sharedFromThis() const
\overload
\since 5.4
@@ -1022,7 +1035,7 @@
*/
/*!
- \fn bool operator==(const QSharedPointer<T> &ptr1, const QSharedPointer<X> &ptr2)
+ \fn template <class T> template <class X> bool operator==(const QSharedPointer<T> &ptr1, const QSharedPointer<X> &ptr2)
\relates QSharedPointer
Returns \c true if the pointer referenced by \a ptr1 is the
@@ -1036,7 +1049,7 @@
*/
/*!
- \fn bool operator!=(const QSharedPointer<T> &ptr1, const QSharedPointer<X> &ptr2)
+ \fn template <class T> template <class X> bool operator!=(const QSharedPointer<T> &ptr1, const QSharedPointer<X> &ptr2)
\relates QSharedPointer
Returns \c true if the pointer referenced by \a ptr1 is not the
@@ -1050,7 +1063,7 @@
*/
/*!
- \fn bool operator==(const QSharedPointer<T> &ptr1, const X *ptr2)
+ \fn template <class T> template <class X> bool operator==(const QSharedPointer<T> &ptr1, const X *ptr2)
\relates QSharedPointer
Returns \c true if the pointer referenced by \a ptr1 is the
@@ -1064,7 +1077,7 @@
*/
/*!
- \fn bool operator!=(const QSharedPointer<T> &ptr1, const X *ptr2)
+ \fn template <class T> template <class X> bool operator!=(const QSharedPointer<T> &ptr1, const X *ptr2)
\relates QSharedPointer
Returns \c true if the pointer referenced by \a ptr1 is not the
@@ -1078,7 +1091,7 @@
*/
/*!
- \fn bool operator==(const T *ptr1, const QSharedPointer<X> &ptr2)
+ \fn template <class T> template <class X> bool operator==(const T *ptr1, const QSharedPointer<X> &ptr2)
\relates QSharedPointer
Returns \c true if the pointer \a ptr1 is the
@@ -1092,7 +1105,7 @@
*/
/*!
- \fn bool operator!=(const T *ptr1, const QSharedPointer<X> &ptr2)
+ \fn template <class T> template <class X> bool operator!=(const T *ptr1, const QSharedPointer<X> &ptr2)
\relates QSharedPointer
Returns \c true if the pointer \a ptr1 is not the
@@ -1106,7 +1119,7 @@
*/
/*!
- \fn bool operator==(const QSharedPointer<T> &ptr1, const QWeakPointer<X> &ptr2)
+ \fn template <class T> template <class X> bool operator==(const QSharedPointer<T> &ptr1, const QWeakPointer<X> &ptr2)
\relates QWeakPointer
Returns \c true if the pointer referenced by \a ptr1 is the
@@ -1120,7 +1133,7 @@
*/
/*!
- \fn bool operator!=(const QSharedPointer<T> &ptr1, const QWeakPointer<X> &ptr2)
+ \fn template <class T> template <class X> bool operator!=(const QSharedPointer<T> &ptr1, const QWeakPointer<X> &ptr2)
\relates QWeakPointer
Returns \c true if the pointer referenced by \a ptr1 is not the
@@ -1134,7 +1147,7 @@
*/
/*!
- \fn bool operator==(const QWeakPointer<T> &ptr1, const QSharedPointer<X> &ptr2)
+ \fn template <class T> template <class X> bool operator==(const QWeakPointer<T> &ptr1, const QSharedPointer<X> &ptr2)
\relates QWeakPointer
Returns \c true if the pointer referenced by \a ptr1 is the
@@ -1148,7 +1161,7 @@
*/
/*!
- \fn bool operator==(const QSharedPointer<T> &lhs, std::nullptr_t)
+ \fn template <class T> bool operator==(const QSharedPointer<T> &lhs, std::nullptr_t)
\relates QSharedPointer
\since 5.8
@@ -1158,7 +1171,7 @@
*/
/*!
- \fn bool operator==(std::nullptr_t, const QSharedPointer<T> &rhs)
+ \fn template <class T> bool operator==(std::nullptr_t, const QSharedPointer<T> &rhs)
\relates QSharedPointer
\since 5.8
@@ -1168,7 +1181,7 @@
*/
/*!
- \fn bool operator!=(const QSharedPointer<T> &lhs, std::nullptr_t)
+ \fn template <class T> bool operator!=(const QSharedPointer<T> &lhs, std::nullptr_t)
\relates QSharedPointer
\since 5.8
@@ -1179,7 +1192,7 @@
*/
/*!
- \fn bool operator!=(std::nullptr_t, const QSharedPointer<T> &rhs)
+ \fn template <class T> bool operator!=(std::nullptr_t, const QSharedPointer<T> &rhs)
\relates QSharedPointer
\since 5.8
@@ -1190,7 +1203,7 @@
*/
/*!
- \fn bool operator==(const QWeakPointer<T> &lhs, std::nullptr_t)
+ \fn template <class T> bool operator==(const QWeakPointer<T> &lhs, std::nullptr_t)
\relates QWeakPointer
\since 5.8
@@ -1200,7 +1213,7 @@
*/
/*!
- \fn bool operator==(std::nullptr_t, const QWeakPointer<T> &rhs)
+ \fn template <class T> bool operator==(std::nullptr_t, const QWeakPointer<T> &rhs)
\relates QWeakPointer
\since 5.8
@@ -1210,7 +1223,7 @@
*/
/*!
- \fn bool operator!=(const QWeakPointer<T> &lhs, std::nullptr_t)
+ \fn template <class T> bool operator!=(const QWeakPointer<T> &lhs, std::nullptr_t)
\relates QWeakPointer
\since 5.8
@@ -1221,7 +1234,7 @@
*/
/*!
- \fn bool operator!=(std::nullptr_t, const QWeakPointer<T> &rhs)
+ \fn template <class T> bool operator!=(std::nullptr_t, const QWeakPointer<T> &rhs)
\relates QWeakPointer
\since 5.8
@@ -1232,7 +1245,7 @@
*/
/*!
- \fn bool operator!=(const QWeakPointer<T> &ptr1, const QSharedPointer<X> &ptr2)
+ \fn template <class T> template <class X> bool operator!=(const QWeakPointer<T> &ptr1, const QSharedPointer<X> &ptr2)
\relates QWeakPointer
Returns \c true if the pointer referenced by \a ptr1 is not the
@@ -1246,7 +1259,7 @@
*/
/*!
- \fn QSharedPointer<X> qSharedPointerCast(const QSharedPointer<T> &other)
+ \fn template <class X> template <class T> QSharedPointer<X> qSharedPointerCast(const QSharedPointer<T> &other)
\relates QSharedPointer
Returns a shared pointer to the pointer held by \a other, cast to
@@ -1261,7 +1274,7 @@
*/
/*!
- \fn QSharedPointer<X> qSharedPointerCast(const QWeakPointer<T> &other)
+ \fn template <class X> template <class T> QSharedPointer<X> qSharedPointerCast(const QWeakPointer<T> &other)
\relates QSharedPointer
\relates QWeakPointer
@@ -1282,10 +1295,10 @@
*/
/*!
- \fn QSharedPointer<X> qSharedPointerDynamicCast(const QSharedPointer<T> &other)
+ \fn template <class X> template <class T> QSharedPointer<X> qSharedPointerDynamicCast(const QSharedPointer<T> &src)
\relates QSharedPointer
- Returns a shared pointer to the pointer held by \a other, using a
+ Returns a shared pointer to the pointer held by \a src, using a
dynamic cast to type \tt X to obtain an internal pointer of the
appropriate type. If the \tt dynamic_cast fails, the object
returned will be null.
@@ -1298,16 +1311,16 @@
*/
/*!
- \fn QSharedPointer<X> qSharedPointerDynamicCast(const QWeakPointer<T> &other)
+ \fn template <class X> template <class T> QSharedPointer<X> qSharedPointerDynamicCast(const QWeakPointer<T> &src)
\relates QSharedPointer
\relates QWeakPointer
- Returns a shared pointer to the pointer held by \a other, using a
+ Returns a shared pointer to the pointer held by \a src, using a
dynamic cast to type \tt X to obtain an internal pointer of the
appropriate type. If the \tt dynamic_cast fails, the object
returned will be null.
- The \a other object is converted first to a strong reference. If
+ The \a src object is converted first to a strong reference. If
that conversion fails (because the object it's pointing to has
already been deleted), this function also returns a null
QSharedPointer.
@@ -1320,10 +1333,10 @@
*/
/*!
- \fn QSharedPointer<X> qSharedPointerConstCast(const QSharedPointer<T> &other)
+ \fn template <class X> template <class T> QSharedPointer<X> qSharedPointerConstCast(const QSharedPointer<T> &src)
\relates QSharedPointer
- Returns a shared pointer to the pointer held by \a other, cast to
+ Returns a shared pointer to the pointer held by \a src, cast to
type \tt X. The types \tt T and \tt X must belong to one
hierarchy for the \tt const_cast to succeed. The \tt const and \tt
volatile differences between \tt T and \tt X are ignored.
@@ -1332,16 +1345,16 @@
*/
/*!
- \fn QSharedPointer<X> qSharedPointerConstCast(const QWeakPointer<T> &other)
+ \fn template <class X> template <class T> QSharedPointer<X> qSharedPointerConstCast(const QWeakPointer<T> &src)
\relates QSharedPointer
\relates QWeakPointer
- Returns a shared pointer to the pointer held by \a other, cast to
+ Returns a shared pointer to the pointer held by \a src, cast to
type \tt X. The types \tt T and \tt X must belong to one
hierarchy for the \tt const_cast to succeed. The \tt const and
\tt volatile differences between \tt T and \tt X are ignored.
- The \a other object is converted first to a strong reference. If
+ The \a src object is converted first to a strong reference. If
that conversion fails (because the object it's pointing to has
already been deleted), this function returns a null
QSharedPointer.
@@ -1350,13 +1363,13 @@
*/
/*!
- \fn QSharedPointer<X> qSharedPointerObjectCast(const QSharedPointer<T> &other)
+ \fn template <class X> template <class T> QSharedPointer<X> qSharedPointerObjectCast(const QSharedPointer<T> &src)
\relates QSharedPointer
\since 4.6
\brief The qSharedPointerObjectCast function is for casting a shared pointer.
- Returns a shared pointer to the pointer held by \a other, using a
+ Returns a shared pointer to the pointer held by \a src, using a
\l qobject_cast() to type \tt X to obtain an internal pointer of the
appropriate type. If the \tt qobject_cast fails, the object
returned will be null.
@@ -1369,19 +1382,19 @@
*/
/*!
- \fn QSharedPointer<X> qSharedPointerObjectCast(const QWeakPointer<T> &other)
+ \fn template <class X> template <class T> QSharedPointer<X> qSharedPointerObjectCast(const QWeakPointer<T> &src)
\relates QSharedPointer
\relates QWeakPointer
\since 4.6
\brief The qSharedPointerObjectCast function is for casting a shared pointer.
- Returns a shared pointer to the pointer held by \a other, using a
+ Returns a shared pointer to the pointer held by \a src, using a
\l qobject_cast() to type \tt X to obtain an internal pointer of the
appropriate type. If the \tt qobject_cast fails, the object
returned will be null.
- The \a other object is converted first to a strong reference. If
+ The \a src object is converted first to a strong reference. If
that conversion fails (because the object it's pointing to has
already been deleted), this function also returns a null
QSharedPointer.
@@ -1395,10 +1408,10 @@
/*!
- \fn QWeakPointer<X> qWeakPointerCast(const QWeakPointer<T> &other)
+ \fn template <class X> template <class T> QWeakPointer<X> qWeakPointerCast(const QWeakPointer<T> &src)
\relates QWeakPointer
- Returns a weak pointer to the pointer held by \a other, cast to
+ Returns a weak pointer to the pointer held by \a src, cast to
type \tt X. The types \tt T and \tt X must belong to one
hierarchy for the \tt static_cast to succeed.
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/qsimd_p.h b/src/corelib/tools/qsimd_p.h
index 181da4f7de..fafc3e37b0 100644
--- a/src/corelib/tools/qsimd_p.h
+++ b/src/corelib/tools/qsimd_p.h
@@ -53,7 +53,6 @@
//
#include <QtCore/private/qglobal_p.h>
-#include <qatomic.h>
/*
* qt_module_config.prf defines the QT_COMPILER_SUPPORTS_XXX macros.
@@ -165,11 +164,7 @@
# if !defined(__MIPS_DSPR2__) && defined(__mips_dspr2) && defined(Q_PROCESSOR_MIPS_32)
# define __MIPS_DSPR2__
# endif
-#elif (defined(Q_CC_INTEL) || defined(Q_CC_MSVC) \
- || (defined(Q_CC_GNU) && !defined(Q_CC_CLANG) && Q_CC_GNU >= 409) \
- || (defined(Q_CC_CLANG) && Q_CC_CLANG >= 308)) \
- && !defined(QT_BOOTSTRAPPED)
-# define QT_COMPILER_SUPPORTS_SIMD_ALWAYS
+#elif defined(Q_PROCESSOR_X86) && defined(QT_COMPILER_SUPPORTS_SIMD_ALWAYS)
# define QT_COMPILER_SUPPORTS_HERE(x) ((__ ## x ## __) || QT_COMPILER_SUPPORTS(x))
# if defined(Q_CC_GNU) && !defined(Q_CC_INTEL)
/* GCC requires attributes for a function */
@@ -333,8 +328,10 @@
# include <arm_acle.h>
#endif
-QT_BEGIN_NAMESPACE
+#ifdef __cplusplus
+#include <qatomic.h>
+QT_BEGIN_NAMESPACE
enum CPUFeatures {
#if defined(Q_PROCESSOR_ARM)
@@ -512,9 +509,11 @@ static inline quint64 qCpuFeatures()
#define ALIGNMENT_PROLOGUE_32BYTES(ptr, i, length) \
for (; i < static_cast<int>(qMin(static_cast<quintptr>(length), ((8 - ((reinterpret_cast<quintptr>(ptr) >> 2) & 0x7)) & 0x7))); ++i)
+QT_END_NAMESPACE
+
+#endif // __cplusplus
+
#define SIMD_EPILOGUE(i, length, max) \
for (int _i = 0; _i < max && i < length; ++i, ++_i)
-QT_END_NAMESPACE
-
#endif // QSIMD_P_H
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index e63f1ce253..8093a26f7d 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -4056,7 +4056,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);
}
/*!
@@ -4107,7 +4107,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);
}
/*!
@@ -4159,7 +4159,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..af1513442a 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);
@@ -675,8 +675,12 @@ public:
: d(fromAscii_helper(ch, N - 1))
{}
template <int N>
+ QString(char (&)[N]) = delete;
+ template <int N>
inline QString &operator=(const char (&ch)[N])
{ return (*this = fromUtf8(ch, N - 1)); }
+ template <int N>
+ QString &operator=(char (&)[N]) = delete;
#endif
#if !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII)
inline QT_ASCII_CAST_WARN QString(const char *ch)
@@ -1417,7 +1421,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 +1537,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 +1580,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.cpp b/src/corelib/tools/qtimezoneprivate.cpp
index e45dd48de0..1a5135f103 100644
--- a/src/corelib/tools/qtimezoneprivate.cpp
+++ b/src/corelib/tools/qtimezoneprivate.cpp
@@ -329,7 +329,7 @@ QTimeZonePrivate::Data QTimeZonePrivate::dataForLocalTime(qint64 forLocalMSecs,
// Only around the transition times might we need another.
Data tran = previousTransition(forLocalMSecs - sixteenHoursInMSecs);
Q_ASSERT(forLocalMSecs < 0 || // Pre-epoch TZ info may be unavailable
- forLocalMSecs >= tran.atMSecsSinceEpoch + tran.offsetFromUtc * 1000);
+ forLocalMSecs - tran.offsetFromUtc * 1000 >= tran.atMSecsSinceEpoch);
Data nextTran = nextTransition(tran.atMSecsSinceEpoch);
/*
Now walk those forward until they bracket forLocalMSecs with transitions.
@@ -363,7 +363,7 @@ QTimeZonePrivate::Data QTimeZonePrivate::dataForLocalTime(qint64 forLocalMSecs,
fail life's tricky.
*/
Q_ASSERT(forLocalMSecs < 0
- || forLocalMSecs > tran.atMSecsSinceEpoch + tran.offsetFromUtc * 1000);
+ || forLocalMSecs - tran.offsetFromUtc * 1000 > tran.atMSecsSinceEpoch);
const qint64 nextStart = nextTran.atMSecsSinceEpoch;
// Work out the UTC values it might make sense to return:
nextTran.atMSecsSinceEpoch = forLocalMSecs - nextTran.offsetFromUtc * 1000;
diff --git a/src/corelib/tools/qtimezoneprivate_p.h b/src/corelib/tools/qtimezoneprivate_p.h
index 74b79dce16..ca36f9d297 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,34 +406,33 @@ 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);
- QWinTransitionRule ruleForYear(int year) const;
QTimeZonePrivate::Data ruleToData(const QWinTransitionRule &rule, qint64 atMSecsSinceEpoch,
- QTimeZone::TimeType type) const;
+ QTimeZone::TimeType type, bool fakeDst = false) const;
QByteArray m_windowsId;
QString m_displayName;
@@ -444,7 +443,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 +456,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/qtimezoneprivate_win.cpp b/src/corelib/tools/qtimezoneprivate_win.cpp
index a50227d3cc..8bde07c710 100644
--- a/src/corelib/tools/qtimezoneprivate_win.cpp
+++ b/src/corelib/tools/qtimezoneprivate_win.cpp
@@ -92,9 +92,11 @@ typedef struct _REG_TZI_FORMAT
SYSTEMTIME DaylightDate;
} REG_TZI_FORMAT;
+namespace {
+
// Fast and reliable conversion from msecs to date for all values
// Adapted from QDateTime msecsToDate
-static QDate msecsToDate(qint64 msecs)
+QDate msecsToDate(qint64 msecs)
{
qint64 jd = JULIAN_DAY_FOR_EPOCH;
@@ -111,7 +113,7 @@ static QDate msecsToDate(qint64 msecs)
return QDate::fromJulianDay(jd);
}
-static bool equalSystemtime(const SYSTEMTIME &t1, const SYSTEMTIME &t2)
+bool equalSystemtime(const SYSTEMTIME &t1, const SYSTEMTIME &t2)
{
return (t1.wYear == t2.wYear
&& t1.wMonth == t2.wMonth
@@ -123,7 +125,7 @@ static bool equalSystemtime(const SYSTEMTIME &t1, const SYSTEMTIME &t2)
&& t1.wMilliseconds == t2.wMilliseconds);
}
-static bool equalTzi(const TIME_ZONE_INFORMATION &tzi1, const TIME_ZONE_INFORMATION &tzi2)
+bool equalTzi(const TIME_ZONE_INFORMATION &tzi1, const TIME_ZONE_INFORMATION &tzi2)
{
return(tzi1.Bias == tzi2.Bias
&& tzi1.StandardBias == tzi2.StandardBias
@@ -135,13 +137,13 @@ static bool equalTzi(const TIME_ZONE_INFORMATION &tzi1, const TIME_ZONE_INFORMAT
}
#ifdef QT_USE_REGISTRY_TIMEZONE
-static bool openRegistryKey(const QString &keyPath, HKEY *key)
+bool openRegistryKey(const QString &keyPath, HKEY *key)
{
return (RegOpenKeyEx(HKEY_LOCAL_MACHINE, (const wchar_t*)keyPath.utf16(), 0, KEY_READ, key)
== ERROR_SUCCESS);
}
-static QString readRegistryString(const HKEY &key, const wchar_t *value)
+QString readRegistryString(const HKEY &key, const wchar_t *value)
{
wchar_t buffer[MAX_PATH] = {0};
DWORD size = sizeof(wchar_t) * MAX_PATH;
@@ -149,7 +151,7 @@ static QString readRegistryString(const HKEY &key, const wchar_t *value)
return QString::fromWCharArray(buffer);
}
-static int readRegistryValue(const HKEY &key, const wchar_t *value)
+int readRegistryValue(const HKEY &key, const wchar_t *value)
{
DWORD buffer;
DWORD size = sizeof(buffer);
@@ -157,8 +159,8 @@ static int readRegistryValue(const HKEY &key, const wchar_t *value)
return buffer;
}
-static QWinTimeZonePrivate::QWinTransitionRule readRegistryRule(const HKEY &key,
- const wchar_t *value, bool *ok)
+QWinTimeZonePrivate::QWinTransitionRule readRegistryRule(const HKEY &key,
+ const wchar_t *value, bool *ok)
{
*ok = false;
QWinTimeZonePrivate::QWinTransitionRule rule;
@@ -176,7 +178,7 @@ static QWinTimeZonePrivate::QWinTransitionRule readRegistryRule(const HKEY &key,
return rule;
}
-static TIME_ZONE_INFORMATION getRegistryTzi(const QByteArray &windowsId, bool *ok)
+TIME_ZONE_INFORMATION getRegistryTzi(const QByteArray &windowsId, bool *ok)
{
*ok = false;
TIME_ZONE_INFORMATION tzi;
@@ -223,7 +225,7 @@ typedef QHash<QByteArray, QWinDynamicTimeZone> QWinRTTimeZoneHash;
Q_GLOBAL_STATIC(QWinRTTimeZoneHash, gTimeZones)
-static void enumerateTimeZones()
+void enumerateTimeZones()
{
DYNAMIC_TIME_ZONE_INFORMATION dtzInfo;
quint32 index = 0;
@@ -244,7 +246,7 @@ static void enumerateTimeZones()
}
}
-static DYNAMIC_TIME_ZONE_INFORMATION dynamicInfoForId(const QByteArray &windowsId)
+DYNAMIC_TIME_ZONE_INFORMATION dynamicInfoForId(const QByteArray &windowsId)
{
DYNAMIC_TIME_ZONE_INFORMATION dtzInfo;
quint32 index = 0;
@@ -259,9 +261,39 @@ static DYNAMIC_TIME_ZONE_INFORMATION dynamicInfoForId(const QByteArray &windowsI
}
return dtzInfo;
}
+
+QWinTimeZonePrivate::QWinTransitionRule
+readDynamicRule(DYNAMIC_TIME_ZONE_INFORMATION &dtzi, int year, bool *ok)
+{
+ TIME_ZONE_INFORMATION tzi;
+ QWinTimeZonePrivate::QWinTransitionRule rule;
+ *ok = GetTimeZoneInformationForYear(year, &dtzi, &tzi);
+ if (*ok) {
+ rule.startYear = 0;
+ rule.standardTimeBias = tzi.Bias + tzi.StandardBias;
+ rule.daylightTimeBias = tzi.Bias + tzi.DaylightBias - rule.standardTimeBias;
+ rule.standardTimeRule = tzi.StandardDate;
+ rule.daylightTimeRule = tzi.DaylightDate;
+ }
+ return rule;
+}
#endif // QT_USE_REGISTRY_TIMEZONE
-static QList<QByteArray> availableWindowsIds()
+bool isSameRule(const QWinTimeZonePrivate::QWinTransitionRule &last,
+ const QWinTimeZonePrivate::QWinTransitionRule &rule)
+{
+ // In particular, when this is true and either wYear is 0, so is the other;
+ // so if one rule is recurrent and they're equal, so is the other. If
+ // either rule *isn't* recurrent, it has non-0 wYear which shall be
+ // different from the other's. Note that we don't compare .startYear, since
+ // that will always be different.
+ return equalSystemtime(last.standardTimeRule, rule.standardTimeRule)
+ && equalSystemtime(last.daylightTimeRule, rule.daylightTimeRule)
+ && last.standardTimeBias == rule.standardTimeBias
+ && last.daylightTimeBias == rule.daylightTimeBias;
+}
+
+QList<QByteArray> availableWindowsIds()
{
#ifdef QT_USE_REGISTRY_TIMEZONE
// TODO Consider caching results in a global static, very unlikely to change.
@@ -288,7 +320,7 @@ static QList<QByteArray> availableWindowsIds()
#endif // QT_USE_REGISTRY_TIMEZONE
}
-static QByteArray windowsSystemZoneId()
+QByteArray windowsSystemZoneId()
{
#ifdef QT_USE_REGISTRY_TIMEZONE
// On Vista and later is held in the value TimeZoneKeyName in key currTzRegPath
@@ -322,66 +354,141 @@ static QByteArray windowsSystemZoneId()
return QTimeZonePrivate::utcQByteArray();
}
-static QDate calculateTransitionLocalDate(const SYSTEMTIME &rule, int year)
+QDate calculateTransitionLocalDate(const SYSTEMTIME &rule, int year)
{
// If month is 0 then there is no date
if (rule.wMonth == 0)
return QDate();
- SYSTEMTIME time = rule;
- // If the year isn't set, then the rule date is relative
- if (time.wYear == 0) {
- if (time.wDayOfWeek == 0)
- time.wDayOfWeek = 7;
- QDate date(year, time.wMonth, 1);
- int startDow = date.dayOfWeek();
- if (startDow <= time.wDayOfWeek)
- date = date.addDays(time.wDayOfWeek - startDow - 7);
- else
- date = date.addDays(time.wDayOfWeek - startDow);
- date = date.addDays(time.wDay * 7);
- while (date.month() != time.wMonth)
- date = date.addDays(-7);
- return date;
+ // Interpret SYSTEMTIME according to the slightly quirky rules in:
+ // https://msdn.microsoft.com/en-us/library/windows/desktop/ms725481(v=vs.85).aspx
+
+ // If the year is set, the rule gives an absolute date:
+ if (rule.wYear)
+ return QDate(rule.wYear, rule.wMonth, rule.wDay);
+
+ // Otherwise, the rule date is annual and relative:
+ const int dayOfWeek = rule.wDayOfWeek == 0 ? 7 : rule.wDayOfWeek;
+ QDate date(year, rule.wMonth, 1);
+ // How many days before was last dayOfWeek before target month ?
+ int adjust = dayOfWeek - date.dayOfWeek(); // -6 <= adjust < 7
+ if (adjust >= 0) // Ensure -7 <= adjust < 0:
+ adjust -= 7;
+ // Normally, wDay is day-within-month; but here it is 1 for the first
+ // of the given dayOfWeek in the month, through 4 for the fourth or ...
+ adjust += (rule.wDay < 1 ? 1 : rule.wDay > 4 ? 5 : rule.wDay) * 7;
+ date = date.addDays(adjust);
+ // ... 5 for the last; so back up by weeks to get within the month:
+ if (date.month() != rule.wMonth) {
+ Q_ASSERT(rule.wDay > 4);
+ // (Note that, with adjust < 0, date <= 28th of our target month
+ // is guaranteed when wDay <= 4, or after our first -7 here.)
+ date = date.addDays(-7);
+ Q_ASSERT(date.month() == rule.wMonth);
}
-
- // If the year is set then is an absolute date
- return QDate(time.wYear, time.wMonth, time.wDay);
+ return date;
}
// Converts a date/time value into msecs
-static inline qint64 timeToMSecs(const QDate &date, const QTime &time)
+inline qint64 timeToMSecs(const QDate &date, const QTime &time)
{
return ((date.toJulianDay() - JULIAN_DAY_FOR_EPOCH) * MSECS_PER_DAY)
+ time.msecsSinceStartOfDay();
}
-static void calculateTransitionsForYear(const QWinTimeZonePrivate::QWinTransitionRule &rule, int year,
- qint64 *stdMSecs, qint64 *dstMSecs)
-{
- // TODO Consider caching the calculated values
- // The local time in Daylight Time when switches to Standard Time
- QDate standardDate = calculateTransitionLocalDate(rule.standardTimeRule, year);
- QTime standardTime = QTime(rule.standardTimeRule.wHour, rule.standardTimeRule.wMinute,
- rule.standardTimeRule.wSecond);
- if (standardDate.isValid() && standardTime.isValid()) {
- *stdMSecs = timeToMSecs(standardDate, standardTime)
- + ((rule.standardTimeBias + rule.daylightTimeBias) * 60000);
- } else {
- *stdMSecs = QTimeZonePrivate::invalidMSecs();
+qint64 calculateTransitionForYear(const SYSTEMTIME &rule, int year, int bias)
+{
+ // TODO Consider caching the calculated values - i.e. replace SYSTEMTIME in
+ // WinTransitionRule; do this in init() once and store the results.
+ const QDate date = calculateTransitionLocalDate(rule, year);
+ const QTime time = QTime(rule.wHour, rule.wMinute, rule.wSecond);
+ if (date.isValid() && time.isValid())
+ return timeToMSecs(date, time) + bias * 60000;
+ return QTimeZonePrivate::invalidMSecs();
+}
+
+struct TransitionTimePair
+{
+ // Transition times after the epoch, in ms:
+ qint64 std, dst;
+ // If either is invalidMSecs(), which shall then be < the other, there is no
+ // DST and the other describes a change in actual standard offset.
+
+ TransitionTimePair(const QWinTimeZonePrivate::QWinTransitionRule &rule,
+ int year, int oldYearOffset)
+ // The local time in Daylight Time of the switch to Standard Time
+ : std(calculateTransitionForYear(rule.standardTimeRule, year,
+ rule.standardTimeBias + rule.daylightTimeBias)),
+ // The local time in Standard Time of the switch to Daylight Time
+ dst(calculateTransitionForYear(rule.daylightTimeRule, year, rule.standardTimeBias))
+ {
+ /*
+ Check for potential "fake DST", used by MS's APIs because the
+ TIME_ZONE_INFORMATION spec either expresses no transitions in the
+ year, or expresses a transition of each kind, even if standard time
+ did change in a year with no DST. We've seen year-start fake-DST
+ (whose offset matches prior standard offset, in which the previous
+ year ended); and conjecture that similar might be used at a year-end.
+ (This might be used for a southern-hemisphere zone, where the start of
+ the year usually is in DST, when applicable.) Note that, here, wDay
+ identifies an instance of a given day-of-week in the month, with 5
+ meaning last.
+
+ Either the alleged standardTimeRule or the alleged daylightTimeRule
+ may be faked; either way, the transition is actually a change to the
+ current standard offset; but the unfaked half of the rule contains the
+ useful bias data, so we have to go along with its lies.
+
+ Example: Russia/Moscow
+ Format: -bias +( -stdBias, stdDate | -dstBias, dstDate ) notes
+ Last year of DST, 2010: 180 +( 0, 0-10-5 3:0 | 60, 0-3-5 2:0 ) normal DST
+ Zone change in 2011: 180 +( 0, 0-1-1 0:0 | 60 0-3-5 2:0 ) fake DST at transition
+ Fixed standard in 2012: 240 +( 0, 0-0-0 0:0 | 60, 0-0-0 0:0 ) standard time years
+ Zone change in 2014: 180 +( 0, 0-10-5 2:0 | 60, 0-1-1 0:0 ) fake DST at year-start
+ The last of these is missing on Win7 VMs (too old to know about it).
+ */
+ if (rule.daylightTimeRule.wMonth == 1 && rule.daylightTimeRule.wDay == 1) {
+ // Fake "DST transition" at start of year producing the same offset as
+ // previous year ended in.
+ if (rule.standardTimeBias + rule.daylightTimeBias == oldYearOffset)
+ dst = QTimeZonePrivate::invalidMSecs();
+ } else if (rule.daylightTimeRule.wMonth == 12 && rule.daylightTimeRule.wDay > 3) {
+ // Similar, conjectured, for end of year, not changing offset.
+ if (rule.daylightTimeBias == 0)
+ dst = QTimeZonePrivate::invalidMSecs();
+ }
+ if (rule.standardTimeRule.wMonth == 1 && rule.standardTimeRule.wDay == 1) {
+ // Fake "transition out of DST" at start of year producing the same
+ // offset as previous year ended in.
+ if (rule.standardTimeBias == oldYearOffset)
+ std = QTimeZonePrivate::invalidMSecs();
+ } else if (rule.standardTimeRule.wMonth == 12 && rule.standardTimeRule.wDay > 3) {
+ // Similar, conjectured, for end of year, not changing offset.
+ if (rule.daylightTimeBias == 0)
+ std = QTimeZonePrivate::invalidMSecs();
+ }
}
- // The local time in Standard Time when switches to Daylight Time
- QDate daylightDate = calculateTransitionLocalDate(rule.daylightTimeRule, year);
- QTime daylightTime = QTime(rule.daylightTimeRule.wHour, rule.daylightTimeRule.wMinute,
- rule.daylightTimeRule.wSecond);
- if (daylightDate.isValid() && daylightTime.isValid())
- *dstMSecs = timeToMSecs(daylightDate, daylightTime) + (rule.standardTimeBias * 60000);
- else
- *dstMSecs = QTimeZonePrivate::invalidMSecs();
+ bool fakesDst() const
+ {
+ return std == QTimeZonePrivate::invalidMSecs()
+ || dst == QTimeZonePrivate::invalidMSecs();
+ }
+};
+
+int yearEndOffset(const QWinTimeZonePrivate::QWinTransitionRule &rule, int year)
+{
+ int offset = rule.standardTimeBias;
+ // Only needed to help another TransitionTimePair work out year + 1's start
+ // offset; and the oldYearOffset we use only affects an alleged transition
+ // at the *start* of this year, so it doesn't matter if we guess wrong here:
+ TransitionTimePair pair(rule, year, offset);
+ if (pair.dst > pair.std)
+ offset += rule.daylightTimeBias;
+ return offset;
}
-static QLocale::Country userCountry()
+QLocale::Country userCountry()
{
const GEOID id = GetUserGeoID(GEOCLASS_NATION);
wchar_t code[3];
@@ -390,6 +497,36 @@ static QLocale::Country userCountry()
: QLocale::AnyCountry;
}
+// Index of last rule in rules with .startYear <= year:
+int ruleIndexForYear(const QList<QWinTimeZonePrivate::QWinTransitionRule> &rules, int year)
+{
+ if (rules.last().startYear <= year)
+ return rules.count() - 1;
+ // We don't have a rule for before the first, but the first is the best we can offer:
+ if (rules.first().startYear > year)
+ return 0;
+
+ // Otherwise, use binary chop:
+ int lo = 0, hi = rules.count();
+ // invariant: rules[i].startYear <= year < rules[hi].startYear
+ // subject to treating rules[rules.count()] as "off the end of time"
+ while (lo + 1 < hi) {
+ const int mid = (lo + hi) / 2;
+ // lo + 2 <= hi, so lo + 1 <= mid <= hi - 1, so lo < mid < hi
+ // In particular, mid < rules.count()
+ const int midYear = rules.at(mid).startYear;
+ if (midYear > year)
+ hi = mid;
+ else if (midYear < year)
+ lo = mid;
+ else // No two rules have the same startYear:
+ return mid;
+ }
+ return lo;
+}
+
+} // anonymous namespace
+
// Create the system default time zone
QWinTimeZonePrivate::QWinTimeZonePrivate()
: QTimeZonePrivate()
@@ -430,6 +567,7 @@ void QWinTimeZonePrivate::init(const QByteArray &ianaId)
m_id = ianaId;
}
+ bool badMonth = false; // Only warn once per zone, if at all.
if (!m_windowsId.isEmpty()) {
#ifdef QT_USE_REGISTRY_TIMEZONE
// Open the base TZI for the time zone
@@ -453,16 +591,28 @@ void QWinTimeZonePrivate::init(const QByteArray &ianaId)
QWinTransitionRule rule = readRegistryRule(dynamicKey,
(LPCWSTR)QString::number(year).utf16(),
&ruleOk);
- rule.startYear = year;
- if (ruleOk)
+ if (ruleOk
+ // Don't repeat a recurrent rule:
+ && (m_tranRules.isEmpty()
+ || !isSameRule(m_tranRules.last(), rule))) {
+ if (!badMonth
+ && (rule.standardTimeRule.wMonth == 0)
+ != (rule.daylightTimeRule.wMonth == 0)) {
+ badMonth = true;
+ qWarning("MS registry TZ API violated its wMonth constraint;"
+ "this may cause mistakes for %s from %d",
+ ianaId.constData(), year);
+ }
+ rule.startYear = m_tranRules.isEmpty() ? MIN_YEAR : year;
m_tranRules.append(rule);
+ }
}
RegCloseKey(dynamicKey);
} else {
// No dynamic data so use the base data
bool ruleOk;
QWinTransitionRule rule = readRegistryRule(baseKey, L"TZI", &ruleOk);
- rule.startYear = 1970;
+ rule.startYear = MIN_YEAR;
if (ruleOk)
m_tranRules.append(rule);
}
@@ -479,20 +629,36 @@ void QWinTimeZonePrivate::init(const QByteArray &ianaId)
DWORD firstYear = 0;
DWORD lastYear = 0;
DYNAMIC_TIME_ZONE_INFORMATION dtzi = dynamicInfoForId(m_windowsId);
- GetDynamicTimeZoneInformationEffectiveYears(&dtzi, &firstYear, &lastYear);
- // If there is no dynamic information, you can still query for
- // year 0, which helps simplifying following part
- for (DWORD year = firstYear; year <= lastYear; ++year) {
- TIME_ZONE_INFORMATION tzi;
- if (!GetTimeZoneInformationForYear(year, &dtzi, &tzi))
- continue;
- QWinTransitionRule rule;
- rule.standardTimeBias = tzi.Bias + tzi.StandardBias;
- rule.daylightTimeBias = tzi.Bias + tzi.DaylightBias - rule.standardTimeBias;
- rule.standardTimeRule = tzi.StandardDate;
- rule.daylightTimeRule = tzi.DaylightDate;
- rule.startYear = year;
- m_tranRules.append(rule);
+ if (GetDynamicTimeZoneInformationEffectiveYears(&dtzi, &firstYear, &lastYear)
+ == ERROR_SUCCESS && firstYear < lastYear) {
+ for (DWORD year = firstYear; year <= lastYear; ++year) {
+ bool ok = false;
+ QWinTransitionRule rule = readDynamicRule(dtzi, year, &ok);
+ if (ok
+ // Don't repeat a recurrent rule
+ && (m_tranRules.isEmpty()
+ || !isSameRule(m_tranRules.last(), rule))) {
+ if (!badMonth
+ && (rule.standardTimeRule.wMonth == 0)
+ != (rule.daylightTimeRule.wMonth == 0)) {
+ badMonth = true;
+ qWarning("MS dynamic TZ API violated its wMonth constraint;"
+ "this may cause mistakes for %s from %d",
+ ianaId.constData(), year);
+ }
+ rule.startYear = m_tranRules.isEmpty() ? MIN_YEAR : year;
+ m_tranRules.append(rule);
+ }
+ }
+ } else {
+ // At least try to get the non-dynamic data:
+ dtzi.DynamicDaylightTimeDisabled = false;
+ bool ok = false;
+ QWinTransitionRule rule = readDynamicRule(dtzi, 1970, &ok);
+ if (ok) {
+ rule.startYear = MIN_YEAR;
+ m_tranRules.append(rule);
+ }
}
}
#endif // QT_USE_REGISTRY_TIMEZONE
@@ -519,7 +685,8 @@ QString QWinTimeZonePrivate::displayName(QTimeZone::TimeType timeType,
Q_UNUSED(locale);
if (nameType == QTimeZone::OffsetName) {
- QWinTransitionRule rule = ruleForYear(QDate::currentDate().year());
+ const QWinTransitionRule &rule =
+ m_tranRules.at(ruleIndexForYear(m_tranRules, QDate::currentDate().year()));
if (timeType == QTimeZone::DaylightTime)
return isoOffsetFormat((rule.standardTimeBias + rule.daylightTimeBias) * -60);
else
@@ -569,38 +736,41 @@ bool QWinTimeZonePrivate::isDaylightTime(qint64 atMSecsSinceEpoch) const
QTimeZonePrivate::Data QWinTimeZonePrivate::data(qint64 forMSecsSinceEpoch) const
{
- // Convert MSecs to year to get transitions for, assumes no transitions around 31 Dec/1 Jan
int year = msecsToDate(forMSecsSinceEpoch).year();
-
- qint64 first;
- qint64 second;
- qint64 next = maxMSecs();
- qint64 stdMSecs;
- qint64 dstMSecs;
- QWinTransitionRule rule;
- do {
- // Convert the transition rules into msecs for the year we want to try
- rule = ruleForYear(year);
- // If no transition rules to calculate then no DST, so just use rule for std
- if (rule.standardTimeRule.wMonth == 0 && rule.daylightTimeRule.wMonth == 0)
- break;
- calculateTransitionsForYear(rule, year, &stdMSecs, &dstMSecs);
- if (stdMSecs < dstMSecs) {
- first = stdMSecs;
- second = dstMSecs;
+ for (int ruleIndex = ruleIndexForYear(m_tranRules, year);
+ ruleIndex >= 0; --ruleIndex) {
+ const QWinTransitionRule &rule = m_tranRules.at(ruleIndex);
+ // Does this rule's period include any transition at all ?
+ if (rule.standardTimeRule.wMonth > 0 || rule.daylightTimeRule.wMonth > 0) {
+ const int endYear = qMax(rule.startYear, year - 1);
+ while (year >= endYear) {
+ const int newYearOffset = (year <= rule.startYear && ruleIndex > 0)
+ ? yearEndOffset(m_tranRules.at(ruleIndex - 1), year - 1)
+ : yearEndOffset(rule, year - 1);
+ const TransitionTimePair pair(rule, year, newYearOffset);
+ bool isDst = false;
+ if (pair.std != invalidMSecs() && pair.std <= forMSecsSinceEpoch) {
+ isDst = pair.std < pair.dst && pair.dst <= forMSecsSinceEpoch;
+ } else if (pair.dst != invalidMSecs() && pair.dst <= forMSecsSinceEpoch) {
+ isDst = true;
+ } else {
+ --year; // Try an earlier year for this rule (once).
+ continue;
+ }
+ return ruleToData(rule, forMSecsSinceEpoch,
+ isDst ? QTimeZone::DaylightTime : QTimeZone::StandardTime,
+ pair.fakesDst());
+ }
+ // Fell off start of rule, try previous rule.
} else {
- first = dstMSecs;
- second = stdMSecs;
+ // No transition, no DST, use the year's standard time.
+ return ruleToData(rule, forMSecsSinceEpoch, QTimeZone::StandardTime);
}
- if (forMSecsSinceEpoch >= second && second != invalidMSecs())
- next = second;
- else if (forMSecsSinceEpoch >= first && first != invalidMSecs())
- next = first;
- // If didn't fall in this year, try the previous
- --year;
- } while (next == maxMSecs() && year >= MIN_YEAR);
-
- return ruleToData(rule, forMSecsSinceEpoch, (next == dstMSecs) ? QTimeZone::DaylightTime : QTimeZone::StandardTime);
+ if (year >= rule.startYear)
+ year = rule.startYear - 1; // Seek last transition in new rule.
+ }
+ // We don't have relevant data :-(
+ return invalidData();
}
bool QWinTimeZonePrivate::hasTransitions() const
@@ -614,105 +784,89 @@ bool QWinTimeZonePrivate::hasTransitions() const
QTimeZonePrivate::Data QWinTimeZonePrivate::nextTransition(qint64 afterMSecsSinceEpoch) const
{
- // Convert MSecs to year to get transitions for, assumes no transitions around 31 Dec/1 Jan
int year = msecsToDate(afterMSecsSinceEpoch).year();
+ for (int ruleIndex = ruleIndexForYear(m_tranRules, year);
+ ruleIndex < m_tranRules.count(); ++ruleIndex) {
+ const QWinTransitionRule &rule = m_tranRules.at(ruleIndex);
+ // Does this rule's period include any transition at all ?
+ if (rule.standardTimeRule.wMonth > 0 || rule.daylightTimeRule.wMonth > 0) {
+ if (year < rule.startYear)
+ year = rule.startYear; // Seek first transition in this rule.
+ const int endYear = ruleIndex + 1 < m_tranRules.count()
+ ? qMin(m_tranRules.at(ruleIndex + 1).startYear, year + 2) : (year + 2);
+ int newYearOffset = (year <= rule.startYear && ruleIndex > 0)
+ ? yearEndOffset(m_tranRules.at(ruleIndex - 1), year - 1)
+ : yearEndOffset(rule, year - 1);
+ while (year < endYear) {
+ const TransitionTimePair pair(rule, year, newYearOffset);
+ bool isDst = false;
+ Q_ASSERT(invalidMSecs() <= afterMSecsSinceEpoch); // invalid is min qint64
+ if (pair.std > afterMSecsSinceEpoch) {
+ isDst = pair.std > pair.dst && pair.dst > afterMSecsSinceEpoch;
+ } else if (pair.dst > afterMSecsSinceEpoch) {
+ isDst = true;
+ } else {
+ newYearOffset = rule.standardTimeBias;
+ if (pair.dst > pair.std)
+ newYearOffset += rule.daylightTimeBias;
+ ++year; // Try a later year for this rule (once).
+ continue;
+ }
- QWinTransitionRule rule;
- // If the required year falls after the last rule start year and the last rule has no
- // valid future transition calculations then there is no next transition
- if (year > m_tranRules.last().startYear) {
- rule = ruleForYear(year);
- // If the rules have either a fixed year, or no month, then no future trans
- if (rule.standardTimeRule.wYear != 0 || rule.daylightTimeRule.wYear != 0
- || rule.standardTimeRule.wMonth == 0 || rule.daylightTimeRule.wMonth == 0) {
- return invalidData();
- }
+ if (isDst)
+ return ruleToData(rule, pair.dst, QTimeZone::DaylightTime, pair.fakesDst());
+ return ruleToData(rule, pair.std, QTimeZone::StandardTime, pair.fakesDst());
+ }
+ // Fell off end of rule, try next rule.
+ } // else: no transition during rule's period
}
-
- // Otherwise we have a valid rule for the required year that can be used
- // to calculate this year or next
- qint64 first;
- qint64 second;
- qint64 next = minMSecs();
- qint64 stdMSecs;
- qint64 dstMSecs;
- do {
- // Convert the transition rules into msecs for the year we want to try
- rule = ruleForYear(year);
- // If no transition rules to calculate then no next transition
- if (rule.standardTimeRule.wMonth == 0 && rule.daylightTimeRule.wMonth == 0)
- return invalidData();
- calculateTransitionsForYear(rule, year, &stdMSecs, &dstMSecs);
- // Find the first and second transition for the year
- if (stdMSecs < dstMSecs) {
- first = stdMSecs;
- second = dstMSecs;
- } else {
- first = dstMSecs;
- second = stdMSecs;
- }
- if (afterMSecsSinceEpoch < first)
- next = first;
- else if (afterMSecsSinceEpoch < second)
- next = second;
- // If didn't fall in this year, try the next
- ++year;
- } while (next == minMSecs() && year <= MAX_YEAR);
-
- if (next == minMSecs() || next == invalidMSecs())
- return invalidData();
-
- return ruleToData(rule, next, (next == dstMSecs) ? QTimeZone::DaylightTime : QTimeZone::StandardTime);
+ // Apparently no transition after the given time:
+ return invalidData();
}
QTimeZonePrivate::Data QWinTimeZonePrivate::previousTransition(qint64 beforeMSecsSinceEpoch) const
{
- // Convert MSecs to year to get transitions for, assumes no transitions around 31 Dec/1 Jan
- int year = msecsToDate(beforeMSecsSinceEpoch).year();
-
- QWinTransitionRule rule;
- // If the required year falls before the first rule start year and the first rule has no
- // valid transition calculations then there is no previous transition
- if (year < m_tranRules.first().startYear) {
- rule = ruleForYear(year);
- // If the rules have either a fixed year, or no month, then no previous trans
- if (rule.standardTimeRule.wYear != 0 || rule.daylightTimeRule.wYear != 0
- || rule.standardTimeRule.wMonth == 0 || rule.daylightTimeRule.wMonth == 0) {
- return invalidData();
- }
- }
-
- qint64 first;
- qint64 second;
- qint64 next = maxMSecs();
- qint64 stdMSecs;
- qint64 dstMSecs;
- do {
- // Convert the transition rules into msecs for the year we want to try
- rule = ruleForYear(year);
- // If no transition rules to calculate then no previous transition
- if (rule.standardTimeRule.wMonth == 0 && rule.daylightTimeRule.wMonth == 0)
- return invalidData();
- calculateTransitionsForYear(rule, year, &stdMSecs, &dstMSecs);
- if (stdMSecs < dstMSecs) {
- first = stdMSecs;
- second = dstMSecs;
- } else {
- first = dstMSecs;
- second = stdMSecs;
- }
- if (beforeMSecsSinceEpoch > second && second != invalidMSecs())
- next = second;
- else if (beforeMSecsSinceEpoch > first && first != invalidMSecs())
- next = first;
- // If didn't fall in this year, try the previous
- --year;
- } while (next == maxMSecs() && year >= MIN_YEAR);
-
- if (next == maxMSecs())
+ const qint64 startOfTime = invalidMSecs() + 1;
+ if (beforeMSecsSinceEpoch <= startOfTime)
return invalidData();
- return ruleToData(rule, next, (next == dstMSecs) ? QTimeZone::DaylightTime : QTimeZone::StandardTime);
+ int year = msecsToDate(beforeMSecsSinceEpoch).year();
+ for (int ruleIndex = ruleIndexForYear(m_tranRules, year);
+ ruleIndex >= 0; --ruleIndex) {
+ const QWinTransitionRule &rule = m_tranRules.at(ruleIndex);
+ // Does this rule's period include any transition at all ?
+ if (rule.standardTimeRule.wMonth > 0 || rule.daylightTimeRule.wMonth > 0) {
+ const int endYear = qMax(rule.startYear, year - 1);
+ while (year >= endYear) {
+ const int newYearOffset = (year <= rule.startYear && ruleIndex > 0)
+ ? yearEndOffset(m_tranRules.at(ruleIndex - 1), year - 1)
+ : yearEndOffset(rule, year - 1);
+ const TransitionTimePair pair(rule, year, newYearOffset);
+ bool isDst = false;
+ if (pair.std != invalidMSecs() && pair.std < beforeMSecsSinceEpoch) {
+ isDst = pair.std < pair.dst && pair.dst < beforeMSecsSinceEpoch;
+ } else if (pair.dst != invalidMSecs() && pair.dst < beforeMSecsSinceEpoch) {
+ isDst = true;
+ } else {
+ --year; // Try an earlier year for this rule (once).
+ continue;
+ }
+ if (isDst)
+ return ruleToData(rule, pair.dst, QTimeZone::DaylightTime, pair.fakesDst());
+ return ruleToData(rule, pair.std, QTimeZone::StandardTime, pair.fakesDst());
+ }
+ // Fell off start of rule, try previous rule.
+ } else if (ruleIndex == 0) {
+ // Treat a no-transition first rule as a transition at the start of
+ // time, so that a scan through all rules *does* see it as the first
+ // rule:
+ return ruleToData(rule, startOfTime, QTimeZone::StandardTime, false);
+ } // else: no transition during rule's period
+ if (year >= rule.startYear)
+ year = rule.startYear - 1; // Seek last transition in new rule
+ }
+ // Apparently no transition before the given time:
+ return invalidData();
}
QByteArray QWinTimeZonePrivate::systemTimeZoneId() const
@@ -744,23 +898,21 @@ QList<QByteArray> QWinTimeZonePrivate::availableTimeZoneIds() const
return result;
}
-QWinTimeZonePrivate::QWinTransitionRule QWinTimeZonePrivate::ruleForYear(int year) const
-{
- for (int i = m_tranRules.size() - 1; i >= 0; --i) {
- if (m_tranRules.at(i).startYear <= year)
- return m_tranRules.at(i);
- }
- return m_tranRules.at(0);
-}
-
QTimeZonePrivate::Data QWinTimeZonePrivate::ruleToData(const QWinTransitionRule &rule,
qint64 atMSecsSinceEpoch,
- QTimeZone::TimeType type) const
+ QTimeZone::TimeType type,
+ bool fakeDst) const
{
- QTimeZonePrivate::Data tran = QTimeZonePrivate::invalidData();
+ Data tran = invalidData();
tran.atMSecsSinceEpoch = atMSecsSinceEpoch;
tran.standardTimeOffset = rule.standardTimeBias * -60;
- if (type == QTimeZone::DaylightTime) {
+ if (fakeDst) {
+ tran.daylightTimeOffset = 0;
+ tran.abbreviation = m_standardName;
+ // Rule may claim we're in DST when it's actually a standard time change:
+ if (type == QTimeZone::DaylightTime)
+ tran.standardTimeOffset += rule.daylightTimeBias * -60;
+ } else if (type == QTimeZone::DaylightTime) {
tran.daylightTimeOffset = rule.daylightTimeBias * -60;
tran.abbreviation = m_daylightName;
} else {
diff --git a/src/corelib/tools/qvarlengtharray.qdoc b/src/corelib/tools/qvarlengtharray.qdoc
index be2bdeda07..7c63871ea9 100644
--- a/src/corelib/tools/qvarlengtharray.qdoc
+++ b/src/corelib/tools/qvarlengtharray.qdoc
@@ -90,7 +90,7 @@
\sa QVector, QList, QLinkedList
*/
-/*! \fn QVarLengthArray::QVarLengthArray(int size)
+/*! \fn template<class T, int Prealloc> QVarLengthArray<T, Prealloc>::QVarLengthArray(int size)
Constructs an array with an initial size of \a size elements.
@@ -101,7 +101,7 @@
*/
-/*! \fn QVarLengthArray::QVarLengthArray(std::initializer_list<T> args)
+/*! \fn template<class T, int Prealloc> QVarLengthArray<T, Prealloc>::QVarLengthArray(std::initializer_list<T> args)
\since 5.5
Constructs an array from the std::initializer_list given by \a args.
@@ -111,26 +111,26 @@
*/
-/*! \fn QVarLengthArray::~QVarLengthArray()
+/*! \fn template<class T, int Prealloc> QVarLengthArray<T, Prealloc>::~QVarLengthArray()
Destroys the array.
*/
-/*! \fn int QVarLengthArray::size() const
+/*! \fn template<class T, int Prealloc> int QVarLengthArray<T, Prealloc>::size() const
Returns the number of elements in the array.
\sa isEmpty(), resize()
*/
-/*! \fn int QVarLengthArray::count() const
+/*! \fn template<class T, int Prealloc> int QVarLengthArray<T, Prealloc>::count() const
Same as size().
\sa isEmpty(), resize()
*/
-/*! \fn int QVarLengthArray::length() const
+/*! \fn template<class T, int Prealloc> int QVarLengthArray<T, Prealloc>::length() const
\since 5.0
Same as size().
@@ -138,7 +138,7 @@
\sa isEmpty(), resize()
*/
-/*! \fn T& QVarLengthArray::first()
+/*! \fn template<class T, int Prealloc> T& QVarLengthArray<T, Prealloc>::first()
Returns a reference to the first item in the array. The array must
not be empty. If the array can be empty, check isEmpty() before
@@ -147,24 +147,24 @@
\sa last(), isEmpty()
*/
-/*! \fn const T& QVarLengthArray::first() const
+/*! \fn template<class T, int Prealloc> const T& QVarLengthArray<T, Prealloc>::first() const
\overload
*/
-/*! \fn T& QVarLengthArray::front()
+/*! \fn template<class T, int Prealloc> T& QVarLengthArray<T, Prealloc>::front()
\since 5.0
Same as first(). Provided for STL-compatibility.
*/
-/*! \fn const T& QVarLengthArray::front() const
+/*! \fn template<class T, int Prealloc> const T& QVarLengthArray<T, Prealloc>::front() const
\since 5.0
\overload
*/
-/*! \fn T& QVarLengthArray::last()
+/*! \fn template<class T, int Prealloc> T& QVarLengthArray<T, Prealloc>::last()
Returns a reference to the last item in the array. The array must
not be empty. If the array can be empty, check isEmpty() before
@@ -173,37 +173,37 @@
\sa first(), isEmpty()
*/
-/*! \fn const T& QVarLengthArray::last() const
+/*! \fn template<class T, int Prealloc> const T& QVarLengthArray<T, Prealloc>::last() const
\overload
*/
-/*! \fn T& QVarLengthArray::back()
+/*! \fn template<class T, int Prealloc> T& QVarLengthArray<T, Prealloc>::back()
\since 5.0
Same as last(). Provided for STL-compatibility.
*/
-/*! \fn const T& QVarLengthArray::back() const
+/*! \fn template<class T, int Prealloc> const T& QVarLengthArray<T, Prealloc>::back() const
\since 5.0
\overload
*/
-/*! \fn void QVarLengthArray::shrink_to_fit()
+/*! \fn template<class T, int Prealloc> void QVarLengthArray<T, Prealloc>::shrink_to_fit()
\since 5.10
Same as squeeze(). Provided for STL-compatibility.
*/
-/*! \fn bool QVarLengthArray::isEmpty() const
+/*! \fn template<class T, int Prealloc> bool QVarLengthArray<T, Prealloc>::isEmpty() const
Returns \c true if the array has size 0; otherwise returns \c false.
\sa size(), resize()
*/
-/*! \fn bool QVarLengthArray::empty() const
+/*! \fn template<class T, int Prealloc> bool QVarLengthArray<T, Prealloc>::empty() const
\since 5.0
Returns \c true if the array has size 0; otherwise returns \c false.
@@ -211,14 +211,14 @@
Same as isEmpty(). Provided for STL-compatibility.
*/
-/*! \fn void QVarLengthArray::clear()
+/*! \fn template<class T, int Prealloc> void QVarLengthArray<T, Prealloc>::clear()
Removes all the elements from the array.
Same as resize(0).
*/
-/*! \fn void QVarLengthArray::resize(int size)
+/*! \fn template<class T, int Prealloc> void QVarLengthArray<T, Prealloc>::resize(int size)
Sets the size of the array to \a size. If \a size is greater than
the current size, elements are added to the end. If \a size is
@@ -232,7 +232,7 @@
\sa size(), squeeze()
*/
-/*! \fn int QVarLengthArray::capacity() const
+/*! \fn template<class T, int Prealloc> int QVarLengthArray<T, Prealloc>::capacity() const
Returns the maximum number of elements that can be stored in the
array without forcing a reallocation.
@@ -245,7 +245,7 @@
\sa reserve(), squeeze()
*/
-/*! \fn void QVarLengthArray::reserve(int size)
+/*! \fn template<class T, int Prealloc> void QVarLengthArray<T, Prealloc>::reserve(int size)
Attempts to allocate memory for at least \a size elements. If you
know in advance how large the array can get, you can call this
@@ -262,7 +262,7 @@
\sa capacity(), squeeze()
*/
-/*! \fn void QVarLengthArray::squeeze()
+/*! \fn template<class T, int Prealloc> void QVarLengthArray<T, Prealloc>::squeeze()
\since 5.1
Releases any memory not required to store the items.
@@ -276,7 +276,7 @@
\sa reserve(), capacity(), resize()
*/
-/*! \fn T &QVarLengthArray::operator[](int i)
+/*! \fn template<class T, int Prealloc> T &QVarLengthArray<T, Prealloc>::operator[](int i)
Returns a reference to the item at index position \a i.
@@ -286,14 +286,14 @@
\sa data(), at()
*/
-/*! \fn const T &QVarLengthArray::operator[](int i) const
+/*! \fn template<class T, int Prealloc> const T &QVarLengthArray<T, Prealloc>::operator[](int i) const
\overload
*/
/*!
- \fn void QVarLengthArray::append(const T &t)
+ \fn template<class T, int Prealloc> void QVarLengthArray<T, Prealloc>::append(const T &t)
Appends item \a t to the array, extending the array if necessary.
@@ -301,7 +301,7 @@
*/
/*!
- \fn void QVarLengthArray::push_back(const T &t)
+ \fn template<class T, int Prealloc> void QVarLengthArray<T, Prealloc>::push_back(const T &t)
\since 5.0
Appends item \a t to the array, extending the array if necessary.
@@ -309,7 +309,7 @@
*/
/*!
- \fn void QVarLengthArray::append(T &&t)
+ \fn template<class T, int Prealloc> void QVarLengthArray<T, Prealloc>::append(T &&t)
\overload append
\since 5.9
@@ -323,7 +323,7 @@
*/
/*!
- \fn void QVarLengthArray::push_back(T &&t)
+ \fn template<class T, int Prealloc> void QVarLengthArray<T, Prealloc>::push_back(T &&t)
\overload push_back
\since 5.9
@@ -337,7 +337,7 @@
*/
/*!
- \fn inline void QVarLengthArray::removeLast()
+ \fn template<class T, int Prealloc> inline void QVarLengthArray<T, Prealloc>::removeLast()
\since 4.5
Decreases the size of the array by one. The allocated size is not changed.
@@ -346,20 +346,20 @@
*/
/*!
- \fn void QVarLengthArray::pop_back()
+ \fn template<class T, int Prealloc> void QVarLengthArray<T, Prealloc>::pop_back()
\since 5.0
Same as removeLast(). Provided for STL-compatibility.
*/
/*!
- \fn void QVarLengthArray::append(const T *buf, int size)
+ \fn template<class T, int Prealloc> void QVarLengthArray<T, Prealloc>::append(const T *buf, int size)
Appends \a size amount of items referenced by \a buf to this array.
*/
-/*! \fn T *QVarLengthArray::data()
+/*! \fn template<class T, int Prealloc> T *QVarLengthArray<T, Prealloc>::data()
Returns a pointer to the data stored in the array. The pointer can
be used to access and modify the items in the array.
@@ -375,12 +375,12 @@
\sa constData(), operator[]()
*/
-/*! \fn const T *QVarLengthArray::data() const
+/*! \fn template<class T, int Prealloc> const T *QVarLengthArray<T, Prealloc>::data() const
\overload
*/
-/*! \fn const T *QVarLengthArray::constData() const
+/*! \fn template<class T, int Prealloc> const T *QVarLengthArray<T, Prealloc>::constData() const
Returns a const pointer to the data stored in the array. The
pointer can be used to access the items in the array. The
@@ -392,11 +392,11 @@
\sa data(), operator[]()
*/
-/*! \fn QVarLengthArray<T, Prealloc> &QVarLengthArray::operator=(const QVarLengthArray<T, Prealloc> &other)
+/*! \fn template<class T, int Prealloc> QVarLengthArray<T, Prealloc> &QVarLengthArray<T, Prealloc>::operator=(const QVarLengthArray<T, Prealloc> &other)
Assigns \a other to this array and returns a reference to this array.
*/
-/*! \fn QVarLengthArray<T, Prealloc> &QVarLengthArray::operator=(std::initializer_list<T> list)
+/*! \fn template<class T, int Prealloc> QVarLengthArray<T, Prealloc> &QVarLengthArray<T, Prealloc>::operator=(std::initializer_list<T> list)
\since 5.5
Assigns the values of \a list to this array, and returns a reference to this array.
@@ -405,11 +405,11 @@
lists.
*/
-/*! \fn QVarLengthArray::QVarLengthArray(const QVarLengthArray<T, Prealloc> &other)
+/*! \fn template<class T, int Prealloc> QVarLengthArray<T, Prealloc>::QVarLengthArray(const QVarLengthArray<T, Prealloc> &other)
Constructs a copy of \a other.
*/
-/*! \fn const T &QVarLengthArray::at(int i) const
+/*! \fn template<class T, int Prealloc> const T &QVarLengthArray<T, Prealloc>::at(int i) const
Returns a reference to the item at index position \a i.
@@ -419,7 +419,7 @@
\sa value(), operator[]()
*/
-/*! \fn T QVarLengthArray::value(int i) const
+/*! \fn template<class T, int Prealloc> T QVarLengthArray<T, Prealloc>::value(int i) const
Returns the value at index position \a i.
@@ -431,7 +431,7 @@
\sa at(), operator[]()
*/
-/*! \fn T QVarLengthArray::value(int i, const T &defaultValue) const
+/*! \fn template<class T, int Prealloc> T QVarLengthArray<T, Prealloc>::value(int i, const T &defaultValue) const
\overload
@@ -516,7 +516,7 @@
Typedef for \c{std::reverse_iterator<T*>}. Provided for STL compatibility.
*/
-/*! \fn void QVarLengthArray::prepend(const T &value)
+/*! \fn template<class T, int Prealloc> void QVarLengthArray<T, Prealloc>::prepend(const T &value)
\since 4.8
Inserts \a value at the beginning of the array.
@@ -533,7 +533,7 @@
\sa append(), insert()
*/
-/*! \fn void QVarLengthArray::replace(int i, const T &value)
+/*! \fn template<class T, int Prealloc> void QVarLengthArray<T, Prealloc>::replace(int i, const T &value)
\since 4.8
Replaces the item at index position \a i with \a value.
@@ -544,7 +544,7 @@
\sa operator[](), remove()
*/
-/*! \fn void QVarLengthArray::remove(int i)
+/*! \fn template<class T, int Prealloc> void QVarLengthArray<T, Prealloc>::remove(int i)
\overload
\since 4.8
@@ -554,7 +554,7 @@
\sa insert(), replace()
*/
-/*! \fn void QVarLengthArray::remove(int i, int count)
+/*! \fn template<class T, int Prealloc> void QVarLengthArray<T, Prealloc>::remove(int i, int count)
\overload
\since 4.8
@@ -565,7 +565,7 @@
\sa insert(), replace()
*/
-/*! \fn QVarLengthArray::iterator QVarLengthArray::begin()
+/*! \fn template<class T, int Prealloc> QVarLengthArray<T, Prealloc>::iterator QVarLengthArray<T, Prealloc>::begin()
\since 4.8
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the first item in
@@ -574,12 +574,12 @@
\sa constBegin(), end()
*/
-/*! \fn QVarLengthArray::const_iterator QVarLengthArray::begin() const
+/*! \fn template<class T, int Prealloc> QVarLengthArray<T, Prealloc>::const_iterator QVarLengthArray<T, Prealloc>::begin() const
\since 4.8
\overload
*/
-/*! \fn QVarLengthArray::const_iterator QVarLengthArray::cbegin() const
+/*! \fn template<class T, int Prealloc> QVarLengthArray<T, Prealloc>::const_iterator QVarLengthArray<T, Prealloc>::cbegin() const
\since 5.0
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first item
@@ -588,7 +588,7 @@
\sa begin(), cend()
*/
-/*! \fn QVarLengthArray::const_iterator QVarLengthArray::constBegin() const
+/*! \fn template<class T, int Prealloc> QVarLengthArray<T, Prealloc>::const_iterator QVarLengthArray<T, Prealloc>::constBegin() const
\since 4.8
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first item
@@ -597,7 +597,7 @@
\sa begin(), constEnd()
*/
-/*! \fn QVarLengthArray::iterator QVarLengthArray::end()
+/*! \fn template<class T, int Prealloc> QVarLengthArray<T, Prealloc>::iterator QVarLengthArray<T, Prealloc>::end()
\since 4.8
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item
@@ -606,13 +606,13 @@
\sa begin(), constEnd()
*/
-/*! \fn QVarLengthArray::const_iterator QVarLengthArray::end() const
+/*! \fn template<class T, int Prealloc> QVarLengthArray<T, Prealloc>::const_iterator QVarLengthArray<T, Prealloc>::end() const
\since 4.8
\overload
*/
-/*! \fn QVarLengthArray::const_iterator QVarLengthArray::cend() const
+/*! \fn template<class T, int Prealloc> QVarLengthArray<T, Prealloc>::const_iterator QVarLengthArray<T, Prealloc>::cend() const
\since 5.0
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary
@@ -621,7 +621,7 @@
\sa cbegin(), end()
*/
-/*! \fn QVarLengthArray::const_iterator QVarLengthArray::constEnd() const
+/*! \fn template<class T, int Prealloc> QVarLengthArray<T, Prealloc>::const_iterator QVarLengthArray<T, Prealloc>::constEnd() const
\since 4.8
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary
@@ -630,7 +630,7 @@
\sa constBegin(), end()
*/
-/*! \fn QVarLengthArray::reverse_iterator QVarLengthArray::rbegin()
+/*! \fn template<class T, int Prealloc> QVarLengthArray<T, Prealloc>::reverse_iterator QVarLengthArray<T, Prealloc>::rbegin()
\since 5.6
Returns a \l{STL-style iterators}{STL-style} reverse iterator pointing to the first
@@ -639,12 +639,12 @@
\sa begin(), crbegin(), rend()
*/
-/*! \fn QVarLengthArray::const_reverse_iterator QVarLengthArray::rbegin() const
+/*! \fn template<class T, int Prealloc> QVarLengthArray<T, Prealloc>::const_reverse_iterator QVarLengthArray<T, Prealloc>::rbegin() const
\since 5.6
\overload
*/
-/*! \fn QVarLengthArray::const_reverse_iterator QVarLengthArray::crbegin() const
+/*! \fn template<class T, int Prealloc> QVarLengthArray<T, Prealloc>::const_reverse_iterator QVarLengthArray<T, Prealloc>::crbegin() const
\since 5.6
Returns a const \l{STL-style iterators}{STL-style} reverse iterator pointing to the first
@@ -653,7 +653,7 @@
\sa begin(), rbegin(), rend()
*/
-/*! \fn QVarLengthArray::reverse_iterator QVarLengthArray::rend()
+/*! \fn template<class T, int Prealloc> QVarLengthArray<T, Prealloc>::reverse_iterator QVarLengthArray<T, Prealloc>::rend()
\since 5.6
Returns a \l{STL-style iterators}{STL-style} reverse iterator pointing to one past
@@ -662,12 +662,12 @@
\sa end(), crend(), rbegin()
*/
-/*! \fn QVarLengthArray::const_reverse_iterator QVarLengthArray::rend() const
+/*! \fn template<class T, int Prealloc> QVarLengthArray<T, Prealloc>::const_reverse_iterator QVarLengthArray<T, Prealloc>::rend() const
\since 5.6
\overload
*/
-/*! \fn QVarLengthArray::const_reverse_iterator QVarLengthArray::crend() const
+/*! \fn template<class T, int Prealloc> QVarLengthArray<T, Prealloc>::const_reverse_iterator QVarLengthArray<T, Prealloc>::crend() const
\since 5.6
Returns a const \l{STL-style iterators}{STL-style} reverse iterator pointing to one
@@ -676,7 +676,7 @@
\sa end(), rend(), rbegin()
*/
-/*! \fn QVarLengthArray::iterator QVarLengthArray::erase(const_iterator pos)
+/*! \fn template<class T, int Prealloc> QVarLengthArray<T, Prealloc>::iterator QVarLengthArray<T, Prealloc>::erase(const_iterator pos)
\since 4.8
Removes the item pointed to by the iterator \a pos from the
@@ -686,7 +686,7 @@
\sa insert(), remove()
*/
-/*! \fn QVarLengthArray::iterator QVarLengthArray::erase(const_iterator begin, const_iterator end)
+/*! \fn template<class T, int Prealloc> QVarLengthArray<T, Prealloc>::iterator QVarLengthArray<T, Prealloc>::erase(const_iterator begin, const_iterator end)
\overload
\since 4.8
@@ -696,7 +696,7 @@
before the call.
*/
-/*! \fn void QVarLengthArray::insert(int i, const T &value)
+/*! \fn template<class T, int Prealloc> void QVarLengthArray<T, Prealloc>::insert(int i, const T &value)
\since 4.8
Inserts \a value at index position \a i in the array. If \a i is
@@ -712,7 +712,7 @@
\sa remove()
*/
-/*! \fn void QVarLengthArray::insert(int i, int count, const T &value)
+/*! \fn template<class T, int Prealloc> void QVarLengthArray<T, Prealloc>::insert(int i, int count, const T &value)
\overload
\since 4.8
@@ -721,7 +721,7 @@
vector.
*/
-/*! \fn QVarLengthArray::iterator QVarLengthArray::insert(const_iterator before, const T &value)
+/*! \fn template<class T, int Prealloc> QVarLengthArray<T, Prealloc>::iterator QVarLengthArray<T, Prealloc>::insert(const_iterator before, const T &value)
\overload
\since 4.8
@@ -730,7 +730,7 @@
\a before. Returns an iterator pointing at the inserted item.
*/
-/*! \fn QVarLengthArray::iterator QVarLengthArray::insert(const_iterator before, int count, const T &value)
+/*! \fn template<class T, int Prealloc> QVarLengthArray<T, Prealloc>::iterator QVarLengthArray<T, Prealloc>::insert(const_iterator before, int count, const T &value)
\since 4.8
Inserts \a count copies of \a value in front of the item pointed to
@@ -740,7 +740,7 @@
-/*! \fn bool operator==(const QVarLengthArray<T, Prealloc1> &left, const QVarLengthArray<T, Prealloc2> &right)
+/*! \fn template<class T, int Prealloc1, int Prealloc2> bool operator==(const QVarLengthArray<T, Prealloc1> &left, const QVarLengthArray<T, Prealloc2> &right)
\relates QVarLengthArray
\since 4.8
@@ -755,7 +755,7 @@
\sa operator!=()
*/
-/*! \fn bool operator!=(const QVarLengthArray<T, Prealloc1> &left, const QVarLengthArray<T, Prealloc2> &right)
+/*! \fn template<typename T, int Prealloc1, int Prealloc2> bool operator!=(const QVarLengthArray<T, Prealloc1> &left, const QVarLengthArray<T, Prealloc2> &right)
\relates QVarLengthArray
\since 4.8
@@ -770,7 +770,7 @@
\sa operator==()
*/
-/*! \fn bool operator<(const QVarLengthArray<T,Prealloc1> &lhs, const QVarLengthArray<T,Prealloc2> &rhs)
+/*! \fn template<typename T, int Prealloc1, int Prealloc2> bool operator<(const QVarLengthArray<T,Prealloc1> &lhs, const QVarLengthArray<T,Prealloc2> &rhs)
\since 5.6
\relates QVarLengthArray
@@ -782,7 +782,7 @@
of \c operator<().
*/
-/*! \fn bool operator<=(const QVarLengthArray<T,Prealloc1> &lhs, const QVarLengthArray<T,Prealloc2> &rhs)
+/*! \fn template<typename T, int Prealloc1, int Prealloc2> bool operator<=(const QVarLengthArray<T,Prealloc1> &lhs, const QVarLengthArray<T,Prealloc2> &rhs)
\since 5.6
\relates QVarLengthArray
@@ -794,7 +794,7 @@
of \c operator<().
*/
-/*! \fn bool operator>(const QVarLengthArray<T,Prealloc1> &lhs, const QVarLengthArray<T,Prealloc2> &rhs)
+/*! \fn template<typename T, int Prealloc1, int Prealloc2> bool operator>(const QVarLengthArray<T,Prealloc1> &lhs, const QVarLengthArray<T,Prealloc2> &rhs)
\since 5.6
\relates QVarLengthArray
@@ -806,7 +806,7 @@
of \c operator<().
*/
-/*! \fn bool operator>=(const QVarLengthArray<T,Prealloc1> &lhs, const QVarLengthArray<T,Prealloc2> &rhs)
+/*! \fn template<typename T, int Prealloc1, int Prealloc2> bool operator>=(const QVarLengthArray<T,Prealloc1> &lhs, const QVarLengthArray<T,Prealloc2> &rhs)
\since 5.6
\relates QVarLengthArray
@@ -818,7 +818,7 @@
of \c operator<().
*/
-/*! \fn QVarLengthArray &QVarLengthArray::operator<<(const T &value)
+/*! \fn template<class T, int Prealloc> QVarLengthArray &QVarLengthArray<T, Prealloc>::operator<<(const T &value)
\since 4.8
Appends \a value to the array and returns a reference to this
@@ -827,7 +827,7 @@
\sa append(), operator+=()
*/
-/*! \fn QVarLengthArray &QVarLengthArray::operator+=(const T &value)
+/*! \fn template<class T, int Prealloc> QVarLengthArray &QVarLengthArray<T, Prealloc>::operator+=(const T &value)
\since 4.8
Appends \a value to the array and returns a reference to this vector.
@@ -835,7 +835,7 @@
\sa append(), operator<<()
*/
-/*! \fn int QVarLengthArray::indexOf(const T &value, int from = 0) const
+/*! \fn template<class T, int Prealloc> int QVarLengthArray<T, Prealloc>::indexOf(const T &value, int from = 0) const
\since 5.3
Returns the index position of the first occurrence of \a value in
@@ -848,7 +848,7 @@
\sa lastIndexOf(), contains()
*/
-/*! \fn int QVarLengthArray::lastIndexOf(const T &value, int from = -1) const
+/*! \fn template<class T, int Prealloc> int QVarLengthArray<T, Prealloc>::lastIndexOf(const T &value, int from = -1) const
\since 5.3
Returns the index position of the last occurrence of the value \a
@@ -862,7 +862,7 @@
\sa indexOf(), contains()
*/
-/*! \fn bool QVarLengthArray::contains(const T &value) const
+/*! \fn template<class T, int Prealloc> bool QVarLengthArray<T, Prealloc>::contains(const T &value) const
\since 5.3
Returns \c true if the array contains an occurrence of \a value;
diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h
index 3a3d416775..ce6e657be0 100644
--- a/src/corelib/tools/qvector.h
+++ b/src/corelib/tools/qvector.h
@@ -59,8 +59,6 @@
QT_BEGIN_NAMESPACE
-class QRegion;
-
template <typename T>
class QVector
{
@@ -291,8 +289,6 @@ public:
inline std::vector<T> toStdVector() const
{ return std::vector<T>(d->begin(), d->end()); }
private:
- friend class QRegion; // Optimization for QRegion::rects()
-
// ### Qt6: remove const from int parameters
void reallocData(const int size, const int alloc, QArrayData::AllocationOptions options = QArrayData::Default);
void reallocData(const int sz) { reallocData(sz, d->alloc); }
diff --git a/src/corelib/tools/qvector.qdoc b/src/corelib/tools/qvector.qdoc
index 61fb3d494d..1068de76d5 100644
--- a/src/corelib/tools/qvector.qdoc
+++ b/src/corelib/tools/qvector.qdoc
@@ -189,7 +189,7 @@
*/
/*!
- \fn QVector<T> QVector::mid(int pos, int length = -1) const
+ \fn template <typename T> QVector<T> QVector<T>::mid(int pos, int length = -1) const
Returns a sub-vector which contains elements from this vector,
starting at position \a pos. If \a length is -1 (the default), all
@@ -199,7 +199,7 @@
*/
-/*! \fn QVector::QVector()
+/*! \fn template <typename T> QVector<T>::QVector()
Constructs an empty vector.
@@ -207,7 +207,7 @@
*/
/*!
- \fn QVector::QVector(QVector<T> &&other)
+ \fn template <typename T> QVector<T>::QVector(QVector<T> &&other)
Move-constructs a QVector instance, making it point at the same
object that \a other was pointing to.
@@ -215,7 +215,7 @@
\since 5.2
*/
-/*! \fn QVector::QVector(int size)
+/*! \fn template <typename T> QVector<T>::QVector(int size)
Constructs a vector with an initial size of \a size elements.
@@ -225,7 +225,7 @@
\sa resize()
*/
-/*! \fn QVector::QVector(int size, const T &value)
+/*! \fn template <typename T> QVector<T>::QVector(int size, const T &value)
Constructs a vector with an initial size of \a size elements.
Each element is initialized with \a value.
@@ -233,7 +233,7 @@
\sa resize(), fill()
*/
-/*! \fn QVector::QVector(const QVector<T> &other)
+/*! \fn template <typename T> QVector<T>::QVector(const QVector<T> &other)
Constructs a copy of \a other.
@@ -246,7 +246,7 @@
\sa operator=()
*/
-/*! \fn QVector::QVector(std::initializer_list<T> args)
+/*! \fn template <typename T> QVector<T>::QVector(std::initializer_list<T> args)
\since 4.8
Constructs a vector from the std::initializer_list given by \a args.
@@ -256,33 +256,33 @@
*/
-/*! \fn QVector::~QVector()
+/*! \fn template <typename T> QVector<T>::~QVector()
Destroys the vector.
*/
-/*! \fn QVector<T> &QVector::operator=(const QVector<T> &other)
+/*! \fn template <typename T> QVector<T> &QVector<T>::operator=(const QVector<T> &other)
Assigns \a other to this vector and returns a reference to this
vector.
*/
/*!
- \fn QVector<T> &QVector::operator=(QVector<T> &&other)
+ \fn template <typename T> QVector<T> &QVector<T>::operator=(QVector<T> &&other)
Move-assigns \a other to this QVector instance.
\since 5.2
*/
-/*! \fn void QVector::swap(QVector<T> &other)
+/*! \fn template <typename T> void QVector<T>::swap(QVector<T> &other)
\since 4.8
Swaps vector \a other with this vector. This operation is very fast and
never fails.
*/
-/*! \fn bool QVector::operator==(const QVector<T> &other) const
+/*! \fn template <typename T> bool QVector<T>::operator==(const QVector<T> &other) const
Returns \c true if \a other is equal to this vector; otherwise
returns \c false.
@@ -296,7 +296,7 @@
\sa operator!=()
*/
-/*! \fn bool QVector::operator!=(const QVector<T> &other) const
+/*! \fn template <typename T> bool QVector<T>::operator!=(const QVector<T> &other) const
Returns \c true if \a other is not equal to this vector; otherwise
returns \c false.
@@ -310,7 +310,7 @@
\sa operator==()
*/
-/*! \fn bool operator<(const QVector<T> &lhs, const QVector<T> &rhs)
+/*! \fn template <typename T> bool operator<(const QVector<T> &lhs, const QVector<T> &rhs)
\since 5.6
\relates QVector
@@ -322,7 +322,7 @@
of \c operator<().
*/
-/*! \fn bool operator<=(const QVector<T> &lhs, const QVector<T> &rhs)
+/*! \fn template <typename T> bool operator<=(const QVector<T> &lhs, const QVector<T> &rhs)
\since 5.6
\relates QVector
@@ -334,7 +334,7 @@
of \c operator<().
*/
-/*! \fn bool operator>(const QVector<T> &lhs, const QVector<T> &rhs)
+/*! \fn template <typename T> bool operator>(const QVector<T> &lhs, const QVector<T> &rhs)
\since 5.6
\relates QVector
@@ -346,7 +346,7 @@
of \c operator<().
*/
-/*! \fn bool operator>=(const QVector<T> &lhs, const QVector<T> &rhs)
+/*! \fn template <typename T> bool operator>=(const QVector<T> &lhs, const QVector<T> &rhs)
\since 5.6
\relates QVector
@@ -359,7 +359,7 @@
*/
/*!
- \fn uint qHash(const QVector<T> &key, uint seed = 0)
+ \fn template <typename T> uint qHash(const QVector<T> &key, uint seed = 0)
\since 5.6
\relates QVector
@@ -369,21 +369,21 @@
This function requires qHash() to be overloaded for the value type \c T.
*/
-/*! \fn int QVector::size() const
+/*! \fn template <typename T> int QVector<T>::size() const
Returns the number of items in the vector.
\sa isEmpty(), resize()
*/
-/*! \fn bool QVector::isEmpty() const
+/*! \fn template <typename T> bool QVector<T>::isEmpty() const
Returns \c true if the vector has size 0; otherwise returns \c false.
\sa size(), resize()
*/
-/*! \fn void QVector::resize(int size)
+/*! \fn template <typename T> void QVector<T>::resize(int size)
Sets the size of the vector to \a size. If \a size is greater than the
current size, elements are added to the end; the new elements are
@@ -396,7 +396,7 @@
\sa size()
*/
-/*! \fn int QVector::capacity() const
+/*! \fn template <typename T> int QVector<T>::capacity() const
Returns the maximum number of items that can be stored in the
vector without forcing a reallocation.
@@ -409,7 +409,7 @@
\sa reserve(), squeeze()
*/
-/*! \fn void QVector::reserve(int size)
+/*! \fn template <typename T> void QVector<T>::reserve(int size)
Attempts to allocate memory for at least \a size elements. If you
know in advance how large the vector will be, you should call this
@@ -434,7 +434,7 @@
\sa squeeze(), capacity()
*/
-/*! \fn void QVector::squeeze()
+/*! \fn template <typename T> void QVector<T>::squeeze()
Releases any memory not required to store the items.
@@ -445,27 +445,27 @@
\sa reserve(), capacity()
*/
-/*! \fn void QVector::detach()
+/*! \fn template <typename T> void QVector<T>::detach()
\internal
*/
-/*! \fn bool QVector::isDetached() const
+/*! \fn template <typename T> bool QVector<T>::isDetached() const
\internal
*/
-/*! \fn void QVector::setSharable(bool sharable)
+/*! \fn template <typename T> void QVector<T>::setSharable(bool sharable)
\internal
*/
-/*! \fn bool QVector::isSharedWith(const QVector<T> &other) const
+/*! \fn template <typename T> bool QVector<T>::isSharedWith(const QVector<T> &other) const
\internal
*/
-/*! \fn T *QVector::data()
+/*! \fn template <typename T> T *QVector<T>::data()
Returns a pointer to the data stored in the vector. The pointer
can be used to access and modify the items in the vector.
@@ -482,12 +482,12 @@
\sa constData(), operator[]()
*/
-/*! \fn const T *QVector::data() const
+/*! \fn template <typename T> const T *QVector<T>::data() const
\overload
*/
-/*! \fn const T *QVector::constData() const
+/*! \fn template <typename T> const T *QVector<T>::constData() const
Returns a const pointer to the data stored in the vector. The
pointer can be used to access the items in the vector.
@@ -500,7 +500,7 @@
\sa data(), operator[]()
*/
-/*! \fn void QVector::clear()
+/*! \fn template <typename T> void QVector<T>::clear()
Removes all the elements from the vector.
@@ -517,7 +517,7 @@
\sa squeeze()
*/
-/*! \fn const T &QVector::at(int i) const
+/*! \fn template <typename T> const T &QVector<T>::at(int i) const
Returns the item at index position \a i in the vector.
@@ -527,7 +527,7 @@
\sa value(), operator[]()
*/
-/*! \fn T &QVector::operator[](int i)
+/*! \fn template <typename T> T &QVector<T>::operator[](int i)
Returns the item at index position \a i as a modifiable reference.
@@ -540,7 +540,7 @@
\sa at(), value()
*/
-/*! \fn const T &QVector::operator[](int i) const
+/*! \fn template <typename T> const T &QVector<T>::operator[](int i) const
\overload
@@ -548,7 +548,7 @@
*/
/*!
- \fn void QVector::append(const T &value)
+ \fn template <typename T> void QVector<T>::append(const T &value)
Inserts \a value at the end of the vector.
@@ -566,7 +566,7 @@
*/
/*!
- \fn void QVector::append(T &&value)
+ \fn template <typename T> void QVector<T>::append(T &&value)
\since 5.6
\overload
@@ -575,7 +575,7 @@
\snippet code/src_corelib_tools_qvector.cpp move-append
*/
-/*! \fn void QVector::append(const QVector<T> &value)
+/*! \fn template <typename T> void QVector<T>::append(const QVector<T> &value)
\overload
@@ -587,7 +587,7 @@
*/
-/*! \fn void QVector::prepend(const T &value)
+/*! \fn template <typename T> void QVector<T>::prepend(const T &value)
Inserts \a value at the beginning of the vector.
@@ -605,7 +605,7 @@
\sa append(), insert()
*/
-/*! \fn void QVector::insert(int i, const T &value)
+/*! \fn template <typename T> void QVector<T>::insert(int i, const T &value)
Inserts \a value at index position \a i in the vector. If \a i is
0, the value is prepended to the vector. If \a i is size(), the
@@ -623,7 +623,7 @@
\sa append(), prepend(), remove()
*/
-/*! \fn void QVector::insert(int i, int count, const T &value)
+/*! \fn template <typename T> void QVector<T>::insert(int i, int count, const T &value)
\overload
@@ -634,7 +634,7 @@
\snippet code/src_corelib_tools_qvector.cpp 10
*/
-/*! \fn QVector::iterator QVector::insert(iterator before, const T &value)
+/*! \fn template <typename T> QVector<T>::iterator QVector<T>::insert(iterator before, const T &value)
\overload
@@ -642,14 +642,14 @@
\a before. Returns an iterator pointing at the inserted item.
*/
-/*! \fn QVector::iterator QVector::insert(iterator before, int count, const T &value)
+/*! \fn template <typename T> QVector<T>::iterator QVector<T>::insert(iterator before, int count, const T &value)
Inserts \a count copies of \a value in front of the item pointed to
by the iterator \a before. Returns an iterator pointing at the
first of the inserted items.
*/
-/*! \fn void QVector::replace(int i, const T &value)
+/*! \fn template <typename T> void QVector<T>::replace(int i, const T &value)
Replaces the item at index position \a i with \a value.
@@ -659,7 +659,7 @@
\sa operator[](), remove()
*/
-/*! \fn void QVector::remove(int i)
+/*! \fn template <typename T> void QVector<T>::remove(int i)
\overload
@@ -668,7 +668,7 @@
\sa insert(), replace(), fill()
*/
-/*! \fn void QVector::remove(int i, int count)
+/*! \fn template <typename T> void QVector<T>::remove(int i, int count)
\overload
@@ -678,7 +678,7 @@
\sa insert(), replace(), fill()
*/
-/*! \fn void QVector::removeAt(int i)
+/*! \fn template <typename T> void QVector<T>::removeAt(int i)
\since 5.2
Removes the element at index position \a i.
@@ -692,7 +692,7 @@
\sa remove(), QList::removeAt()
*/
-/*! \fn int QVector::removeAll(const T &t)
+/*! \fn template <typename T> int QVector<T>::removeAll(const T &t)
\since 5.4
Removes all elements that compare equal to \a t from the
@@ -703,7 +703,7 @@
\sa removeOne(), QList::removeAll()
*/
-/*! \fn bool QVector::removeOne(const T &t)
+/*! \fn template <typename T> bool QVector<T>::removeOne(const T &t)
\since 5.4
Removes the first element that compares equal to \a t from the
@@ -714,7 +714,7 @@
\sa removeAll(), QList::removeOne()
*/
-/*! \fn int QVector::length() const
+/*! \fn template <typename T> int QVector<T>::length() const
\since 5.2
Same as size() and count().
@@ -724,7 +724,7 @@
\sa size(), count(), QList::length()
*/
-/*! \fn T QVector::takeAt(int i)
+/*! \fn template <typename T> T QVector<T>::takeAt(int i)
\since 5.2
Removes the element at index position \a i and returns it.
@@ -741,7 +741,7 @@
\sa takeFirst(), takeLast(), QList::takeAt()
*/
-/*! \fn void QVector::move(int from, int to)
+/*! \fn template <typename T> void QVector<T>::move(int from, int to)
\since 5.6
Moves the item at index position \a from to index position \a to.
@@ -751,7 +751,7 @@
\sa QList::move()
*/
-/*! \fn void QVector::removeFirst()
+/*! \fn template <typename T> void QVector<T>::removeFirst()
\since 5.1
Removes the first item in the vector. Calling this function is
equivalent to calling remove(0). The vector must not be empty. If
@@ -761,7 +761,7 @@
\sa remove(), takeFirst(), isEmpty()
*/
-/*! \fn void QVector::removeLast()
+/*! \fn template <typename T> void QVector<T>::removeLast()
\since 5.1
Removes the last item in the vector. Calling this function is
equivalent to calling remove(size() - 1). The vector must not be
@@ -771,7 +771,7 @@
\sa remove(), takeLast(), removeFirst(), isEmpty()
*/
-/*! \fn T QVector::takeFirst()
+/*! \fn template <typename T> T QVector<T>::takeFirst()
\since 5.1
Removes the first item in the vector and returns it. This function
@@ -781,7 +781,7 @@
\sa takeLast(), removeFirst()
*/
-/*! \fn T QVector::takeLast()
+/*! \fn template <typename T> T QVector<T>::takeLast()
\since 5.1
Removes the last item in the list and returns it. This function
@@ -795,7 +795,7 @@
*/
-/*! \fn QVector &QVector::fill(const T &value, int size = -1)
+/*! \fn template <typename T> QVector &QVector<T>::fill(const T &value, int size = -1)
Assigns \a value to all items in the vector. If \a size is
different from -1 (the default), the vector is resized to size \a
@@ -807,7 +807,7 @@
\sa resize()
*/
-/*! \fn int QVector::indexOf(const T &value, int from = 0) const
+/*! \fn template <typename T> int QVector<T>::indexOf(const T &value, int from = 0) const
Returns the index position of the first occurrence of \a value in
the vector, searching forward from index position \a from.
@@ -822,7 +822,7 @@
\sa lastIndexOf(), contains()
*/
-/*! \fn int QVector::lastIndexOf(const T &value, int from = -1) const
+/*! \fn template <typename T> int QVector<T>::lastIndexOf(const T &value, int from = -1) const
Returns the index position of the last occurrence of the value \a
value in the vector, searching backward from index position \a
@@ -838,7 +838,7 @@
\sa indexOf()
*/
-/*! \fn bool QVector::contains(const T &value) const
+/*! \fn template <typename T> bool QVector<T>::contains(const T &value) const
Returns \c true if the vector contains an occurrence of \a value;
otherwise returns \c false.
@@ -849,7 +849,7 @@
\sa indexOf(), count()
*/
-/*! \fn bool QVector::startsWith(const T &value) const
+/*! \fn template <typename T> bool QVector<T>::startsWith(const T &value) const
\since 4.5
Returns \c true if this vector is not empty and its first
@@ -858,7 +858,7 @@
\sa isEmpty(), first()
*/
-/*! \fn bool QVector::endsWith(const T &value) const
+/*! \fn template <typename T> bool QVector<T>::endsWith(const T &value) const
\since 4.5
Returns \c true if this vector is not empty and its last
@@ -868,7 +868,7 @@
*/
-/*! \fn int QVector::count(const T &value) const
+/*! \fn template <typename T> int QVector<T>::count(const T &value) const
Returns the number of occurrences of \a value in the vector.
@@ -878,14 +878,14 @@
\sa contains(), indexOf()
*/
-/*! \fn int QVector::count() const
+/*! \fn template <typename T> int QVector<T>::count() const
\overload
Same as size().
*/
-/*! \fn QVector::iterator QVector::begin()
+/*! \fn template <typename T> QVector<T>::iterator QVector<T>::begin()
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the first item in
the vector.
@@ -893,12 +893,12 @@
\sa constBegin(), end()
*/
-/*! \fn QVector::const_iterator QVector::begin() const
+/*! \fn template <typename T> QVector<T>::const_iterator QVector<T>::begin() const
\overload
*/
-/*! \fn QVector::const_iterator QVector::cbegin() const
+/*! \fn template <typename T> QVector<T>::const_iterator QVector<T>::cbegin() const
\since 5.0
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first item
@@ -907,7 +907,7 @@
\sa begin(), cend()
*/
-/*! \fn QVector::const_iterator QVector::constBegin() const
+/*! \fn template <typename T> QVector<T>::const_iterator QVector<T>::constBegin() const
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first item
in the vector.
@@ -915,7 +915,7 @@
\sa begin(), constEnd()
*/
-/*! \fn QVector::iterator QVector::end()
+/*! \fn template <typename T> QVector<T>::iterator QVector<T>::end()
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item
after the last item in the vector.
@@ -923,12 +923,12 @@
\sa begin(), constEnd()
*/
-/*! \fn QVector::const_iterator QVector::end() const
+/*! \fn template <typename T> QVector<T>::const_iterator QVector<T>::end() const
\overload
*/
-/*! \fn QVector::const_iterator QVector::cend() const
+/*! \fn template <typename T> QVector<T>::const_iterator QVector<T>::cend() const
\since 5.0
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary
@@ -937,7 +937,7 @@
\sa cbegin(), end()
*/
-/*! \fn QVector::const_iterator QVector::constEnd() const
+/*! \fn template <typename T> QVector<T>::const_iterator QVector<T>::constEnd() const
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary
item after the last item in the vector.
@@ -945,7 +945,7 @@
\sa constBegin(), end()
*/
-/*! \fn QVector::reverse_iterator QVector::rbegin()
+/*! \fn template <typename T> QVector<T>::reverse_iterator QVector<T>::rbegin()
\since 5.6
Returns a \l{STL-style iterators}{STL-style} reverse iterator pointing to the first
@@ -954,12 +954,12 @@
\sa begin(), crbegin(), rend()
*/
-/*! \fn QVector::const_reverse_iterator QVector::rbegin() const
+/*! \fn template <typename T> QVector<T>::const_reverse_iterator QVector<T>::rbegin() const
\since 5.6
\overload
*/
-/*! \fn QVector::const_reverse_iterator QVector::crbegin() const
+/*! \fn template <typename T> QVector<T>::const_reverse_iterator QVector<T>::crbegin() const
\since 5.6
Returns a const \l{STL-style iterators}{STL-style} reverse iterator pointing to the first
@@ -968,7 +968,7 @@
\sa begin(), rbegin(), rend()
*/
-/*! \fn QVector::reverse_iterator QVector::rend()
+/*! \fn template <typename T> QVector<T>::reverse_iterator QVector<T>::rend()
\since 5.6
Returns a \l{STL-style iterators}{STL-style} reverse iterator pointing to one past
@@ -977,12 +977,12 @@
\sa end(), crend(), rbegin()
*/
-/*! \fn QVector::const_reverse_iterator QVector::rend() const
+/*! \fn template <typename T> QVector<T>::const_reverse_iterator QVector<T>::rend() const
\since 5.6
\overload
*/
-/*! \fn QVector::const_reverse_iterator QVector::crend() const
+/*! \fn template <typename T> QVector<T>::const_reverse_iterator QVector<T>::crend() const
\since 5.6
Returns a const \l{STL-style iterators}{STL-style} reverse iterator pointing to one
@@ -991,7 +991,7 @@
\sa end(), rend(), rbegin()
*/
-/*! \fn QVector::iterator QVector::erase(iterator pos)
+/*! \fn template <typename T> QVector<T>::iterator QVector<T>::erase(iterator pos)
Removes the item pointed to by the iterator \a pos from the
vector, and returns an iterator to the next item in the vector
@@ -1000,7 +1000,7 @@
\sa insert(), remove()
*/
-/*! \fn QVector::iterator QVector::erase(iterator begin, iterator end)
+/*! \fn template <typename T> QVector<T>::iterator QVector<T>::erase(iterator begin, iterator end)
\overload
@@ -1009,7 +1009,7 @@
before the call.
*/
-/*! \fn T& QVector::first()
+/*! \fn template <typename T> T& QVector<T>::first()
Returns a reference to the first item in the vector. This
function assumes that the vector isn't empty.
@@ -1017,12 +1017,12 @@
\sa last(), isEmpty(), constFirst()
*/
-/*! \fn const T& QVector::first() const
+/*! \fn template <typename T> const T& QVector<T>::first() const
\overload
*/
-/*! \fn const T& QVector::constFirst() const
+/*! \fn template <typename T> const T& QVector<T>::constFirst() const
\since 5.6
Returns a const reference to the first item in the vector. This
@@ -1031,7 +1031,7 @@
\sa constLast(), isEmpty(), first()
*/
-/*! \fn T& QVector::last()
+/*! \fn template <typename T> T& QVector<T>::last()
Returns a reference to the last item in the vector. This function
assumes that the vector isn't empty.
@@ -1039,12 +1039,12 @@
\sa first(), isEmpty(), constLast()
*/
-/*! \fn const T& QVector::last() const
+/*! \fn template <typename T> const T& QVector<T>::last() const
\overload
*/
-/*! \fn const T& QVector::constLast() const
+/*! \fn template <typename T> const T& QVector<T>::constLast() const
\since 5.6
Returns a const reference to the last item in the vector. This function
@@ -1053,7 +1053,7 @@
\sa constFirst(), isEmpty(), last()
*/
-/*! \fn T QVector::value(int i) const
+/*! \fn template <typename T> T QVector<T>::value(int i) const
Returns the value at index position \a i in the vector.
@@ -1065,7 +1065,7 @@
\sa at(), operator[]()
*/
-/*! \fn T QVector::value(int i, const T &defaultValue) const
+/*! \fn template <typename T> T QVector<T>::value(int i, const T &defaultValue) const
\overload
@@ -1073,72 +1073,72 @@
\a defaultValue.
*/
-/*! \fn void QVector::push_back(const T &value)
+/*! \fn template <typename T> void QVector<T>::push_back(const T &value)
This function is provided for STL compatibility. It is equivalent
to append(\a value).
*/
-/*! \fn void QVector::push_back(T &&value)
+/*! \fn template <typename T> void QVector<T>::push_back(T &&value)
\since 5.6
\overload
*/
-/*! \fn void QVector::push_front(const T &value)
+/*! \fn template <typename T> void QVector<T>::push_front(const T &value)
This function is provided for STL compatibility. It is equivalent
to prepend(\a value).
*/
-/*! \fn void QVector::pop_front()
+/*! \fn template <typename T> void QVector<T>::pop_front()
This function is provided for STL compatibility. It is equivalent
to removeFirst().
*/
-/*! \fn void QVector::pop_back()
+/*! \fn template <typename T> void QVector<T>::pop_back()
This function is provided for STL compatibility. It is equivalent
to removeLast().
*/
-/*! \fn T& QVector::front()
+/*! \fn template <typename T> T& QVector<T>::front()
This function is provided for STL compatibility. It is equivalent
to first().
*/
-/*! \fn QVector::const_reference QVector::front() const
+/*! \fn template <typename T> QVector<T>::const_reference QVector<T>::front() const
\overload
*/
-/*! \fn QVector::reference QVector::back()
+/*! \fn template <typename T> QVector<T>::reference QVector<T>::back()
This function is provided for STL compatibility. It is equivalent
to last().
*/
-/*! \fn QVector::const_reference QVector::back() const
+/*! \fn template <typename T> QVector<T>::const_reference QVector<T>::back() const
\overload
*/
-/*! \fn void QVector::shrink_to_fit()
+/*! \fn template <typename T> void QVector<T>::shrink_to_fit()
\since 5.10
This function is provided for STL compatibility. It is equivalent
to squeeze().
*/
-/*! \fn bool QVector::empty() const
+/*! \fn template <typename T> bool QVector<T>::empty() const
This function is provided for STL compatibility. It is equivalent
to isEmpty(), returning \c true if the vector is empty; otherwise
returns \c false.
*/
-/*! \fn QVector<T> &QVector::operator+=(const QVector<T> &other)
+/*! \fn template <typename T> QVector<T> &QVector<T>::operator+=(const QVector<T> &other)
Appends the items of the \a other vector to this vector and
returns a reference to this vector.
@@ -1146,7 +1146,7 @@
\sa operator+(), append()
*/
-/*! \fn void QVector::operator+=(const T &value)
+/*! \fn template <typename T> void QVector<T>::operator+=(const T &value)
\overload
@@ -1155,7 +1155,7 @@
\sa append(), operator<<()
*/
-/*! \fn QVector<T> QVector::operator+(const QVector<T> &other) const
+/*! \fn template <typename T> QVector<T> QVector<T>::operator+(const QVector<T> &other) const
Returns a vector that contains all the items in this vector
followed by all the items in the \a other vector.
@@ -1163,7 +1163,7 @@
\sa operator+=()
*/
-/*! \fn QVector<T> &QVector::operator<<(const T &value)
+/*! \fn template <typename T> QVector<T> &QVector<T>::operator<<(const T &value)
Appends \a value to the vector and returns a reference to this
vector.
@@ -1171,7 +1171,7 @@
\sa append(), operator+=()
*/
-/*! \fn QVector<T> &QVector::operator<<(const QVector<T> &other)
+/*! \fn template <typename T> QVector<T> &QVector<T>::operator<<(const QVector<T> &other)
Appends \a other to the vector and returns a reference to the
vector.
@@ -1288,7 +1288,7 @@
Typedef for T. Provided for STL compatibility.
*/
-/*! \fn QList<T> QVector<T>::toList() const
+/*! \fn template <typename T> QList<T> QVector<T>::toList() const
Returns a QList object with the data contained in this QVector.
@@ -1299,7 +1299,7 @@
\sa fromList(), QList::fromVector()
*/
-/*! \fn QVector<T> QVector<T>::fromList(const QList<T> &list)
+/*! \fn template <typename T> QVector<T> QVector<T>::fromList(const QList<T> &list)
Returns a QVector object with the data contained in \a list.
@@ -1310,7 +1310,7 @@
\sa toList(), QList::toVector()
*/
-/*! \fn QVector<T> QVector<T>::fromStdVector(const std::vector<T> &vector)
+/*! \fn template <typename T> QVector<T> QVector<T>::fromStdVector(const std::vector<T> &vector)
Returns a QVector object with the data contained in \a vector. The
order of the elements in the QVector is the same as in \a vector.
@@ -1322,7 +1322,7 @@
\sa toStdVector(), QList::fromStdList()
*/
-/*! \fn std::vector<T> QVector<T>::toStdVector() const
+/*! \fn template <typename T> std::vector<T> QVector<T>::toStdVector() const
Returns a std::vector object with the data contained in this QVector.
Example:
@@ -1332,7 +1332,7 @@
\sa fromStdVector(), QList::toStdList()
*/
-/*! \fn QDataStream &operator<<(QDataStream &out, const QVector<T> &vector)
+/*! \fn template <typename T> QDataStream &operator<<(QDataStream &out, const QVector<T> &vector)
\relates QVector
Writes the vector \a vector to stream \a out.
@@ -1342,7 +1342,7 @@
\sa{Serializing Qt Data Types}{Format of the QDataStream operators}
*/
-/*! \fn QDataStream &operator>>(QDataStream &in, QVector<T> &vector)
+/*! \fn template <typename T> QDataStream &operator>>(QDataStream &in, QVector<T> &vector)
\relates QVector
Reads a vector from stream \a in into \a vector.
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/tools/tools.pri b/src/corelib/tools/tools.pri
index 2c609098ea..56b30279bd 100644
--- a/src/corelib/tools/tools.pri
+++ b/src/corelib/tools/tools.pri
@@ -223,4 +223,3 @@ TR_EXCLUDE += ../3rdparty/*
# MIPS DSP
MIPS_DSP_ASM += tools/qstring_mips_dsp_asm.S
MIPS_DSP_HEADERS += ../gui/painting/qt_mips_asm_dsp_p.h
-CONFIG += simd
diff --git a/src/corelib/xml/qxmlstream.cpp b/src/corelib/xml/qxmlstream.cpp
index ef5fafbd76..9b5295a17e 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("&lt;"));
- else if (c.unicode() == '>' )
+ break;
+ case '>':
escaped.append(QLatin1String("&gt;"));
- else if (c.unicode() == '&' )
+ break;
+ case '&':
escaped.append(QLatin1String("&amp;"));
- else if (c.unicode() == '\"' )
+ break;
+ case '\"':
escaped.append(QLatin1String("&quot;"));
- else if (escapeWhitespace && c.isSpace()) {
- if (c.unicode() == '\n')
+ break;
+ case '\t':
+ if (escapeWhitespace)
+ escaped.append(QLatin1String("&#9;"));
+ else
+ escaped += c;
+ break;
+ case '\n':
+ if (escapeWhitespace)
escaped.append(QLatin1String("&#10;"));
- else if (c.unicode() == '\r')
+ else
+ escaped += c;
+ break;
+ case '\v':
+ case '\f':
+ hasEncodingError = true;
+ break;
+ case '\r':
+ if (escapeWhitespace)
escaped.append(QLatin1String("&#13;"));
- else if (c.unicode() == '\t')
- escaped.append(QLatin1String("&#9;"));
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;
{