diff options
author | Antti Hölttä <AHoelttae@luxoft.com> | 2018-04-09 11:49:24 +0200 |
---|---|---|
committer | Antti Hölttä <ahoelttae@luxoft.com> | 2018-04-09 12:28:33 +0000 |
commit | e898bd625306a294cb85d716f9a95275578e0d46 (patch) | |
tree | 729a7dc358f40ae57092cd5f6f4814d6475bda08 | |
parent | fd53d8a1277c02978518bf66feec0fdf3c7da6b6 (diff) |
Fix bug with qtro-backend's pending replies
Calling a method through a remote backend now returns directly a failed reply
if the client-server connection is not valid.
Change-Id: I7be9dc5c71f111497ed03547bf1c0bc2457f9f43
Reviewed-by: Dominik Holland <dominik.holland@pelagicore.com>
-rw-r--r-- | src/tools/ivigenerator/templates_backend_qtro/backend.cpp.tpl | 3 | ||||
-rw-r--r-- | tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/tst_echoqtro.cpp | 4 |
2 files changed, 7 insertions, 0 deletions
diff --git a/src/tools/ivigenerator/templates_backend_qtro/backend.cpp.tpl b/src/tools/ivigenerator/templates_backend_qtro/backend.cpp.tpl index ac99d59..33f65dd 100644 --- a/src/tools/ivigenerator/templates_backend_qtro/backend.cpp.tpl +++ b/src/tools/ivigenerator/templates_backend_qtro/backend.cpp.tpl @@ -106,6 +106,9 @@ void {{class}}::set{{property|upperfirst}}({{ property|parameter_type }}) {% set operation_parameters = operation.parameters|map('parameter_type')|join(', ') %} QIviPendingReply<{{operation|return_type}}> {{class}}::{{operation}}({{operation_parameters}}){%if operation.const %} const{% endif %} { + if (m_replica->state() != QRemoteObjectReplica::Valid) + return QIviPendingReply<{{operation|return_type}}>::createFailedReply(); + QIviPendingReply<{{operation|return_type}}> iviReply; {% if not operation.type.is_void %} QRemoteObjectPendingReply<{{operation|return_type}}> reply = m_replica->{{operation}}({{operation.parameters|join(', ')}}); diff --git a/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/tst_echoqtro.cpp b/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/tst_echoqtro.cpp index 7e5fa90..3883b60 100644 --- a/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/tst_echoqtro.cpp +++ b/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/tst_echoqtro.cpp @@ -139,6 +139,10 @@ void EchoQtroTest::testReconnect() QCOMPARE(disconnectSpy.count(), 1); QCOMPARE(client.error(), QIviAbstractFeature::Unknown); + //test that a remote call fails on a disconnected replica + QIviPendingReply<QString> idReply = client.id(); + QVERIFY(idReply.isResultAvailable() && !idReply.watcher()->isSuccessful()); + //test reconnection QSignalSpy reconnectSpy(&client, SIGNAL(errorChanged(QIviAbstractFeature::Error,QString))); QVERIFY(reconnectSpy.isValid()); |