diff options
author | Jannis Voelker <jannis.voelker@basyskom.com> | 2018-04-03 11:48:22 +0200 |
---|---|---|
committer | Frank Meerkoetter <frank.meerkoetter@basyskom.com> | 2018-04-05 19:54:41 +0000 |
commit | 2a17f34290fd9a57ecbd21a21616e356145743d5 (patch) | |
tree | 3ddfbd6cf16acbf3cc9822530213a5518cece690 | |
parent | 59656d562b31b1ff576b43cc40bad5789c80babd (diff) |
Disable the open62541 client state handler during connect and disconnectv5.11.0-beta3
This prevents emitting duplicate signals when the disconnect state is
reached.
The destructor of OpcuaConnector in tst_client.cpp is extended to verify
that no client error signals have been emitted (which is what happens if
the client state handler and the disconnect method both emit a signal).
Change-Id: I4aa03e63b402b09b497c4c482747b4ac258eecdb
Reviewed-by: Frank Meerkoetter <frank.meerkoetter@basyskom.com>
-rw-r--r-- | src/plugins/opcua/open62541/qopen62541backend.cpp | 4 | ||||
-rw-r--r-- | tests/auto/qopcuaclient/tst_client.cpp | 2 |
2 files changed, 6 insertions, 0 deletions
diff --git a/src/plugins/opcua/open62541/qopen62541backend.cpp b/src/plugins/opcua/open62541/qopen62541backend.cpp index ec0eb09..9fcd8d3 100644 --- a/src/plugins/opcua/open62541/qopen62541backend.cpp +++ b/src/plugins/opcua/open62541/qopen62541backend.cpp @@ -437,6 +437,8 @@ void Open62541AsyncBackend::connectToEndpoint(const QUrl &url) if (m_uaclient) UA_Client_delete(m_uaclient); + m_useStateCallback = false; + UA_ClientConfig conf = UA_ClientConfig_default; conf.clientContext = this; conf.stateCallback = &clientStateCallback; @@ -469,6 +471,8 @@ void Open62541AsyncBackend::disconnectFromEndpoint() m_subscriptions.clear(); m_attributeMapping.clear(); + m_useStateCallback = false; + if (m_uaclient) { UA_StatusCode ret = UA_Client_disconnect(m_uaclient); if (ret != UA_STATUSCODE_GOOD) { diff --git a/tests/auto/qopcuaclient/tst_client.cpp b/tests/auto/qopcuaclient/tst_client.cpp index 0e243d5..069ea75 100644 --- a/tests/auto/qopcuaclient/tst_client.cpp +++ b/tests/auto/qopcuaclient/tst_client.cpp @@ -83,6 +83,7 @@ public: QSignalSpy connectedSpy(opcuaClient, &QOpcUaClient::connected); QSignalSpy disconnectedSpy(opcuaClient, &QOpcUaClient::disconnected); QSignalSpy stateSpy(opcuaClient, &QOpcUaClient::stateChanged); + QSignalSpy errorSpy(opcuaClient, &QOpcUaClient::errorChanged); QVERIFY(opcuaClient != nullptr); if (opcuaClient->state() == QOpcUaClient::Connected) { @@ -98,6 +99,7 @@ public: QOpcUaClient::ClientState::Closing); QCOMPARE(stateSpy.at(1).at(0).value<QOpcUaClient::ClientState>(), QOpcUaClient::ClientState::Disconnected); + QCOMPARE(errorSpy.size(), 0); } opcuaClient = nullptr; |