Skip to content

Commit

Permalink
Fix Qt6 compilation warnings around QVariant/QMetaType
Browse files Browse the repository at this point in the history
  • Loading branch information
dfaure-kdab committed Sep 24, 2023
1 parent bd66a42 commit 22c0a14
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/KDSoapClient/KDSoapMessageReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,12 @@ static KDSoapValue parseElement(QXmlStreamReader &reader, const QXmlStreamNamesp
val.setNamespaceDeclarations(reader.namespaceDeclarations());
val.setEnvironmentNamespaceDeclarations(combinedNamespaceDeclarations);
// qDebug() << "parsing" << name;
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QVariant::Type metaTypeId = QVariant::Invalid;
#else
QMetaType::Type metaTypeId = QMetaType::UnknownType;
#endif
const auto invalidType = metaTypeId;

const QXmlStreamAttributes attributes = reader.attributes();
for (const QXmlStreamAttribute &attribute : attributes) {
Expand All @@ -86,7 +91,7 @@ static KDSoapValue parseElement(QXmlStreamReader &reader, const QXmlStreamNamesp
const int pos = type.indexOf(QLatin1Char(':'));
const QString dataType = type.mid(pos + 1);
val.setType(namespaceForPrefix(combinedNamespaceDeclarations, type.left(pos)).toString(), dataType);
metaTypeId = static_cast<QVariant::Type>(xmlTypeToMetaType(dataType));
metaTypeId = static_cast<decltype(metaTypeId)>(xmlTypeToMetaType(dataType));
}
continue;
} else if (ns == KDSoapNamespaceManager::soapEncoding() || ns == KDSoapNamespaceManager::soapEncoding200305()
Expand Down Expand Up @@ -115,9 +120,13 @@ static KDSoapValue parseElement(QXmlStreamReader &reader, const QXmlStreamNamesp
// qDebug() << text << variant << metaTypeId;
// With use=encoded, we have type info, we can convert the variant here
// Otherwise, for servers, we do it later, once we know the method's parameter types.
if (metaTypeId != QVariant::Invalid) {
if (metaTypeId != invalidType) {
QVariant copy = variant;
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
if (!variant.convert(metaTypeId)) {
#else
if (!variant.convert(QMetaType(metaTypeId))) {
#endif
variant = copy;
}
}
Expand Down

0 comments on commit 22c0a14

Please sign in to comment.