From e7ecd6730fa988f078f8fc052e94086f5acbcdac Mon Sep 17 00:00:00 2001 From: Dorian Zedler Date: Mon, 6 Apr 2020 22:53:58 +0200 Subject: [PATCH] another small patch --- ScStwLibraries/scstwclient.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/ScStwLibraries/scstwclient.cpp b/ScStwLibraries/scstwclient.cpp index 03e4dcf..6af3d44 100644 --- a/ScStwLibraries/scstwclient.cpp +++ b/ScStwLibraries/scstwclient.cpp @@ -187,6 +187,7 @@ void ScStwClient::handleSocketStateChange(QAbstractSocket::SocketState socketSta switch (socketState) { case QAbstractSocket::UnconnectedState: { + this->deInit(); break; } case QAbstractSocket::ConnectedState: @@ -289,6 +290,8 @@ void ScStwClient::handleSocketMessage(QString reply) { reply.replace(ScStw::SOCKET_MESSAGE_START_KEY, ""); reply.replace(ScStw::SOCKET_MESSAGE_END_KEY, ""); + //qDebug() << "got message: " << reply; + int id = 0; QJsonDocument jsonReply = QJsonDocument::fromJson(reply.toUtf8()); @@ -320,7 +323,13 @@ void ScStwClient::handleSocketMessage(QString reply) { void ScStwClient::handleSignal(QVariantMap data) { // get the signal type - ScStw::SignalKey signalKey = ScStw::SignalKey(data["header"].toInt()); + if(ScStw::signalKeyFromInt(data["header"].toInt()) == ScStw::InvalidSignal) + return; + + ScStw::SignalKey signalKey = ScStw::signalKeyFromInt(data["header"].toInt()); + + //qDebug() << "got signal: " << signalKey << " with data: " << data["data"]; + switch (signalKey) { case ScStw::ExtensionsChanged: { @@ -432,9 +441,6 @@ void ScStwClient::setState(ScStwClient::State newState){ qDebug() << "+--- ScStwClient state changed: " << newState; this->state = newState; emit stateChanged(); - if(this->state == DISCONNECTED) { - this->deInit(); - } } }