From 37d15b2f0bcda4918b0788d7b2c3cd96bb5eb1ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98ystein=20Heskestad?= Date: Tue, 23 Mar 2021 09:19:05 +0100 Subject: Replace Q_NULLPTR with nullptr and fix a warning * The warning was that a QJsonValue reference was used when iterating over a QJsonArray Task-number: QTBUG-91757 Change-Id: I72fefb0b1d119da565b6dd1bcbada4fa874fd94e Reviewed-by: Allan Sandfeld Jensen --- src/webchannel/qmetaobjectpublisher.cpp | 14 +++++++------- src/webchannel/qqmlwebchannel.h | 2 +- src/webchannel/qwebchannel.h | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/webchannel/qmetaobjectpublisher.cpp b/src/webchannel/qmetaobjectpublisher.cpp index 6cf9487..f61c2f0 100644 --- a/src/webchannel/qmetaobjectpublisher.cpp +++ b/src/webchannel/qmetaobjectpublisher.cpp @@ -207,7 +207,7 @@ void QMetaObjectPublisher::registerObject(const QString &id, QObject *object) qWarning("Registered new object after initialization, existing clients won't be notified!"); // TODO: send a message to clients that an object was added } - initializePropertyUpdates(object, classInfoForObject(object, Q_NULLPTR)); + initializePropertyUpdates(object, classInfoForObject(object, nullptr)); } } @@ -333,7 +333,7 @@ QJsonObject QMetaObjectPublisher::initializeClient(QWebChannelAbstractTransport void QMetaObjectPublisher::initializePropertyUpdates(const QObject *const object, const QJsonObject &objectInfo) { - for (const QJsonValue &propertyInfoVar : objectInfo[KEY_PROPERTIES].toArray()) { + for (const auto propertyInfoVar : objectInfo[KEY_PROPERTIES].toArray()) { const QJsonArray &propertyInfo = propertyInfoVar.toArray(); if (propertyInfo.size() < 2) { qWarning() << "Invalid property info encountered:" << propertyInfoVar; @@ -389,7 +389,7 @@ void QMetaObjectPublisher::sendPendingPropertyUpdates() for (const int propertyIndex : objectsSignalToPropertyMap.value(sigIt.key())) { const QMetaProperty &property = metaObject->property(propertyIndex); Q_ASSERT(property.isValid()); - properties[QString::number(propertyIndex)] = wrapResult(property.read(object), Q_NULLPTR, objectId); + properties[QString::number(propertyIndex)] = wrapResult(property.read(object), nullptr, objectId); } sigs[QString::number(sigIt.key())] = QJsonArray::fromVariantList(sigIt.value()); } @@ -555,7 +555,7 @@ void QMetaObjectPublisher::signalEmitted(const QObject *object, const int signal message[KEY_OBJECT] = objectName; message[KEY_SIGNAL] = signalIndex; if (!arguments.isEmpty()) { - message[KEY_ARGS] = wrapList(arguments, Q_NULLPTR, objectName); + message[KEY_ARGS] = wrapList(arguments, nullptr, objectName); } message[KEY_TYPE] = TypeSignal; @@ -609,7 +609,7 @@ QObject *QMetaObjectPublisher::unwrapObject(const QString &objectId) const } qWarning() << "No wrapped object" << objectId; - return Q_NULLPTR; + return nullptr; } QVariant QMetaObjectPublisher::unwrapMap(QVariantMap map) const @@ -665,7 +665,7 @@ QVariant QMetaObjectPublisher::toVariant(const QJsonValue &value, int targetType return QVariant::fromValue(value.toObject()); } else if (target.flags() & QMetaType::PointerToQObject) { QObject *unwrappedObject = unwrapObject(value.toObject()[KEY_ID].toString()); - if (unwrappedObject == Q_NULLPTR) + if (unwrappedObject == nullptr) qWarning() << "Cannot not convert non-object argument" << value << "to QObject*."; return QVariant::fromValue(unwrappedObject); } else if (isQFlagsType(targetType)) { @@ -702,7 +702,7 @@ int QMetaObjectPublisher::conversionScore(const QJsonValue &value, int targetTyp return IncompatibleScore; QObject *unwrappedObject = unwrapObject(object[KEY_ID].toString()); - return unwrappedObject != Q_NULLPTR ? PerfectMatchScore : IncompatibleScore; + return unwrappedObject != nullptr ? PerfectMatchScore : IncompatibleScore; } else if (targetType == QMetaType::QVariant) { return VariantScore; } diff --git a/src/webchannel/qqmlwebchannel.h b/src/webchannel/qqmlwebchannel.h index 72d067a..bacf0df 100644 --- a/src/webchannel/qqmlwebchannel.h +++ b/src/webchannel/qqmlwebchannel.h @@ -59,7 +59,7 @@ class Q_WEBCHANNEL_EXPORT QQmlWebChannel : public QWebChannel Q_PROPERTY( QQmlListProperty registeredObjects READ registeredObjects ) public: - explicit QQmlWebChannel(QObject *parent = Q_NULLPTR); + explicit QQmlWebChannel(QObject *parent = nullptr); virtual ~QQmlWebChannel(); Q_INVOKABLE void registerObjects(const QVariantMap &objects); diff --git a/src/webchannel/qwebchannel.h b/src/webchannel/qwebchannel.h index 44dd8b6..19d2862 100644 --- a/src/webchannel/qwebchannel.h +++ b/src/webchannel/qwebchannel.h @@ -57,7 +57,7 @@ class Q_WEBCHANNEL_EXPORT QWebChannel : public QObject Q_DISABLE_COPY(QWebChannel) Q_PROPERTY(bool blockUpdates READ blockUpdates WRITE setBlockUpdates NOTIFY blockUpdatesChanged) public: - explicit QWebChannel(QObject *parent = Q_NULLPTR); + explicit QWebChannel(QObject *parent = nullptr); ~QWebChannel(); void registerObjects(const QHash &objects); @@ -78,7 +78,7 @@ public Q_SLOTS: private: Q_DECLARE_PRIVATE(QWebChannel) - QWebChannel(QWebChannelPrivate &dd, QObject *parent = Q_NULLPTR); + QWebChannel(QWebChannelPrivate &dd, QObject *parent = nullptr); Q_PRIVATE_SLOT(d_func(), void _q_transportDestroyed(QObject*)) friend class QMetaObjectPublisher; -- cgit v1.2.1