mirror of
https://github.com/barry-ran/QtScrcpy.git
synced 2025-07-31 21:08:38 +00:00
解决退出时解码线程死锁问题
This commit is contained in:
parent
2f81e7372b
commit
3e906c51d3
2 changed files with 9 additions and 2 deletions
|
@ -18,6 +18,9 @@ DeviceSocket::~DeviceSocket()
|
||||||
|
|
||||||
qint32 DeviceSocket::recvData(quint8 *buf, qint32 bufSize)
|
qint32 DeviceSocket::recvData(quint8 *buf, qint32 bufSize)
|
||||||
{
|
{
|
||||||
|
if (m_quit) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
QMutexLocker locker(&m_mutex);
|
QMutexLocker locker(&m_mutex);
|
||||||
|
|
||||||
m_buffer = buf;
|
m_buffer = buf;
|
||||||
|
@ -63,6 +66,7 @@ void DeviceSocket::onReadyRead()
|
||||||
|
|
||||||
void DeviceSocket::quitNotify()
|
void DeviceSocket::quitNotify()
|
||||||
{
|
{
|
||||||
|
m_quit = true;
|
||||||
QMutexLocker locker(&m_mutex);
|
QMutexLocker locker(&m_mutex);
|
||||||
if (m_buffer) {
|
if (m_buffer) {
|
||||||
m_buffer = Q_NULLPTR;
|
m_buffer = Q_NULLPTR;
|
||||||
|
|
|
@ -18,10 +18,12 @@ public:
|
||||||
protected:
|
protected:
|
||||||
bool event(QEvent *event);
|
bool event(QEvent *event);
|
||||||
|
|
||||||
protected slots:
|
public slots:
|
||||||
void onReadyRead();
|
|
||||||
void quitNotify();
|
void quitNotify();
|
||||||
|
|
||||||
|
protected slots:
|
||||||
|
void onReadyRead();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QMutex m_mutex;
|
QMutex m_mutex;
|
||||||
QWaitCondition m_recvDataCond;
|
QWaitCondition m_recvDataCond;
|
||||||
|
@ -29,6 +31,7 @@ private:
|
||||||
quint8* m_buffer = Q_NULLPTR;
|
quint8* m_buffer = Q_NULLPTR;
|
||||||
qint32 m_bufferSize = 0;
|
qint32 m_bufferSize = 0;
|
||||||
qint32 m_dataSize = 0;
|
qint32 m_dataSize = 0;
|
||||||
|
bool m_quit = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DEVICESOCKET_H
|
#endif // DEVICESOCKET_H
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue