diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-07 13:05:48 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-07 23:02:47 +0200 |
commit | 564b59d903683b14c75b72a3e93367717f201def (patch) | |
tree | 03ffe749d83dce84429a7db484bf92795047036f /tests/auto/corelib | |
parent | b5fc1e4e2643e73d3b44c483d159529f8deb8af1 (diff) |
Another round of replacing 0 with nullptr
This time based on grepping to also include documentation, tests and
examples previously missed by the automatic tool.
Change-Id: Ied1703f4bcc470fbc275f759ed5b7c588a5c4e9f
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'tests/auto/corelib')
33 files changed, 118 insertions, 114 deletions
diff --git a/tests/auto/corelib/animation/qanimationgroup/tst_qanimationgroup.cpp b/tests/auto/corelib/animation/qanimationgroup/tst_qanimationgroup.cpp index cf46d5c14e..fd1e288b4d 100644 --- a/tests/auto/corelib/animation/qanimationgroup/tst_qanimationgroup.cpp +++ b/tests/auto/corelib/animation/qanimationgroup/tst_qanimationgroup.cpp @@ -92,7 +92,7 @@ class UncontrolledAnimation : public QPropertyAnimation { Q_OBJECT public: - UncontrolledAnimation(QObject *target, const QByteArray &propertyName, QObject *parent = 0) + UncontrolledAnimation(QObject *target, const QByteArray &propertyName, QObject *parent = nullptr) : QPropertyAnimation(target, propertyName, parent), id(0) { setDuration(250); diff --git a/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp b/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp index fa30659d89..dab7a8cd6f 100644 --- a/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp +++ b/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp @@ -127,7 +127,7 @@ class UncontrolledAnimation : public QPropertyAnimation { Q_OBJECT public: - UncontrolledAnimation(QObject *target, const QByteArray &propertyName, QObject *parent = 0) + UncontrolledAnimation(QObject *target, const QByteArray &propertyName, QObject *parent = nullptr) : QPropertyAnimation(target, propertyName, parent), id(0) { setDuration(250); diff --git a/tests/auto/corelib/animation/qpauseanimation/tst_qpauseanimation.cpp b/tests/auto/corelib/animation/qpauseanimation/tst_qpauseanimation.cpp index a38f3d221d..5f2923f498 100644 --- a/tests/auto/corelib/animation/qpauseanimation/tst_qpauseanimation.cpp +++ b/tests/auto/corelib/animation/qpauseanimation/tst_qpauseanimation.cpp @@ -56,7 +56,7 @@ class TestablePauseAnimation : public QPauseAnimation { Q_OBJECT public: - TestablePauseAnimation(QObject *parent = 0) + TestablePauseAnimation(QObject *parent = nullptr) : QPauseAnimation(parent), m_updateCurrentTimeCount(0) { diff --git a/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp index 8a4d05ed96..f5cff8a2e0 100644 --- a/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp +++ b/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp @@ -65,7 +65,7 @@ private: class DummyPropertyAnimation : public QPropertyAnimation { public: - DummyPropertyAnimation(QObject *parent = 0) : QPropertyAnimation(parent) + DummyPropertyAnimation(QObject *parent = nullptr) : QPropertyAnimation(parent) { setTargetObject(&o); this->setPropertyName("x"); diff --git a/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp b/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp index 008ac696fc..1a03254e0b 100644 --- a/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp +++ b/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp @@ -108,7 +108,7 @@ public: class DummyPropertyAnimation : public QPropertyAnimation { public: - DummyPropertyAnimation(QObject *parent = 0) : QPropertyAnimation(parent) + DummyPropertyAnimation(QObject *parent = nullptr) : QPropertyAnimation(parent) { setTargetObject(&o); this->setPropertyName("value"); @@ -122,7 +122,7 @@ class UncontrolledAnimation : public QPropertyAnimation { Q_OBJECT public: - UncontrolledAnimation(QObject *target, QObject *parent = 0) + UncontrolledAnimation(QObject *target, QObject *parent = nullptr) : QPropertyAnimation(target, "value", parent) { setDuration(250); diff --git a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp index 4f07581587..72d0960473 100644 --- a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp +++ b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp @@ -722,7 +722,7 @@ public: SignalReceiver(const QDir &moveSrcDir, const QString &moveDestination, QFileSystemWatcher *watcher, - QObject *parent = 0) + QObject *parent = nullptr) : QObject(parent), added(false), moveSrcDir(moveSrcDir), diff --git a/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp b/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp index cc73eac9c8..e45c13b9b9 100644 --- a/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp +++ b/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp @@ -820,7 +820,7 @@ private slots: { _config->clear(); _config->addKey("LoggingCategoryObject", true); - QLoggingCategory *pcategorybject = 0; + QLoggingCategory *pcategorybject = nullptr; QLoggingCategory::setFilterRules(_config->array()); { QLoggingCategory mycategoryobject("LoggingCategoryObject"); diff --git a/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp b/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp index 5d384de2b2..bf44cf5fa0 100644 --- a/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp +++ b/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp @@ -132,8 +132,8 @@ private: class QtTestModel: public QAbstractItemModel { public: - QtTestModel(int rows, int columns, QObject *parent = 0); - QtTestModel(const QList<QList<QString> > tbl, QObject *parent = 0); + QtTestModel(int rows, int columns, QObject *parent = nullptr); + QtTestModel(const QList<QList<QString> > tbl, QObject *parent = nullptr); QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override; QModelIndex parent(const QModelIndex &) const override; int rowCount(const QModelIndex &parent) const override; @@ -1940,7 +1940,7 @@ public: UserRole }; - CustomRoleModel(QObject *parent = 0) + CustomRoleModel(QObject *parent = nullptr) : QStringListModel(QStringList() << "a" << "b" << "c", parent) { } @@ -1991,7 +1991,7 @@ class SignalArgumentChecker : public QObject { Q_OBJECT public: - SignalArgumentChecker(const QModelIndex &p1, const QModelIndex &p2, QObject *parent = 0) + SignalArgumentChecker(const QModelIndex &p1, const QModelIndex &p2, QObject *parent = nullptr) : QObject(parent), m_p1(p1), m_p2(p2), m_p1Persistent(p1), m_p2Persistent(p2) { connect(p1.model(), SIGNAL(layoutAboutToBeChanged(QList<QPersistentModelIndex>)), SLOT(layoutAboutToBeChanged(QList<QPersistentModelIndex>))); @@ -2165,7 +2165,7 @@ class OverrideRoleNamesAndDragActions : public QStringListModel { Q_OBJECT public: - OverrideRoleNamesAndDragActions(QObject *parent = 0) + OverrideRoleNamesAndDragActions(QObject *parent = nullptr) : QStringListModel(parent) { @@ -2204,7 +2204,7 @@ class OverrideDropActions : public QStringListModel { Q_OBJECT public: - OverrideDropActions(QObject *parent = 0) + OverrideDropActions(QObject *parent = nullptr) : QStringListModel(parent) { } @@ -2225,7 +2225,7 @@ class SignalConnectionTester : public QObject { Q_OBJECT public: - SignalConnectionTester(QObject *parent = 0) + SignalConnectionTester(QObject *parent = nullptr) : QObject(parent), testPassed(false) { diff --git a/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp b/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp index 313facac81..92f9c87b9f 100644 --- a/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp +++ b/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp @@ -2092,7 +2092,7 @@ class QtTestTableModel: public QAbstractTableModel { Q_OBJECT public: - QtTestTableModel(int rows = 0, int columns = 0, QObject *parent = 0) + QtTestTableModel(int rows = 0, int columns = 0, QObject *parent = nullptr) : QAbstractTableModel(parent) , row_count(rows) , column_count(columns) @@ -2624,7 +2624,7 @@ class SelectionObserver : public QObject { Q_OBJECT public: - SelectionObserver(QAbstractItemModel *model, QObject *parent = 0) + SelectionObserver(QAbstractItemModel *model, QObject *parent = nullptr) : QObject(parent), m_model(model), m_selectionModel(0) { connect(model, SIGNAL(modelReset()), SLOT(modelReset())); @@ -2688,7 +2688,7 @@ class DuplicateItemSelectionModel : public QItemSelectionModel { Q_OBJECT public: - DuplicateItemSelectionModel(QItemSelectionModel *target, QAbstractItemModel *model, QObject *parent = 0) + DuplicateItemSelectionModel(QItemSelectionModel *target, QAbstractItemModel *model, QObject *parent = nullptr) : QItemSelectionModel(model, parent), m_target(target) { } diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel_recursive/tst_qsortfilterproxymodel_recursive.cpp b/tests/auto/corelib/itemmodels/qsortfilterproxymodel_recursive/tst_qsortfilterproxymodel_recursive.cpp index 35ae7f4a7f..d6a09056ae 100644 --- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel_recursive/tst_qsortfilterproxymodel_recursive.cpp +++ b/tests/auto/corelib/itemmodels/qsortfilterproxymodel_recursive/tst_qsortfilterproxymodel_recursive.cpp @@ -142,7 +142,7 @@ static QString treeAsString(const QAbstractItemModel &model, const QModelIndex & static void fillModel(QStandardItemModel &model, const QString &str) { QCOMPARE(str.count('['), str.count(']')); - QStandardItem *item = 0; + QStandardItem *item = nullptr; QString data; for ( int i = 0 ; i < str.length() ; ++i ) { const QChar ch = str.at(i); diff --git a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp index 8b3d0503df..3b87f8fabf 100644 --- a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp +++ b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp @@ -824,13 +824,13 @@ class JobObject : public QObject Q_OBJECT public: - explicit JobObject(QEventLoop *loop, QObject *parent = 0) + explicit JobObject(QEventLoop *loop, QObject *parent = nullptr) : QObject(parent), locker(loop) { QTimer::singleShot(1000, this, SLOT(timeout())); } - explicit JobObject(QObject *parent = 0) + explicit JobObject(QObject *parent = nullptr) : QObject(parent) { QTimer::singleShot(1000, this, SLOT(timeout())); @@ -860,7 +860,7 @@ class QuitTester : public QObject { Q_OBJECT public: - QuitTester(QObject *parent = 0) + QuitTester(QObject *parent = nullptr) : QObject(parent) { QTimer::singleShot(0, this, SLOT(doTest())); diff --git a/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp b/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp index 3765b6fbf8..9d1153fe47 100644 --- a/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp +++ b/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp @@ -86,7 +86,7 @@ void EventLoopThread::run() emit checkPoint(); (void) eventLoop->exec(); delete eventLoop; - eventLoop = 0; + eventLoop = nullptr; } class MultipleExecThread : public QThread @@ -126,7 +126,7 @@ public: class StartStopEvent: public QEvent { public: - explicit StartStopEvent(int type, QEventLoop *loop = 0) + explicit StartStopEvent(int type, QEventLoop *loop = nullptr) : QEvent(Type(type)), el(loop) { } @@ -602,12 +602,12 @@ class JobObject : public QObject Q_OBJECT public: - explicit JobObject(QEventLoop *loop, QObject *parent = 0) + explicit JobObject(QEventLoop *loop, QObject *parent = nullptr) : QObject(parent), locker(loop) { } - explicit JobObject(QObject *parent = 0) + explicit JobObject(QObject *parent = nullptr) : QObject(parent) { } diff --git a/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp b/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp index fde1255443..c073e2d77f 100644 --- a/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp +++ b/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp @@ -90,7 +90,7 @@ namespace MyNamespace { MyFlags myFlags() const { return m_flags; } void setMyFlags(MyFlags val) { m_flags = val; } - MyClass(QObject *parent = 0) + MyClass(QObject *parent = nullptr) : QObject(parent), m_enum(MyEnum1), m_flags(MyFlag1|MyFlag2) @@ -139,7 +139,7 @@ namespace MyNamespace { MyFlags myFlags() const { return m_flags; } void setMyFlags(MyFlags val) { m_flags = val; } - MyClass2(QObject *parent = 0) + MyClass2(QObject *parent = nullptr) : QObject(parent), m_enum(MyEnum1), m_flags(MyFlag1|MyFlag2) @@ -699,24 +699,24 @@ void tst_QMetaObject::invokeMetaMember() QCOMPARE(exp, QString("yessir")); QCOMPARE(obj.slotResult, QString("sl1:bubu")); - QObject *ptr = 0; + QObject *ptr = nullptr; QVERIFY(QMetaObject::invokeMethod(&obj, "sl11", Q_RETURN_ARG(QObject*,ptr))); QCOMPARE(ptr, (QObject *)&obj); QCOMPARE(obj.slotResult, QString("sl11")); // try again with a space: - ptr = 0; + ptr = nullptr; QVERIFY(QMetaObject::invokeMethod(&obj, "sl11", Q_RETURN_ARG(QObject * , ptr))); QCOMPARE(ptr, (QObject *)&obj); QCOMPARE(obj.slotResult, QString("sl11")); - const char *ptr2 = 0; + const char *ptr2 = nullptr; QVERIFY(QMetaObject::invokeMethod(&obj, "sl12", Q_RETURN_ARG(const char*, ptr2))); - QVERIFY(ptr2 != 0); + QVERIFY(ptr2 != nullptr); QCOMPARE(obj.slotResult, QString("sl12")); // try again with a space: - ptr2 = 0; + ptr2 = nullptr; QVERIFY(QMetaObject::invokeMethod(&obj, "sl12", Q_RETURN_ARG(char const * , ptr2))); - QVERIFY(ptr2 != 0); + QVERIFY(ptr2 != nullptr); QCOMPARE(obj.slotResult, QString("sl12")); // test w/ template args @@ -1022,12 +1022,12 @@ void tst_QMetaObject::invokeBlockingQueuedMetaMember() QCOMPARE(exp, QString("yessir")); QCOMPARE(obj.slotResult, QString("sl1:bubu")); - QObject *ptr = 0; + QObject *ptr = nullptr; QVERIFY(QMetaObject::invokeMethod(&obj, "sl11", Qt::BlockingQueuedConnection, Q_RETURN_ARG(QObject*,ptr))); QCOMPARE(ptr, (QObject *)&obj); QCOMPARE(obj.slotResult, QString("sl11")); // try again with a space: - ptr = 0; + ptr = nullptr; QVERIFY(QMetaObject::invokeMethod(&obj, "sl11", Qt::BlockingQueuedConnection, Q_RETURN_ARG(QObject * , ptr))); QCOMPARE(ptr, (QObject *)&obj); QCOMPARE(obj.slotResult, QString("sl11")); @@ -1218,7 +1218,7 @@ class ConstructibleClass : public QObject { Q_OBJECT public: - Q_INVOKABLE ConstructibleClass(QObject *parent = 0) + Q_INVOKABLE ConstructibleClass(QObject *parent = nullptr) : QObject(parent) {} }; diff --git a/tests/auto/corelib/kernel/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp b/tests/auto/corelib/kernel/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp index 333c7931d9..2a26f5c4c2 100644 --- a/tests/auto/corelib/kernel/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp +++ b/tests/auto/corelib/kernel/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp @@ -1350,7 +1350,7 @@ private: //Q_PROPERTY(int intProp READ intProp WRITE setIntProp NOTIFY intPropChanged) public: - TestObject(QObject *parent = 0); // Q_INVOKABLE + TestObject(QObject *parent = nullptr); // Q_INVOKABLE ~TestObject(); // Property accessors diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp index ca215386fb..f116684f5b 100644 --- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp +++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp @@ -367,7 +367,7 @@ class CustomQObject : public QObject { Q_OBJECT public: - CustomQObject(QObject *parent = 0) + CustomQObject(QObject *parent = nullptr) : QObject(parent) { } @@ -1017,7 +1017,7 @@ class CustomObject : public QObject { Q_OBJECT public: - CustomObject(QObject *parent = 0) + CustomObject(QObject *parent = nullptr) : QObject(parent) { @@ -1031,7 +1031,7 @@ class CustomMultiInheritanceObject : public QObject, SecondBase { Q_OBJECT public: - CustomMultiInheritanceObject(QObject *parent = 0) + CustomMultiInheritanceObject(QObject *parent = nullptr) : QObject(parent) { @@ -1605,7 +1605,7 @@ class AutoMetaTypeObject : public QObject Q_PROPERTY(IntIntHash someHash READ someHash CONSTANT) Q_PROPERTY(NaturalNumber someInt READ someInt CONSTANT) public: - AutoMetaTypeObject(QObject *parent = 0) + AutoMetaTypeObject(QObject *parent = nullptr) : QObject(parent), m_int(42) { m_hash.insert(4, 2); @@ -1630,7 +1630,7 @@ class MyObject : public QObject { Q_OBJECT public: - MyObject(QObject *parent = 0) + MyObject(QObject *parent = nullptr) : QObject(parent) { } @@ -1781,7 +1781,7 @@ void tst_QMetaType::automaticTemplateRegistration() { typedef std::map<int, CustomObject*> StdMapIntCustomObject ; StdMapIntCustomObject intComparableMap; - CustomObject *o = 0; + CustomObject *o = nullptr; intComparableMap[4] = o; QCOMPARE(QVariant::fromValue(intComparableMap).value<StdMapIntCustomObject >()[4], o); } @@ -1822,7 +1822,7 @@ void tst_QMetaType::automaticTemplateRegistration() } { typedef std::pair<int, CustomQObject*> StdIntComparablePair; - CustomQObject* o = 0; + CustomQObject *o = nullptr; StdIntComparablePair intComparablePair = std::make_pair(4, o); QCOMPARE(QVariant::fromValue(intComparablePair).value<StdIntComparablePair>().first, 4); QCOMPARE(QVariant::fromValue(intComparablePair).value<StdIntComparablePair>().second, o); @@ -2099,7 +2099,7 @@ class MyQObjectFromGadget : public QObject, public MyGadget { Q_OBJECT public: - MyQObjectFromGadget(QObject *parent = 0) + MyQObjectFromGadget(QObject *parent = nullptr) : QObject(parent) {} }; diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp index 51df41f5ac..f4c028c83e 100644 --- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp +++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp @@ -537,7 +537,7 @@ void tst_QObject::findChildren() Q_SET_OBJECT_NAME(t121); emptyname.setObjectName(""); - QObject *op = 0; + QObject *op = nullptr; op = o.findChild<QObject*>("o1"); QCOMPARE(op, &o1); @@ -1430,7 +1430,7 @@ class QCustomTypeChecker: public QObject Q_OBJECT public: - QCustomTypeChecker(QObject *parent = 0): QObject(parent) {} + QCustomTypeChecker(QObject *parent = nullptr): QObject(parent) {} void doEmit(CustomType ct) { emit signal1(ct); } @@ -1638,8 +1638,8 @@ void tst_QObject::thread() QCOMPARE(child.thread(), object.thread()); } - QObject *object = 0; - QObject *child = 0; + QObject *object = nullptr; + QObject *child = nullptr; { TestThread thr; @@ -1681,12 +1681,12 @@ class MoveToThreadObject : public QObject { Q_OBJECT public: - QThread *timerEventThread; - QThread *customEventThread; - QThread *slotThread; + QThread *timerEventThread = nullptr; + QThread *customEventThread = nullptr; + QThread *slotThread = nullptr; - MoveToThreadObject(QObject *parent = 0) - : QObject(parent), timerEventThread(0), customEventThread(0), slotThread(0) + MoveToThreadObject(QObject *parent = nullptr) + : QObject(parent) { } void customEvent(QEvent *) override @@ -1969,7 +1969,7 @@ void tst_QObject::property() QCOMPARE(property.type(), QVariant::UserType); QCOMPARE(property.userType(), qMetaTypeId<CustomType*>()); - CustomType *customPointer = 0; + CustomType *customPointer = nullptr; QVariant customVariant = object.property("custom"); customPointer = qvariant_cast<CustomType *>(customVariant); QCOMPARE(customPointer, object.custom()); @@ -2166,7 +2166,7 @@ public: SuperObject() { - theSender = 0; + theSender = nullptr; theSignalId = 0; } @@ -2230,7 +2230,7 @@ void tst_QObject::senderTest() QCOMPARE(receiver->sender(), (QObject *)0); QCOMPARE(receiver->senderSignalIndex(), -1); - receiver->theSender = 0; + receiver->theSender = nullptr; receiver->theSignalId = -1; thread.start(); emit sender->theSignal(); @@ -3046,7 +3046,7 @@ class EventSpy : public QObject public: typedef QList<QPair<QObject *, QEvent::Type> > EventList; - EventSpy(QObject *parent = 0) + EventSpy(QObject *parent = nullptr) : QObject(parent) { } @@ -3582,9 +3582,9 @@ class OverloadObject : public QObject signals: void sig(int i, char c, qreal m = 12); void sig(int i, int j = 12); - void sig(QObject *o, QObject *p, QObject *q = 0, QObject *r = 0) const; + void sig(QObject *o, QObject *p, QObject *q = nullptr, QObject *r = nullptr) const; void other(int a = 0); - void sig(QObject *o, OverloadObject *p = 0, QObject *q = 0, QObject *r = nullptr); + void sig(QObject *o, OverloadObject *p = nullptr, QObject *q = nullptr, QObject *r = nullptr); void sig(double r = 0.5); public slots: void slo(int i, int j = 43) @@ -6160,7 +6160,7 @@ public slots: { if (abouttoblock) { abouttoblock->deleteLater(); - abouttoblock = 0; + abouttoblock = nullptr; } ++m_aboutToBlocks; } @@ -6168,7 +6168,7 @@ public slots: { if (awake) { awake->deleteLater(); - awake = 0; + awake = nullptr; } ++m_awakes; diff --git a/tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp b/tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp index ba973910a7..63e2f25d1d 100644 --- a/tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp +++ b/tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp @@ -98,7 +98,7 @@ void tst_QPointer::assignment_operators() QCOMPARE(p1, QPointer<QObject>(p2)); // Test assignment with a null pointer - p1 = 0; + p1 = nullptr; p2 = p1; QCOMPARE(p1, QPointer<QObject>(0)); QCOMPARE(p2, QPointer<QObject>(0)); @@ -131,9 +131,9 @@ void tst_QPointer::equality_operators() QVERIFY(p1 == p2); - QObject *object = 0; + QObject *object = nullptr; #ifndef QT_NO_WIDGETS - QWidget *widget = 0; + QWidget *widget = nullptr; #endif p1 = object; @@ -149,11 +149,15 @@ void tst_QPointer::equality_operators() QVERIFY(p1 == p2); // compare to zero - p1 = 0; + p1 = nullptr; QVERIFY(p1 == 0); QVERIFY(0 == p1); QVERIFY(p2 != 0); QVERIFY(0 != p2); + QVERIFY(p1 == nullptr); + QVERIFY(nullptr == p1); + QVERIFY(p2 != nullptr); + QVERIFY(nullptr != p2); QVERIFY(p1 == object); QVERIFY(object == p1); QVERIFY(p2 != object); @@ -188,7 +192,7 @@ void tst_QPointer::isNull() QVERIFY(p1.isNull()); p1 = this; QVERIFY(!p1.isNull()); - p1 = 0; + p1 = nullptr; QVERIFY(p1.isNull()); } diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp index ea8f26ae20..251bb803b4 100644 --- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp +++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp @@ -64,7 +64,7 @@ class tst_QVariant : public QObject Q_OBJECT public: - tst_QVariant(QObject *parent = 0) + tst_QVariant(QObject *parent = nullptr) : QObject(parent), customNonQObjectPointer(0) { @@ -2288,7 +2288,7 @@ void tst_QVariant::variantHash() class CustomQObject : public QObject { Q_OBJECT public: - CustomQObject(QObject *parent = 0) : QObject(parent) {} + CustomQObject(QObject *parent = nullptr) : QObject(parent) {} }; Q_DECLARE_METATYPE(CustomQObject*) @@ -2346,7 +2346,7 @@ void tst_QVariant::qvariant_cast_QObject() QVERIFY(data.canConvert<QObject*>()); QVERIFY(data.canConvert(QMetaType::QObjectStar)); QVERIFY(data.canConvert(::qMetaTypeId<QObject*>())); - QCOMPARE(data.value<QObject*>() == 0, isNull); + QCOMPARE(data.value<QObject*>() == nullptr, isNull); QVERIFY(data.convert(QMetaType::QObjectStar)); QCOMPARE(data.userType(), int(QMetaType::QObjectStar)); } else { @@ -2362,14 +2362,14 @@ void tst_QVariant::qvariant_cast_QObject() class CustomQObjectDerived : public CustomQObject { Q_OBJECT public: - CustomQObjectDerived(QObject *parent = 0) : CustomQObject(parent) {} + CustomQObjectDerived(QObject *parent = nullptr) : CustomQObject(parent) {} }; Q_DECLARE_METATYPE(CustomQObjectDerived*) class CustomQObjectDerivedNoMetaType : public CustomQObject { Q_OBJECT public: - CustomQObjectDerivedNoMetaType(QObject *parent = 0) : CustomQObject(parent) {} + CustomQObjectDerivedNoMetaType(QObject *parent = nullptr) : CustomQObject(parent) {} }; void tst_QVariant::qvariant_cast_QObject_derived() @@ -2404,7 +2404,7 @@ void tst_QVariant::qvariant_cast_QObject_derived() struct QObjectWrapper { - explicit QObjectWrapper(QObject *o = 0) : obj(o) {} + explicit QObjectWrapper(QObject *o = nullptr) : obj(o) {} QObject* getObject() const { return obj; @@ -2433,7 +2433,7 @@ class SmartPointer T* pointer; public: typedef T element_type; - explicit SmartPointer(T *t = 0) + explicit SmartPointer(T *t = nullptr) : pointer(t) { } @@ -2667,7 +2667,7 @@ void tst_QVariant::voidStar() const v2 = QVariant::fromValue(p2); QCOMPARE(v1, v2); - p2 = 0; + p2 = nullptr; v2 = QVariant::fromValue(p2); QVERIFY(v1 != v2); } @@ -3705,7 +3705,7 @@ Q_DECLARE_METATYPE(Forward*) void tst_QVariant::forwardDeclare() { - Forward *f = 0; + Forward *f = nullptr; QVariant v = QVariant::fromValue(f); QCOMPARE(qvariant_cast<Forward*>(v), f); } diff --git a/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp b/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp index 1a2a2a5324..0710e257b8 100644 --- a/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp +++ b/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp @@ -2526,7 +2526,7 @@ void tst_QDataStream::skipRawData() QFETCH(char, expect); qint8 dummy; - QIODevice *dev = 0; + QIODevice *dev = nullptr; if (deviceType == "sequential") { dev = new SequentialBuffer(&data); } else if (deviceType == "random-access") { diff --git a/tests/auto/corelib/serialization/qxmlstream/qc14n.h b/tests/auto/corelib/serialization/qxmlstream/qc14n.h index e4056fb0db..7fb27382aa 100644 --- a/tests/auto/corelib/serialization/qxmlstream/qc14n.h +++ b/tests/auto/corelib/serialization/qxmlstream/qc14n.h @@ -36,7 +36,7 @@ class QC14N public: static bool isEqual(QIODevice *const firstDocument, QIODevice *const secondDocument, - QString *const message = 0); + QString *const message = nullptr); private: static bool isDifferent(const QXmlStreamReader &r1, diff --git a/tests/auto/corelib/text/qlocale/tst_qlocale.cpp b/tests/auto/corelib/text/qlocale/tst_qlocale.cpp index 7d4cbbbcdd..7b69e2b8af 100644 --- a/tests/auto/corelib/text/qlocale/tst_qlocale.cpp +++ b/tests/auto/corelib/text/qlocale/tst_qlocale.cpp @@ -1265,7 +1265,7 @@ void tst_QLocale::strtod() QFETCH(bool, ok); QByteArray numData = num_str.toLatin1(); - const char *end = 0; + const char *end = nullptr; bool actualOk = false; double result = qstrtod(numData.constData(), &end, &actualOk); diff --git a/tests/auto/corelib/text/qstring/tst_qstring.cpp b/tests/auto/corelib/text/qstring/tst_qstring.cpp index 31f362888c..e63270bfe4 100644 --- a/tests/auto/corelib/text/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/text/qstring/tst_qstring.cpp @@ -4486,7 +4486,7 @@ void tst_QString::fromLatin1() void tst_QString::fromUcs4() { - const char32_t *null = 0; + const char32_t *null = nullptr; QString s; s = QString::fromUcs4( null ); QVERIFY( s.isNull() ); diff --git a/tests/auto/corelib/text/qstringbuilder/qstringbuilder1/stringbuilder.cpp b/tests/auto/corelib/text/qstringbuilder/qstringbuilder1/stringbuilder.cpp index c1a208bc62..66dfe3ce58 100644 --- a/tests/auto/corelib/text/qstringbuilder/qstringbuilder1/stringbuilder.cpp +++ b/tests/auto/corelib/text/qstringbuilder/qstringbuilder1/stringbuilder.cpp @@ -261,7 +261,7 @@ void runScenario() r = string P ba; QCOMPARE(r, string); - const char *zero = 0; + const char *zero = nullptr; r = string P zero; QCOMPARE(r, string); r = zero P string; @@ -300,7 +300,7 @@ void runScenario() r2 = QByteArray("hello\0") P UTF8_LITERAL; QCOMPARE(r, r2); - const char *zero = 0; + const char *zero = nullptr; r = ba P zero; QCOMPARE(r, ba); r = zero P ba; diff --git a/tests/auto/corelib/thread/qatomicint/tst_qatomicint.cpp b/tests/auto/corelib/thread/qatomicint/tst_qatomicint.cpp index ef00be31c5..260dbc30e8 100644 --- a/tests/auto/corelib/thread/qatomicint/tst_qatomicint.cpp +++ b/tests/auto/corelib/thread/qatomicint/tst_qatomicint.cpp @@ -85,7 +85,7 @@ private: }; template <int I> -static inline void assemblyMarker(void *ptr = 0) +static inline void assemblyMarker(void *ptr = nullptr) { puts((char *)ptr + I); } diff --git a/tests/auto/corelib/thread/qatomicpointer/tst_qatomicpointer.cpp b/tests/auto/corelib/thread/qatomicpointer/tst_qatomicpointer.cpp index bcc34a7d96..4361609442 100644 --- a/tests/auto/corelib/thread/qatomicpointer/tst_qatomicpointer.cpp +++ b/tests/auto/corelib/thread/qatomicpointer/tst_qatomicpointer.cpp @@ -77,8 +77,8 @@ void tst_QAtomicPointer::warningFreeHelper() p.loadRelaxed()->bar(); - WFHC *expectedValue = 0; - WFHC *newValue = 0; + WFHC *expectedValue = nullptr; + WFHC *newValue = nullptr; qptrdiff valueToAdd = 0; p.testAndSetRelaxed(expectedValue, newValue); @@ -585,7 +585,7 @@ void tst_QAtomicPointer::fetchAndAdd() template <typename T> void constAndVolatile_helper() { - T *one = 0; + T *one = nullptr; T *two = &one; T *three = &two; diff --git a/tests/auto/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp b/tests/auto/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp index f984aec0e8..76e50eee1b 100644 --- a/tests/auto/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp +++ b/tests/auto/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp @@ -864,7 +864,7 @@ private: void tst_QReadWriteLock::deleteOnUnlock() { - QReadWriteLock *lock = 0; + QReadWriteLock *lock = nullptr; QWaitCondition startup; QMutex waitMutex; diff --git a/tests/auto/corelib/thread/qsemaphore/tst_qsemaphore.cpp b/tests/auto/corelib/thread/qsemaphore/tst_qsemaphore.cpp index cf27c23591..f556e402e3 100644 --- a/tests/auto/corelib/thread/qsemaphore/tst_qsemaphore.cpp +++ b/tests/auto/corelib/thread/qsemaphore/tst_qsemaphore.cpp @@ -49,7 +49,7 @@ private slots: void raii(); }; -static QSemaphore *semaphore = 0; +static QSemaphore *semaphore = nullptr; class ThreadOne : public QThread { diff --git a/tests/auto/corelib/thread/qthread/tst_qthread.cpp b/tests/auto/corelib/thread/qthread/tst_qthread.cpp index 235fb093b5..1e8380fbba 100644 --- a/tests/auto/corelib/thread/qthread/tst_qthread.cpp +++ b/tests/auto/corelib/thread/qthread/tst_qthread.cpp @@ -429,7 +429,7 @@ void tst_QThread::exit() delete thread.object; Exit_Thread thread2; - thread2.object = 0; + thread2.object = nullptr; thread2.code = 53; thread2.result = 0; QMutexLocker locker2(&thread2.mutex); @@ -505,7 +505,7 @@ void tst_QThread::quit() delete thread.object; Quit_Thread thread2; - thread2.object = 0; + thread2.object = nullptr; thread2.result = -1; QMutexLocker locker2(&thread2.mutex); thread2.start(); @@ -647,8 +647,8 @@ class NativeThreadWrapper { public: NativeThreadWrapper() : qthread(0), waitForStop(false) {} - void start(FunctionPointer functionPointer = noop, void *data = 0); - void startAndWait(FunctionPointer functionPointer = noop, void *data = 0); + void start(FunctionPointer functionPointer = noop, void *data = nullptr); + void startAndWait(FunctionPointer functionPointer = noop, void *data = nullptr); void join(); void setWaitForStop() { waitForStop = true; } void stop(); @@ -1289,7 +1289,7 @@ class Job : public QObject { Q_OBJECT public: - Job(QThread *thread, int deleteDelay, bool *flag, QObject *parent = 0) + Job(QThread *thread, int deleteDelay, bool *flag, QObject *parent = nullptr) : QObject(parent), quitLocker(thread), exitThreadCalled(*flag) { exitThreadCalled = false; diff --git a/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp b/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp index 3054e3c5a4..e6db963c7b 100644 --- a/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp +++ b/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp @@ -107,7 +107,7 @@ private: }; -QMutex *tst_QThreadPool::functionTestMutex = 0; +QMutex *tst_QThreadPool::functionTestMutex = nullptr; tst_QThreadPool::tst_QThreadPool() { @@ -116,7 +116,7 @@ tst_QThreadPool::tst_QThreadPool() tst_QThreadPool::~tst_QThreadPool() { - tst_QThreadPool::functionTestMutex = 0; + tst_QThreadPool::functionTestMutex = nullptr; } int testFunctionCount; @@ -282,7 +282,7 @@ void tst_QThreadPool::destruction() } QSemaphore threadRecyclingSemaphore; -QThread *recycledThread = 0; +QThread *recycledThread = nullptr; class ThreadRecorderTask : public QRunnable { diff --git a/tests/auto/corelib/tools/collections/tst_collections.cpp b/tests/auto/corelib/tools/collections/tst_collections.cpp index e5cfb0fbad..1e01c5a484 100644 --- a/tests/auto/corelib/tools/collections/tst_collections.cpp +++ b/tests/auto/corelib/tools/collections/tst_collections.cpp @@ -812,7 +812,7 @@ void tst_Collections::vector() QVERIFY(LargeStatic::count == originalLargeStaticCount); { QVector<LargeStatic> vector; - LargeStatic *dummy = 0; + LargeStatic *dummy = nullptr; for (int i = 0; i < 10000; ++i) { delete dummy; dummy = new LargeStatic; @@ -834,7 +834,7 @@ void tst_Collections::vector() QVERIFY(Movable::count == originalMovableCount); { QVector<Movable> vector; - Movable *dummy = 0; + Movable *dummy = nullptr; for (int i = 0; i < 10000; ++i) { delete dummy; dummy = new Movable; @@ -2583,7 +2583,7 @@ void tst_Collections::list_stl() } template <typename T> -T qtInit(T * = 0) +T qtInit(T * = nullptr) { return T(); } @@ -2593,9 +2593,9 @@ void tst_Collections::q_init() QCOMPARE(qtInit<int>(), 0); QCOMPARE(qtInit<double>(), 0.0); QCOMPARE(qtInit<QString>(), QString()); - QCOMPARE(qtInit<int *>(), static_cast<int *>(0)); - QCOMPARE(qtInit<double *>(), static_cast<double *>(0)); - QCOMPARE(qtInit<QString *>(), static_cast<QString *>(0)); + QCOMPARE(qtInit<int *>(), static_cast<int *>(nullptr)); + QCOMPARE(qtInit<double *>(), static_cast<double *>(nullptr)); + QCOMPARE(qtInit<QString *>(), static_cast<QString *>(nullptr)); QCOMPARE(qtInit<Pod>().i1, 0); QCOMPARE(qtInit<Pod>().i2, 0); } diff --git a/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp b/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp index e0062b9118..76ae592011 100644 --- a/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp +++ b/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp @@ -167,42 +167,42 @@ void tst_QAlgorithms::swap() } { - void *a = 0, *b = 0; + void *a = nullptr, *b = nullptr; qSwap(a, b); } { - const void *a = 0, *b = 0; + const void *a = nullptr, *b = nullptr; qSwap(a, b); } { - QString *a = 0, *b = 0; + QString *a = nullptr, *b = nullptr; qSwap(a, b); } { - const QString *a = 0, *b = 0; + const QString *a = nullptr, *b = nullptr; qSwap(a, b); } { - QString **a = 0, **b = 0; + QString **a = nullptr, **b = nullptr; qSwap(a, b); } { - const QString **a = 0, **b = 0; + const QString **a = nullptr, **b = nullptr; qSwap(a, b); } { - QString * const *a = 0, * const *b = 0; + QString * const *a = nullptr, * const *b = nullptr; qSwap(a, b); } { - const QString * const *a = 0, * const *b = 0; + const QString * const *a = nullptr, * const *b = nullptr; qSwap(a, b); } } diff --git a/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp b/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp index 90fadbb628..069f990e2c 100644 --- a/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp +++ b/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp @@ -501,7 +501,7 @@ class tst_QEasingProperties : public QObject Q_OBJECT Q_PROPERTY(QEasingCurve easing READ easing WRITE setEasing) public: - tst_QEasingProperties(QObject *parent = 0) : QObject(parent) {} + tst_QEasingProperties(QObject *parent = nullptr) : QObject(parent) {} QEasingCurve easing() const { return e; } void setEasing(const QEasingCurve& value) { e = value; } diff --git a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp index 4ca7940556..06c4091232 100644 --- a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp +++ b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp @@ -2251,12 +2251,12 @@ void tst_QSharedPointer::invalidConstructs_data() QTest::newRow("weak-pointer-from-regular-pointer") << &QTest::QExternalTest::tryCompileFail - << "Data *ptr = 0;\n" + << "Data *ptr = nullptr;\n" "QWeakPointer<Data> weakptr(ptr);\n"; QTest::newRow("shared-pointer-implicit-from-uninitialized") << &QTest::QExternalTest::tryCompileFail - << "Data *ptr = 0;\n" + << "Data *ptr = nullptr;\n" "QSharedPointer<Data> weakptr = Qt::Uninitialized;\n"; QTest::newRow("incompatible-custom-deleter1") |