Changeset View
Changeset View
Standalone View
Standalone View
core/backends/lan/socketlinereader.cpp
Show All 28 Lines | 28 | connect(m_socket, &QIODevice::readyRead, | |||
---|---|---|---|---|---|
29 | this, &SocketLineReader::dataReceived); | 29 | this, &SocketLineReader::dataReceived); | ||
30 | } | 30 | } | ||
31 | 31 | | |||
32 | void SocketLineReader::dataReceived() | 32 | void SocketLineReader::dataReceived() | ||
33 | { | 33 | { | ||
34 | while (m_socket->canReadLine()) { | 34 | while (m_socket->canReadLine()) { | ||
35 | const QByteArray line = m_socket->readLine(); | 35 | const QByteArray line = m_socket->readLine(); | ||
36 | if (line.length() > 1) { //we don't want a single \n | 36 | if (line.length() > 1) { //we don't want a single \n | ||
37 | m_packages.enqueue(line); | 37 | m_packets.enqueue(line); | ||
38 | } | 38 | } | ||
39 | } | 39 | } | ||
40 | 40 | | |||
41 | //If we still have things to read from the socket, call dataReceived again | 41 | //If we still have things to read from the socket, call dataReceived again | ||
42 | //We do this manually because we do not trust readyRead to be emitted again | 42 | //We do this manually because we do not trust readyRead to be emitted again | ||
43 | //So we call this method again just in case. | 43 | //So we call this method again just in case. | ||
44 | if (m_socket->bytesAvailable() > 0) { | 44 | if (m_socket->bytesAvailable() > 0) { | ||
45 | QMetaObject::invokeMethod(this, "dataReceived", Qt::QueuedConnection); | 45 | QMetaObject::invokeMethod(this, "dataReceived", Qt::QueuedConnection); | ||
46 | return; | 46 | return; | ||
47 | } | 47 | } | ||
48 | 48 | | |||
49 | //If we have any packages, tell it to the world. | 49 | //If we have any packets, tell it to the world. | ||
50 | if (!m_packages.isEmpty()) { | 50 | if (!m_packets.isEmpty()) { | ||
51 | Q_EMIT readyRead(); | 51 | Q_EMIT readyRead(); | ||
52 | } | 52 | } | ||
53 | } | 53 | } |