From fcd6ac231d160afd5c11cc5ef515dcc61c3eca3f Mon Sep 17 00:00:00 2001 From: Denis Shienkov Date: Fri, 9 Sep 2016 08:53:20 +0300 Subject: Fix crash after closing of ejected device on Linux When the user calls QSP::close() in a slot which is connected to the QSP::error() signal, then the application is crashed. The reason is that we emit the QSP::error() signal before than we call QRingBuffer::chop() of an internal read buffer, which becomes invalid after the QIODevice::close() called. Therefore, we need just call QRingBuffer::chop() before than the QSP::error() signal will be emitted. Task-number: QTBUG-55847 Change-Id: If536f9cf5cbc1b813d3642bdf9be0867e06368e8 Reviewed-by: Sergey Belyashov Reviewed-by: Alex Trotsenko Reviewed-by: Denis Shienkov --- src/serialport/qserialport_unix.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/serialport/qserialport_unix.cpp b/src/serialport/qserialport_unix.cpp index 8e06adac..fafe8c54 100644 --- a/src/serialport/qserialport_unix.cpp +++ b/src/serialport/qserialport_unix.cpp @@ -778,6 +778,8 @@ bool QSerialPortPrivate::readNotification() char *ptr = buffer.reserve(bytesToRead); const qint64 readBytes = readFromPort(ptr, bytesToRead); + buffer.chop(bytesToRead - qMax(readBytes, qint64(0))); + if (readBytes <= 0) { QSerialPortErrorInfo error = getSystemError(); if (error.errorCode != QSerialPort::ResourceError) @@ -785,12 +787,9 @@ bool QSerialPortPrivate::readNotification() else setReadNotificationEnabled(false); setError(error); - buffer.chop(bytesToRead); return false; } - buffer.chop(bytesToRead - qMax(readBytes, qint64(0))); - newBytes = buffer.size() - newBytes; // If read buffer is full, disable the read port notifier. -- cgit v1.2.3 From dee818e77a6cf9a6c164fbc7ee132fe875f7f998 Mon Sep 17 00:00:00 2001 From: Denis Shienkov Date: Sat, 10 Sep 2016 20:56:42 +0300 Subject: Do not reset RTS after changing other properties on Windows Changing any of serial port properties drops RTS, which has been set earlier, since the fRtsControl field of DCB structure always has RTS_CONTROL_DISABLE value (except hardware flow control). Thus, using one EscapeCommFunction() function inside of QSP::setRequestToSend() method is not enough. We need set there also the fRtsControl field to RTS_CONTROL_ENABLE(DISABLE) value and keep it unchanged. Task-number: QTBUG-55907 Change-Id: I7e407b0de9f970f5d11f61c0e360d4735a0acb84 Reviewed-by: Sergey Belyashov Reviewed-by: Denis Shienkov --- src/serialport/qserialport_win.cpp | 13 ++++++-- tests/auto/qserialport/tst_qserialport.cpp | 53 ++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 2 deletions(-) diff --git a/src/serialport/qserialport_win.cpp b/src/serialport/qserialport_win.cpp index 9ab44487..84bf5b90 100644 --- a/src/serialport/qserialport_win.cpp +++ b/src/serialport/qserialport_win.cpp @@ -90,6 +90,9 @@ static inline void qt_set_common_props(DCB *dcb) if (dcb->fDtrControl == DTR_CONTROL_HANDSHAKE) dcb->fDtrControl = DTR_CONTROL_DISABLE; + + if (dcb->fRtsControl != RTS_CONTROL_HANDSHAKE) + dcb->fRtsControl = RTS_CONTROL_DISABLE; } static inline void qt_set_baudrate(DCB *dcb, qint32 baudrate) @@ -152,7 +155,8 @@ static inline void qt_set_flowcontrol(DCB *dcb, QSerialPort::FlowControl flowcon dcb->fInX = FALSE; dcb->fOutX = FALSE; dcb->fOutxCtsFlow = FALSE; - dcb->fRtsControl = RTS_CONTROL_DISABLE; + if (dcb->fRtsControl == RTS_CONTROL_HANDSHAKE) + dcb->fRtsControl = RTS_CONTROL_DISABLE; switch (flowcontrol) { case QSerialPort::NoFlowControl: break; @@ -278,7 +282,12 @@ bool QSerialPortPrivate::setRequestToSend(bool set) return false; } - return true; + DCB dcb; + if (!getDcb(&dcb)) + return false; + + dcb.fRtsControl = set ? RTS_CONTROL_ENABLE : RTS_CONTROL_DISABLE; + return setDcb(&dcb); } bool QSerialPortPrivate::flush() diff --git a/tests/auto/qserialport/tst_qserialport.cpp b/tests/auto/qserialport/tst_qserialport.cpp index 33a48fe5..94eaaa5c 100644 --- a/tests/auto/qserialport/tst_qserialport.cpp +++ b/tests/auto/qserialport/tst_qserialport.cpp @@ -98,6 +98,7 @@ private slots: void rts(); void dtr(); + void independenceRtsAndDtr(); void flush(); void doubleFlush(); @@ -549,6 +550,58 @@ void tst_QSerialPort::dtr() QCOMPARE(qvariant_cast(dtrSpy.at(2).at(0)), toggle3); } +void tst_QSerialPort::independenceRtsAndDtr() +{ + QSerialPort serialPort(m_senderPortName); + QVERIFY(serialPort.open(QIODevice::ReadWrite)); // No flow control by default! + + QVERIFY(serialPort.setDataTerminalReady(true)); + QVERIFY(serialPort.setRequestToSend(true)); + QVERIFY(serialPort.isDataTerminalReady()); + QVERIFY(serialPort.isRequestToSend()); + + // check that DTR changing does not change RTS + QVERIFY(serialPort.setDataTerminalReady(false)); + QVERIFY(!serialPort.isDataTerminalReady()); + QVERIFY(serialPort.isRequestToSend()); + QVERIFY(serialPort.setDataTerminalReady(true)); + QVERIFY(serialPort.isDataTerminalReady()); + QVERIFY(serialPort.isRequestToSend()); + + // check that RTS changing does not change DTR + QVERIFY(serialPort.setRequestToSend(false)); + QVERIFY(!serialPort.isRequestToSend()); + QVERIFY(serialPort.isDataTerminalReady()); + QVERIFY(serialPort.setRequestToSend(true)); + QVERIFY(serialPort.isRequestToSend()); + QVERIFY(serialPort.isDataTerminalReady()); + + // check that baud rate changing does not change DTR or RTS + QVERIFY(serialPort.setBaudRate(115200)); + QVERIFY(serialPort.isRequestToSend()); + QVERIFY(serialPort.isDataTerminalReady()); + + // check that data bits changing does not change DTR or RTS + QVERIFY(serialPort.setDataBits(QSerialPort::Data7)); + QVERIFY(serialPort.isRequestToSend()); + QVERIFY(serialPort.isDataTerminalReady()); + + // check that parity changing does not change DTR or RTS + QVERIFY(serialPort.setParity(QSerialPort::EvenParity)); + QVERIFY(serialPort.isRequestToSend()); + QVERIFY(serialPort.isDataTerminalReady()); + + // check that stop bits changing does not change DTR or RTS + QVERIFY(serialPort.setStopBits(QSerialPort::TwoStop)); + QVERIFY(serialPort.isRequestToSend()); + QVERIFY(serialPort.isDataTerminalReady()); + + // check that software flow control changing does not change DTR or RTS + QVERIFY(serialPort.setFlowControl(QSerialPort::SoftwareControl)); + QVERIFY(serialPort.isRequestToSend()); + QVERIFY(serialPort.isDataTerminalReady()); +} + void tst_QSerialPort::handleBytesWrittenAndExitLoopSlot(qint64 bytesWritten) { QCOMPARE(bytesWritten, qint64(alphabetArray.size() + newlineArray.size())); -- cgit v1.2.3 From 0b9f41c28cece4fe51011083e646aba405ec3a65 Mon Sep 17 00:00:00 2001 From: Jani Heikkinen Date: Thu, 20 Oct 2016 13:30:34 +0300 Subject: Add changes file for 5.7.1 Change-Id: I85decd74c3fff4ee1710af8c38b435f57da3b610 Reviewed-by: Denis Shienkov --- dist/changes-5.7.1 | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 dist/changes-5.7.1 diff --git a/dist/changes-5.7.1 b/dist/changes-5.7.1 new file mode 100644 index 00000000..e9bf6684 --- /dev/null +++ b/dist/changes-5.7.1 @@ -0,0 +1,27 @@ +Qt 5.7.1 is a bug-fix release. It maintains both forward and backward +compatibility (source and binary) with Qt 5.7.0. + +For more details, refer to the online documentation included in this +distribution. The documentation is also available online: + +http://doc.qt.io/qt-5/index.html + +The Qt version 5.7 series is binary compatible with the 5.6.x series. +Applications compiled for 5.6 will continue to run with 5.7. + +Some of the changes listed in this file include issue tracking numbers +corresponding to tasks in the Qt Bug Tracker: + +https://bugreports.qt.io/ + +Each of these identifiers can be entered in the bug tracker to obtain more +information about a particular change. + +**************************************************************************** +* Library * +**************************************************************************** + + - QSerialPort: + * [QTBUG-55847] Fixed crash after closing of ejected device on Linux. + * [QTBUG-55907] Now the RTS does not resets after changing of other + properties on Windows. -- cgit v1.2.3 From 3bd025649c0641e11ae557544d9949d5dcc6cf51 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 3 Nov 2016 18:23:58 +0100 Subject: remove dependencies from sync.profile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit the CI obtains them from the qt5 super repo nowadays. Change-Id: Ibde79e1be1701519505020d31c6d713ae2af4830 Reviewed-by: Jędrzej Nowacki --- sync.profile | 4 ---- 1 file changed, 4 deletions(-) diff --git a/sync.profile b/sync.profile index a1e480d7..bcd9ff65 100644 --- a/sync.profile +++ b/sync.profile @@ -1,7 +1,3 @@ %modules = ( "QtSerialPort" => "$basedir/src/serialport", ); - -%dependencies = ( - "qtbase" => "", -); -- cgit v1.2.3