diff options
author | Ulf Hermann <ulf.hermann@theqtcompany.com> | 2015-07-13 15:56:25 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@theqtcompany.com> | 2015-07-31 06:44:13 +0000 |
commit | cc3a57861d5ef6e84cef0adfa1aaf726dd2b9d84 (patch) | |
tree | ef5c3983cda85022afd077fe05a2cb850aa0274b /tests | |
parent | 4d07a6254cac5742ffc23377b97c6eaf04aa4c49 (diff) |
Use signal/slot for passing messages through QQmlDebugServer
This results in much cleaner code than the previous implementation
using QMetaObject::invokeMethod().
We have to use read locks now for adding and removing engines, as we
should have done already before. If a condition is waiting on a write
lock you cannot acquire a read lock from another thread. So, if we kept
the write locks we wouldn't be able to receive messages while the engines
are waiting.
Change-Id: Icfe641601dec2f8d7181ae579146ed603d57a4c2
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'tests')
3 files changed, 2 insertions, 10 deletions
diff --git a/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp b/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp index 6ae59078f6..b63c5c0a6d 100644 --- a/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp +++ b/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp @@ -178,7 +178,7 @@ void tst_QQmlDebugService::sendMessage() QTest::ignoreMessage(QtWarningMsg, "QQmlDebugService: Conflicting plugin name \"tst_QQmlDebugService\""); QQmlDebugTestService duplicate("tst_QQmlDebugService"); - duplicate.sendMessage("msg"); + emit duplicate.messageToClient(duplicate.name(), "msg"); QTest::ignoreMessage(QtWarningMsg, "QQmlDebugService: Plugin \"tst_QQmlDebugService\" is not registered."); } diff --git a/tests/auto/qml/debugger/shared/qqmldebugtestservice.cpp b/tests/auto/qml/debugger/shared/qqmldebugtestservice.cpp index 94eaa2c083..e62aa2ce61 100644 --- a/tests/auto/qml/debugger/shared/qqmldebugtestservice.cpp +++ b/tests/auto/qml/debugger/shared/qqmldebugtestservice.cpp @@ -42,7 +42,7 @@ QQmlDebugTestService::QQmlDebugTestService(const QString &s, float version, QObj void QQmlDebugTestService::messageReceived(const QByteArray &ba) { Q_ASSERT(QThread::currentThread() != thread()); - QMetaObject::invokeMethod(this, "_sendMessage", Qt::QueuedConnection, Q_ARG(QByteArray, ba)); + emit messageToClient(name(), ba); } void QQmlDebugTestService::stateAboutToBeChanged(QQmlDebugService::State) @@ -55,8 +55,3 @@ void QQmlDebugTestService::stateChanged(State) Q_ASSERT(QThread::currentThread() != thread()); emit stateHasChanged(); } - -void QQmlDebugTestService::_sendMessage(const QByteArray &msg) -{ - QQmlDebugService::sendMessage(msg); -} diff --git a/tests/auto/qml/debugger/shared/qqmldebugtestservice.h b/tests/auto/qml/debugger/shared/qqmldebugtestservice.h index 7cb09798de..cc24f3c119 100644 --- a/tests/auto/qml/debugger/shared/qqmldebugtestservice.h +++ b/tests/auto/qml/debugger/shared/qqmldebugtestservice.h @@ -46,9 +46,6 @@ public: signals: void stateHasChanged(); -private slots: - void _sendMessage(const QByteArray &msg); - protected: virtual void messageReceived(const QByteArray &ba); virtual void stateAboutToBeChanged(State state); |