summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2021-07-02 13:06:33 +0200
committerUlf Hermann <ulf.hermann@qt.io>2021-07-02 13:20:03 +0200
commitc38a132dacb8250cd957f4f2ef5f1b40f9daf26b (patch)
tree5cb955e151b14a0703fe3ffdf77d45b84e313356
parent331cb9088048154db4338d46cf96b7ff61ad1b5b (diff)
Avoid further implicit constructions of QString from const char *
Change-Id: I35085649ee1b258669a834928dab3c9661d61257 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
-rw-r--r--src/imports/opcua/opcuaconnection.cpp4
-rw-r--r--src/imports/opcua/opcuapathresolver.cpp5
-rw-r--r--src/imports/opcua/universalnode.cpp8
3 files changed, 9 insertions, 8 deletions
diff --git a/src/imports/opcua/opcuaconnection.cpp b/src/imports/opcua/opcuaconnection.cpp
index 5735335..e0f7a93 100644
--- a/src/imports/opcua/opcuaconnection.cpp
+++ b/src/imports/opcua/opcuaconnection.cpp
@@ -467,7 +467,7 @@ bool OpcUaConnection::readNodeAttributes(const QJSValue &value)
QList<QOpcUaReadItem> readItemList;
- for (int i = 0; i < value.property("length").toInt(); ++i){
+ for (int i = 0, end = value.property(QStringLiteral("length")).toInt(); i < end; ++i){
const auto &readItem = qjsvalue_cast<OpcUaReadItem>(value.property(i));
if (readItem.nodeId().isEmpty()) {
qCWarning(QT_OPCUA_PLUGINS_QML) << tr("Invalid ReadItem in list of items at index %1").arg(i);
@@ -552,7 +552,7 @@ bool OpcUaConnection::writeNodeAttributes(const QJSValue &value)
QList<QOpcUaWriteItem> writeItemList;
- for (int i = 0; i < value.property("length").toInt(); ++i){
+ for (int i = 0, end = value.property(QStringLiteral("length")).toInt(); i < end; ++i) {
const auto &writeItem = qjsvalue_cast<OpcUaWriteItem>(value.property(i));
if (writeItem.nodeId().isEmpty()) {
qCWarning(QT_OPCUA_PLUGINS_QML) << tr("Invalid WriteItem in list of items at index %1").arg(i);
diff --git a/src/imports/opcua/opcuapathresolver.cpp b/src/imports/opcua/opcuapathresolver.cpp
index 95b09e9..068df80 100644
--- a/src/imports/opcua/opcuapathresolver.cpp
+++ b/src/imports/opcua/opcuapathresolver.cpp
@@ -173,7 +173,8 @@ void OpcUaPathResolver::browsePathFinished(QList<QOpcUaBrowsePathTarget> results
UniversalNode nodeToUse;
if (status != QOpcUa::Good) {
- const char *name = QMetaEnum::fromType<QOpcUa::UaStatusCode>().valueToKey(status);
+ const QString name = QString::fromUtf8(
+ QMetaEnum::fromType<QOpcUa::UaStatusCode>().valueToKey(status));
emit resolvedNode(UniversalNode(),
QStringLiteral("Resolving browse path return error code %1").arg(name));
deleteLater();
@@ -197,7 +198,7 @@ void OpcUaPathResolver::browsePathFinished(QList<QOpcUaBrowsePathTarget> results
} else { // greater than one
UniversalNode tmp;
- QString message = "No resolved node found";
+ QString message = QStringLiteral("No resolved node found");
for (const auto &result : results) {
if (result.isFullyResolved()) {
diff --git a/src/imports/opcua/universalnode.cpp b/src/imports/opcua/universalnode.cpp
index 5531a2c..2b96381 100644
--- a/src/imports/opcua/universalnode.cpp
+++ b/src/imports/opcua/universalnode.cpp
@@ -274,14 +274,14 @@ void UniversalNode::from(const UniversalNode &other)
QString UniversalNode::fullNodeId() const
{
if (!m_namespaceIndexValid || m_nodeIdentifier.isEmpty()) {
- QString message("Unable to construct a full node id");
+ QString message = QStringLiteral("Unable to construct a full node id");
if (!m_nodeIdentifier.isEmpty())
- message += " for node " + m_nodeIdentifier;
+ message += QStringLiteral(" for node ") + m_nodeIdentifier;
else
- message += " because node id string is empty.";
+ message += QStringLiteral(" because node id string is empty.");
if (!m_namespaceIndexValid)
- message += "; namespace index is not valid.";
+ message += QStringLiteral("; namespace index is not valid.");
qCWarning(QT_OPCUA_PLUGINS_QML) << message;
return QString();
}