From 43666b086041c9c3a7647e33a3662c38dc4e3590 Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Sun, 31 May 2020 15:13:51 +0200 Subject: [PATCH] Add explicit quit command when removing a wallpaper --- ScreenPlay/src/sdkconnector.h | 10 ++++++++++ ScreenPlaySDK/screenplaysdk.cpp | 9 +++++++++ 2 files changed, 19 insertions(+) diff --git a/ScreenPlay/src/sdkconnector.h b/ScreenPlay/src/sdkconnector.h index 157fafd9..2f7b81fd 100644 --- a/ScreenPlay/src/sdkconnector.h +++ b/ScreenPlay/src/sdkconnector.h @@ -188,6 +188,16 @@ public slots: void close() { + + qInfo() << "Close " << m_type; + + QJsonObject obj; + obj.insert("command", QJsonValue("quit")); + QByteArray command = QJsonDocument(obj).toJson(); + + m_socket->write(command); + m_socket->waitForBytesWritten(); + if (m_socket->state() == QLocalSocket::ConnectedState) { m_socket->disconnectFromServer(); m_socket->close(); diff --git a/ScreenPlaySDK/screenplaysdk.cpp b/ScreenPlaySDK/screenplaysdk.cpp index d007b0de..08b25451 100644 --- a/ScreenPlaySDK/screenplaysdk.cpp +++ b/ScreenPlaySDK/screenplaysdk.cpp @@ -77,6 +77,15 @@ void ScreenPlaySDK::readyRead() return; } QJsonObject ob = doc.object(); + + if(ob.size() == 1){ + if(ob.contains("command")){ + if(ob.value("command") == "quit"){ + emit sdkDisconnected(); + return; + } + } + } QJsonObject::iterator iterator; for (iterator = ob.begin(); iterator != ob.end(); iterator++) { emit incommingMessage(iterator.key(), ob.value(iterator.key()).toString());