diff --git a/ScreenPlay/src/screenplaywallpaper.cpp b/ScreenPlay/src/screenplaywallpaper.cpp index 3a51cd06..fbe3e8e8 100644 --- a/ScreenPlay/src/screenplaywallpaper.cpp +++ b/ScreenPlay/src/screenplaywallpaper.cpp @@ -149,9 +149,11 @@ void ScreenPlayWallpaper::close() return; } - if (m_connection->close()) { - m_isExiting = true; + if (!m_connection->close()) { + qCritical() << "Cannot close wallpaper!"; + return; } + m_isExiting = true; } /*! \brief Prints the exit code if != 0. diff --git a/ScreenPlay/src/sdkconnection.cpp b/ScreenPlay/src/sdkconnection.cpp index dd1c1cac..5652b401 100644 --- a/ScreenPlay/src/sdkconnection.cpp +++ b/ScreenPlay/src/sdkconnection.cpp @@ -113,6 +113,10 @@ bool ScreenPlay::SDKConnection::close() qWarning() << "Cannot close invalid socket."; return false; } + QJsonObject obj; + obj.insert("command", "quit"); + m_socket->write(QByteArray(QJsonDocument(obj).toJson(QJsonDocument::Compact))); + m_socket->flush(); qInfo() << "Close " << m_type << m_appID << m_socket->state(); m_socket->disconnectFromServer(); diff --git a/ScreenPlaySDK/src/screenplaysdk.cpp b/ScreenPlaySDK/src/screenplaysdk.cpp index 4d088bea..6a982053 100644 --- a/ScreenPlaySDK/src/screenplaysdk.cpp +++ b/ScreenPlaySDK/src/screenplaysdk.cpp @@ -32,6 +32,9 @@ void ScreenPlaySDK::start() connect(&m_socket, &QLocalSocket::connected, this, &ScreenPlaySDK::connected); connect(&m_socket, &QLocalSocket::disconnected, this, &ScreenPlaySDK::disconnected); connect(&m_socket, &QLocalSocket::readyRead, this, &ScreenPlaySDK::readyRead); + connect(&m_socket, &QLocalSocket::errorOccurred, this, [this](){ + emit disconnected(); + }); m_socket.connectToServer("ScreenPlay"); if (!m_socket.waitForConnected(1000)){