diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2018-02-21 10:41:54 +0100 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2018-02-26 07:13:18 +0000 |
commit | 499ec43937e926e4f2fa57a9baa455fcb3862262 (patch) | |
tree | 206c90d47387f8322b68f5e3db613189397e1af3 /tests/auto/qml/qjsengine | |
parent | 53d1e9ed21d25e65a2f13606af479838f5f21fe7 (diff) |
use nullptr consistently (clang-tidy)
From now on we prefer nullptr instead of 0 to clarify cases where
we are assigning or testing a pointer rather than a numeric zero.
Also, replaced cases where 0 was passed as Qt::KeyboardModifiers
with Qt::NoModifier (clang-tidy replaced them with nullptr, which
waas wrong, so it was just as well to make the tests more readable
rather than to revert those lines).
Change-Id: I4735d35e4d9f42db5216862ce091429eadc6e65d
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'tests/auto/qml/qjsengine')
-rw-r--r-- | tests/auto/qml/qjsengine/tst_qjsengine.cpp | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp index 519c57efb2..b34aaea61c 100644 --- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp +++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp @@ -615,10 +615,10 @@ void tst_QJSEngine::newQObject() QObject temp; { - QJSValue qobject = eng.newQObject(0); + QJSValue qobject = eng.newQObject(nullptr); QCOMPARE(qobject.isNull(), true); QCOMPARE(qobject.isObject(), false); - QCOMPARE(qobject.toQObject(), (QObject *)0); + QCOMPARE(qobject.toQObject(), (QObject *)nullptr); } { QJSValue qobject = eng.newQObject(&temp); @@ -639,7 +639,7 @@ void tst_QJSEngine::newQObject_ownership() QJSEngine eng; { QPointer<QObject> ptr = new QObject(); - QVERIFY(ptr != 0); + QVERIFY(ptr != nullptr); { QJSValue v = eng.newQObject(ptr); } @@ -650,7 +650,7 @@ void tst_QJSEngine::newQObject_ownership() } { QPointer<QObject> ptr = new QObject(this); - QVERIFY(ptr != 0); + QVERIFY(ptr != nullptr); { QJSValue v = eng.newQObject(ptr); } @@ -665,11 +665,11 @@ void tst_QJSEngine::newQObject_ownership() QJSValue v = eng.newQObject(child); QCOMPARE(v.toQObject(), child); delete parent; - QCOMPARE(v.toQObject(), (QObject *)0); + QCOMPARE(v.toQObject(), (QObject *)nullptr); } { QPointer<QObject> ptr = new QObject(); - QVERIFY(ptr != 0); + QVERIFY(ptr != nullptr); { QJSValue v = eng.newQObject(ptr); } @@ -682,18 +682,18 @@ void tst_QJSEngine::newQObject_ownership() { QObject *parent = new QObject(); QPointer<QObject> child = new QObject(parent); - QVERIFY(child != 0); + QVERIFY(child != nullptr); { QJSValue v = eng.newQObject(child); } eng.collectGarbage(); // has parent, so it should be like QtOwnership - QVERIFY(child != 0); + QVERIFY(child != nullptr); delete parent; } { QPointer<QObject> ptr = new QObject(); - QVERIFY(ptr != 0); + QVERIFY(ptr != nullptr); { QQmlEngine::setObjectOwnership(ptr.data(), QQmlEngine::CppOwnership); QJSValue v = eng.newQObject(ptr); @@ -1377,7 +1377,7 @@ void tst_QJSEngine::valueConversion_basic() QCOMPARE(eng.fromScriptValue<QChar>(eng.toScriptValue(c)), c); } - QVERIFY(eng.toScriptValue(static_cast<void *>(0)).isNull()); + QVERIFY(eng.toScriptValue(static_cast<void *>(nullptr)).isNull()); } void tst_QJSEngine::valueConversion_QVariant() @@ -1463,7 +1463,7 @@ void tst_QJSEngine::valueConversion_QVariant() QCOMPARE(qjsvalue_cast<QVariant>(QJSValue(123)), QVariant(123)); - QVERIFY(eng.toScriptValue(QVariant(QMetaType::VoidStar, 0)).isNull()); + QVERIFY(eng.toScriptValue(QVariant(QMetaType::VoidStar, nullptr)).isNull()); QVERIFY(eng.toScriptValue(QVariant::fromValue(nullptr)).isNull()); { @@ -1574,7 +1574,7 @@ class Klazz : public QWidget, Q_INTERFACES(QGraphicsItem) Q_OBJECT public: - Klazz(QWidget *parent = 0) : QWidget(parent) { } + Klazz(QWidget *parent = nullptr) : QWidget(parent) { } virtual QRectF boundingRect() const { return QRectF(); } virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) { } }; @@ -1603,7 +1603,7 @@ void tst_QJSEngine::collectGarbage() a = eng.newObject(); a = eng.newObject(); QPointer<QObject> ptr = new QObject(); - QVERIFY(ptr != 0); + QVERIFY(ptr != nullptr); (void)eng.newQObject(ptr); eng.collectGarbage(); if (ptr) @@ -3372,7 +3372,7 @@ void tst_QJSEngine::dynamicProperties() QQmlEngine qmlEngine; QQmlComponent component(&qmlEngine); component.setData("import QtQml 2.0; QtObject { property QtObject subObject: QtObject {} }", QUrl()); - QObject *root = component.create(0); + QObject *root = component.create(nullptr); QVERIFY(root); QVERIFY(qmlContext(root)); |