From b5f50cd68f4c1cf769e9c96359dee1ae36c2e026 Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Sun, 3 Mar 2024 15:37:31 -0800 Subject: [PATCH] fix(socket): clear buffer when closing/opening socket --- src/io/datastream.hpp | 2 +- src/io/socket.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/io/datastream.hpp b/src/io/datastream.hpp index 13baf28..24aa54a 100644 --- a/src/io/datastream.hpp +++ b/src/io/datastream.hpp @@ -37,7 +37,7 @@ protected: private slots: void onReaderDestroyed(); -private: +protected: DataStreamParser* mReader = nullptr; QByteArray buffer; }; diff --git a/src/io/socket.cpp b/src/io/socket.cpp index e2ecfb5..0270316 100644 --- a/src/io/socket.cpp +++ b/src/io/socket.cpp @@ -41,6 +41,7 @@ void Socket::setPath(QString path) { } void Socket::onSocketConnected() { + this->buffer.clear(); this->connected = true; this->targetConnected = false; this->disconnecting = false; @@ -52,6 +53,7 @@ void Socket::onSocketDisconnected() { this->disconnecting = false; this->socket->deleteLater(); this->socket = nullptr; + this->buffer.clear(); emit this->connectionStateChanged(); if (this->targetConnected) this->connectPathSocket();