From 3e906c51d387d7244c1b56c4d873a54ef24243c6 Mon Sep 17 00:00:00 2001 From: Barry <870709864@qq.com> Date: Thu, 22 Nov 2018 22:57:08 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E9=80=80=E5=87=BA=E6=97=B6?= =?UTF-8?q?=E8=A7=A3=E7=A0=81=E7=BA=BF=E7=A8=8B=E6=AD=BB=E9=94=81=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- QtScrcpy/server/devicesocket.cpp | 4 ++++ QtScrcpy/server/devicesocket.h | 7 +++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/QtScrcpy/server/devicesocket.cpp b/QtScrcpy/server/devicesocket.cpp index debe994..ebc3518 100644 --- a/QtScrcpy/server/devicesocket.cpp +++ b/QtScrcpy/server/devicesocket.cpp @@ -18,6 +18,9 @@ DeviceSocket::~DeviceSocket() qint32 DeviceSocket::recvData(quint8 *buf, qint32 bufSize) { + if (m_quit) { + return 0; + } QMutexLocker locker(&m_mutex); m_buffer = buf; @@ -63,6 +66,7 @@ void DeviceSocket::onReadyRead() void DeviceSocket::quitNotify() { + m_quit = true; QMutexLocker locker(&m_mutex); if (m_buffer) { m_buffer = Q_NULLPTR; diff --git a/QtScrcpy/server/devicesocket.h b/QtScrcpy/server/devicesocket.h index bb83d36..87dcd2d 100644 --- a/QtScrcpy/server/devicesocket.h +++ b/QtScrcpy/server/devicesocket.h @@ -18,10 +18,12 @@ public: protected: bool event(QEvent *event); -protected slots: - void onReadyRead(); +public slots: void quitNotify(); +protected slots: + void onReadyRead(); + private: QMutex m_mutex; QWaitCondition m_recvDataCond; @@ -29,6 +31,7 @@ private: quint8* m_buffer = Q_NULLPTR; qint32 m_bufferSize = 0; qint32 m_dataSize = 0; + bool m_quit = false; }; #endif // DEVICESOCKET_H