summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2022-10-05 08:21:25 +0200
committerMarc Mutz <marc.mutz@qt.io>2022-10-07 17:15:50 +0200
commit290e04469a3d8e19c0a7017138ae7d4e812615e1 (patch)
treec49ad30f842563ad659ebf8272fcbcebb4b92be1
parent0cc735971ac07e93525690efb778c6bd7c3bcbd2 (diff)
downloadqtwebchannel-290e04469a3d8e19c0a7017138ae7d4e812615e1.tar.gz
Port from container::count() and length() to size()
This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8: auto QtContainerClass = anyOf( expr(hasType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))))).bind(o), expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o)); makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container', with the extended set of container classes recognized. Change-Id: I34d5ddf6742eda92ae291d2fd0ced98fcee92b7b Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
-rw-r--r--src/webchannel/qmetaobjectpublisher.cpp4
-rw-r--r--src/webchannel/signalhandler_p.h4
-rw-r--r--tests/auto/webchannel/tst_webchannel.cpp6
3 files changed, 7 insertions, 7 deletions
diff --git a/src/webchannel/qmetaobjectpublisher.cpp b/src/webchannel/qmetaobjectpublisher.cpp
index e27d620..b1fed71 100644
--- a/src/webchannel/qmetaobjectpublisher.cpp
+++ b/src/webchannel/qmetaobjectpublisher.cpp
@@ -152,7 +152,7 @@ QMetaType resultTypeOfQFuture(QByteArrayView typeName)
if (!typeName.startsWith("QFuture<") || !typeName.endsWith('>'))
return {};
- return QMetaType::fromName(typeName.sliced(8, typeName.length() - 9));
+ return QMetaType::fromName(typeName.sliced(8, typeName.size() - 9));
}
template<typename Func>
@@ -302,7 +302,7 @@ QJsonObject QMetaObjectPublisher::classInfoForObject(const QObject *object, QWeb
// optimize: compress the common propertyChanged notification names, just send a 1
const QByteArray &notifySignal = prop.notifySignal().name();
static const QByteArray changedSuffix = QByteArrayLiteral("Changed");
- if (notifySignal.length() == changedSuffix.length() + propertyName.length() &&
+ if (notifySignal.size() == changedSuffix.size() + propertyName.size() &&
notifySignal.endsWith(changedSuffix) && notifySignal.startsWith(prop.name()))
{
signalInfo.append(1);
diff --git a/src/webchannel/signalhandler_p.h b/src/webchannel/signalhandler_p.h
index 876413d..f5a378a 100644
--- a/src/webchannel/signalhandler_p.h
+++ b/src/webchannel/signalhandler_p.h
@@ -195,9 +195,9 @@ void SignalHandler<Receiver>::dispatch(const QObject *object, const int signalId
}
const QList<int> &argumentTypes = *signalIt;
QVariantList arguments;
- arguments.reserve(argumentTypes.count());
+ arguments.reserve(argumentTypes.size());
// TODO: basic overload resolution based on number of arguments?
- for (int i = 0; i < argumentTypes.count(); ++i) {
+ for (int i = 0; i < argumentTypes.size(); ++i) {
const QMetaType::Type type = static_cast<QMetaType::Type>(argumentTypes.at(i));
QVariant arg;
if (type == QMetaType::QVariant) {
diff --git a/tests/auto/webchannel/tst_webchannel.cpp b/tests/auto/webchannel/tst_webchannel.cpp
index 780d045..d628937 100644
--- a/tests/auto/webchannel/tst_webchannel.cpp
+++ b/tests/auto/webchannel/tst_webchannel.cpp
@@ -976,7 +976,7 @@ void TestWebChannel::testWrapObjectWithMultipleTransports()
pub->wrapResult(QVariant::fromValue(&obj), dummyTransport);
pub->wrapResult(QVariant::fromValue(&obj), dummyTransport2);
- QCOMPARE(pub->transportedWrappedObjects.count(), 2);
+ QCOMPARE(pub->transportedWrappedObjects.size(), 2);
}
void TestWebChannel::testJsonToVariant_data()
@@ -1545,9 +1545,9 @@ void TestWebChannel::qtbug46548_overriddenProperties()
QSignalSpy spy(&engine, &TestJSEngine::channelSetupReady);
connect(&engine, &TestJSEngine::channelSetupReady, TestSubclassedFunctor(&engine));
engine.initWebChannelJS();
- if (!spy.count())
+ if (!spy.size())
spy.wait();
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QJSValue subclassedTestObject = engine.evaluate("channel.objects[\"subclassedTestObject\"]");
QVERIFY(subclassedTestObject.isObject());