Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.9.2
-
None
-
834258bb3d17638e8e3dc2eca2a3115006c092fd (qt/qtserialbus/5.12)
Description
// code placeholder void BlockedModbusMaster::waitFinished (QModbusReply *reply) { if (reply != nullptr) { while (!reply->isFinished()) { QEventLoop loop; connect(reply, SIGNAL(finished()), &loop, SLOT(quit()), Qt::QueuedConnection); connect(reply, SIGNAL(errorOccurred(QModbusDevice::Error)), &loop, SLOT(quit()), Qt::QueuedConnection); qDebug("enter loop"); loop.exec(); qDebug("exit loop"); } } }
Above is my code, and I found the loop never quit after the
QModbusRtuSerialMaster was closed via disconnectDevice.
I viewed the qtserialbus source code, in the file "qmodbusrtuserialmaster_p.h", the object "m_current" was unhandled when the serialport was aboutToClose. I think this is exactly the reason why the QModbusReply never finished, am I correct?
// code placeholder QObject::connect(m_serialPort, &QSerialPort::aboutToClose, q, [this]() { Q_Q(QModbusRtuSerialMaster); Q_UNUSED(q); // To avoid unused variable warning in release mode Q_ASSERT(q->state() == QModbusDevice::ClosingState); m_sendTimer.stop(); m_responseTimer.stop(); });
Attachments
For Gerrit Dashboard: QTBUG-68543 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
243001,6 | Ensure QModbusReply::finished() is emitted after disconnect from serial | 5.12 | qt/qtserialbus | Status: MERGED | +2 | 0 |