diff options
author | Mårten Nordheim <marten.nordheim@qt.io> | 2020-05-05 14:27:57 +0200 |
---|---|---|
committer | Mårten Nordheim <marten.nordheim@qt.io> | 2020-05-05 16:44:36 +0200 |
commit | 393fcf8a64748f0c59f47d254667518dba9e2fc3 (patch) | |
tree | 6e2c31ad35f37894fb8527444c6a0e1d5d3b17c4 /src/websockets/qwebsocketdataprocessor.cpp | |
parent | b93474cc1a5e5800cad676954c0bbf56f72e946b (diff) | |
download | qtwebsockets-393fcf8a64748f0c59f47d254667518dba9e2fc3.tar.gz |
Make sure child QObjects get moved-to-thread along with the owner
By parenting them. And to do that without crashing they need to be
allocated dynamically.
A couple missed "parenting"s caused the object to not be moved to the
other thread when the websocket was moved. This caused it to print
warnings when the timer was started and stopped since this cannot be
done across threads.
Fixes: QTBUG-83722
Pick-to: 5.15
Change-Id: Iee60fe1c498f8f6d1e0c2cfcb2923bd5b9560acb
Reviewed-by: Jesus Fernandez <jsfdez@gmail.com>
Diffstat (limited to 'src/websockets/qwebsocketdataprocessor.cpp')
-rw-r--r-- | src/websockets/qwebsocketdataprocessor.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/websockets/qwebsocketdataprocessor.cpp b/src/websockets/qwebsocketdataprocessor.cpp index 4110f2a..0d2e927 100644 --- a/src/websockets/qwebsocketdataprocessor.cpp +++ b/src/websockets/qwebsocketdataprocessor.cpp @@ -84,13 +84,14 @@ QWebSocketDataProcessor::QWebSocketDataProcessor(QObject *parent) : m_textMessage(), m_payloadLength(0), m_pConverterState(nullptr), - m_pTextCodec(QTextCodec::codecForName("UTF-8")) + m_pTextCodec(QTextCodec::codecForName("UTF-8")), + m_waitTimer(new QTimer(this)) { clear(); // initialize the internal timeout timer - waitTimer.setInterval(5000); - waitTimer.setSingleShot(true); - waitTimer.callOnTimeout(this, &QWebSocketDataProcessor::timeout); + m_waitTimer->setInterval(5000); + m_waitTimer->setSingleShot(true); + m_waitTimer->callOnTimeout(this, &QWebSocketDataProcessor::timeout); } /*! @@ -163,8 +164,8 @@ bool QWebSocketDataProcessor::process(QIODevice *pIoDevice) if (!frame.isDone()) { // waiting for more data available QObject::connect(pIoDevice, &QIODevice::readyRead, - &waitTimer, &QTimer::stop, Qt::UniqueConnection); - waitTimer.start(); + m_waitTimer, &QTimer::stop, Qt::UniqueConnection); + m_waitTimer->start(); return false; } else if (Q_LIKELY(frame.isValid())) { if (frame.isControlFrame()) { |