summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2017-01-25 10:26:13 +0100
committerLiang Qi <liang.qi@qt.io>2017-01-25 10:26:13 +0100
commit4458f9376aa88b556e38d81180c5966889009bfb (patch)
tree44b5b9921eb4f9cf5030317685544c4d20820935
parent23902340662f1ef6f5dafe68a34b593aed6ea497 (diff)
parentf640521532087dc76d36b25a6c49b2f64afcd4de (diff)
Merge remote-tracking branch 'origin/5.8' into devv5.9.0-alpha1
Conflicts: .qmake.conf Change-Id: Ie713faf0d6395f11477fceb35c93388756e33fae
-rw-r--r--dist/changes-5.7.127
-rw-r--r--examples/serialport/terminal/mainwindow.cpp2
-rw-r--r--src/serialport/qserialport.cpp87
-rw-r--r--src/serialport/qserialport_unix.cpp5
-rw-r--r--src/serialport/qserialport_win.cpp13
-rw-r--r--src/serialport/qserialportinfo.cpp16
-rw-r--r--sync.profile4
-rw-r--r--tests/auto/qserialport/tst_qserialport.cpp53
8 files changed, 148 insertions, 59 deletions
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.
diff --git a/examples/serialport/terminal/mainwindow.cpp b/examples/serialport/terminal/mainwindow.cpp
index 996b3d6c..f6e86cc2 100644
--- a/examples/serialport/terminal/mainwindow.cpp
+++ b/examples/serialport/terminal/mainwindow.cpp
@@ -178,7 +178,7 @@ void MainWindow::initActionsConnections()
connect(ui->actionConnect, &QAction::triggered, this, &MainWindow::openSerialPort);
connect(ui->actionDisconnect, &QAction::triggered, this, &MainWindow::closeSerialPort);
connect(ui->actionQuit, &QAction::triggered, this, &MainWindow::close);
- connect(ui->actionConfigure, &QAction::triggered, settings, &MainWindow::show);
+ connect(ui->actionConfigure, &QAction::triggered, settings, &SettingsDialog::show);
connect(ui->actionClear, &QAction::triggered, console, &Console::clear);
connect(ui->actionAbout, &QAction::triggered, this, &MainWindow::about);
connect(ui->actionAboutQt, &QAction::triggered, qApp, &QApplication::aboutQt);
diff --git a/src/serialport/qserialport.cpp b/src/serialport/qserialport.cpp
index d23e3b64..81beb2de 100644
--- a/src/serialport/qserialport.cpp
+++ b/src/serialport/qserialport.cpp
@@ -209,7 +209,7 @@ void QSerialPortPrivate::setError(const QSerialPortErrorInfo &errorInfo)
}
\endcode
- If \l{QIODevice::}{waitForReadyRead()} returns false, the
+ If \l{QIODevice::}{waitForReadyRead()} returns \c false, the
connection has been closed or an error has occurred.
If an error occurs at any point in time, QSerialPort will emit the
@@ -549,11 +549,11 @@ QString QSerialPort::portName() const
/*!
\reimp
- Opens the serial port using OpenMode \a mode, and then returns true if
- successful; otherwise returns false and sets an error code which can be
+ Opens the serial port using OpenMode \a mode, and then returns \c true if
+ successful; otherwise returns \c false and sets an error code which can be
obtained by calling the error() method.
- \note The method returns false if opening the port is successful, but could
+ \note The method returns \c false if opening the port is successful, but could
not set any of the port settings successfully. In that case, the port is
closed automatically not to leave the port around with incorrect settings.
@@ -607,6 +607,9 @@ void QSerialPort::close()
QIODevice::close();
}
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
+
#if QT_DEPRECATED_SINCE(5, 3)
/*!
\property QSerialPort::settingsRestoredOnClose
@@ -614,7 +617,7 @@ void QSerialPort::close()
the serial port.
\obsolete
- If this flag is true, the settings will be restored; otherwise not.
+ If this flag is \c true, the settings will be restored; otherwise not.
The default state of the QSerialPort class is to restore the
settings.
*/
@@ -628,6 +631,8 @@ void QSerialPort::setSettingsRestoredOnClose(bool restore)
}
}
+QT_WARNING_POP
+
bool QSerialPort::settingsRestoredOnClose() const
{
Q_D(const QSerialPort);
@@ -653,8 +658,8 @@ bool QSerialPort::settingsRestoredOnClose() const
\property QSerialPort::baudRate
\brief the data baud rate for the desired direction
- If the setting is successful or set before opening the port, returns true;
- otherwise returns false and sets an error code which can be obtained by
+ If the setting is successful or set before opening the port, returns \c true;
+ otherwise returns \c false and sets an error code which can be obtained by
accessing the value of the QSerialPort::error property. To set the baud
rate, use the enumeration QSerialPort::BaudRate or any positive qint32
value.
@@ -721,7 +726,7 @@ qint32 QSerialPort::baudRate(Directions directions) const
\brief the data bits in a frame
If the setting is successful or set before opening the port, returns
- true; otherwise returns false and sets an error code which can be obtained
+ \c true; otherwise returns \c false and sets an error code which can be obtained
by accessing the value of the QSerialPort::error property.
\note If the setting is set before opening the port, the actual serial port
@@ -765,8 +770,8 @@ QSerialPort::DataBits QSerialPort::dataBits() const
\property QSerialPort::parity
\brief the parity checking mode
- If the setting is successful or set before opening the port, returns true;
- otherwise returns false and sets an error code which can be obtained by
+ If the setting is successful or set before opening the port, returns \c true;
+ otherwise returns \c false and sets an error code which can be obtained by
accessing the value of the QSerialPort::error property.
\note If the setting is set before opening the port, the actual serial port
@@ -809,8 +814,8 @@ QSerialPort::Parity QSerialPort::parity() const
\property QSerialPort::stopBits
\brief the number of stop bits in a frame
- If the setting is successful or set before opening the port, returns true;
- otherwise returns false and sets an error code which can be obtained by
+ If the setting is successful or set before opening the port, returns \c true;
+ otherwise returns \c false and sets an error code which can be obtained by
accessing the value of the QSerialPort::error property.
\note If the setting is set before opening the port, the actual serial port
@@ -853,8 +858,8 @@ QSerialPort::StopBits QSerialPort::stopBits() const
\property QSerialPort::flowControl
\brief the desired flow control mode
- If the setting is successful or set before opening the port, returns true;
- otherwise returns false and sets an error code which can be obtained by
+ If the setting is successful or set before opening the port, returns \c true;
+ otherwise returns \c false and sets an error code which can be obtained by
accessing the value of the QSerialPort::error property.
\note If the setting is set before opening the port, the actual serial port
@@ -897,11 +902,11 @@ QSerialPort::FlowControl QSerialPort::flowControl() const
\property QSerialPort::dataTerminalReady
\brief the state (high or low) of the line signal DTR
- Returns true on success, false otherwise.
- If the flag is true then the DTR signal is set to high; otherwise low.
+ Returns \c true on success, \c false otherwise.
+ If the flag is \c true then the DTR signal is set to high; otherwise low.
\note The serial port has to be open before trying to set or get this
- property; otherwise false is returned and the error code is set to
+ property; otherwise \c false is returned and the error code is set to
NotOpenError.
\sa pinoutSignals()
@@ -944,11 +949,11 @@ bool QSerialPort::isDataTerminalReady()
\property QSerialPort::requestToSend
\brief the state (high or low) of the line signal RTS
- Returns true on success, false otherwise.
- If the flag is true then the RTS signal is set to high; otherwise low.
+ Returns \c true on success, \c false otherwise.
+ If the flag is \c true then the RTS signal is set to high; otherwise low.
\note The serial port has to be open before trying to set or get this
- property; otherwise false is returned and the error code is set to
+ property; otherwise \c false is returned and the error code is set to
NotOpenError.
\sa pinoutSignals()
@@ -1024,7 +1029,7 @@ QSerialPort::PinoutSignals QSerialPort::pinoutSignals()
/*!
This function writes as much as possible from the internal write
buffer to the underlying serial port without blocking. If any data
- was written, this function returns true; otherwise returns false.
+ was written, this function returns \c true; otherwise returns \c false.
Call this function for sending the buffered data immediately to the serial
port. The number of bytes successfully written depends on the operating
@@ -1034,7 +1039,7 @@ QSerialPort::PinoutSignals QSerialPort::pinoutSignals()
waitForBytesWritten() instead.
\note The serial port has to be open before trying to flush any buffered
- data; otherwise returns false and sets the NotOpenError error code.
+ data; otherwise returns \c false and sets the NotOpenError error code.
\sa write(), waitForBytesWritten()
*/
@@ -1055,10 +1060,10 @@ bool QSerialPort::flush()
Discards all characters from the output or input buffer, depending on
given directions \a directions. This includes clearing the internal class buffers and
the UART (driver) buffers. Also terminate pending read or write operations.
- If successful, returns true; otherwise returns false.
+ If successful, returns \c true; otherwise returns \c false.
\note The serial port has to be open before trying to clear any buffered
- data; otherwise returns false and sets the NotOpenError error code.
+ data; otherwise returns \c false and sets the NotOpenError error code.
*/
bool QSerialPort::clear(Directions directions)
{
@@ -1080,8 +1085,8 @@ bool QSerialPort::clear(Directions directions)
/*!
\reimp
- Returns true if no more data is currently available for reading; otherwise
- returns false.
+ Returns \c true if no more data is currently available for reading; otherwise
+ returns \c false.
This function is most commonly used when reading data from the
serial port in a loop. For example:
@@ -1111,11 +1116,11 @@ bool QSerialPort::atEnd() const
a parity error is detected.
\obsolete
- If the setting is successful, returns true; otherwise returns false. The
+ If the setting is successful, returns \c true; otherwise returns \c false. The
default policy set is IgnorePolicy.
\note The serial port has to be open before trying to set this property;
- otherwise returns false and sets the NotOpenError error code. This is a bit
+ otherwise returns \c false and sets the NotOpenError error code. This is a bit
unusual as opposed to the regular Qt property settings of a class. However,
this is a special use case since the property is set through the interaction
with the kernel and hardware. Hence, the two scenarios cannot be completely
@@ -1165,7 +1170,7 @@ QSerialPort::DataErrorPolicy QSerialPort::dataErrorPolicy() const
\brief the error status of the serial port
The I/O device status returns an error code. For example, if open()
- returns false, or a read/write operation returns -1, this property can
+ returns \c false, or a read/write operation returns \c -1, this property can
be used to figure out the reason why the operation failed.
The error code is set to the default QSerialPort::NoError after a call to
@@ -1205,7 +1210,7 @@ void QSerialPort::clearError()
amount of data that the client can receive before calling the read()
or readAll() methods.
- A read buffer size of 0 (the default) means that the buffer has
+ A read buffer size of \c 0 (the default) means that the buffer has
no size limit, ensuring that no data is lost.
\sa setReadBufferSize(), read()
@@ -1222,7 +1227,7 @@ qint64 QSerialPort::readBufferSize() const
If the buffer size is limited to a certain size, QSerialPort
will not buffer more than this size of data. The special case of a buffer
- size of 0 means that the read buffer is unlimited and all
+ size of \c 0 means that the read buffer is unlimited and all
incoming data is buffered. This is the default.
This option is useful if the data is only read at certain points
@@ -1244,7 +1249,7 @@ void QSerialPort::setReadBufferSize(qint64 size)
/*!
\reimp
- Always returns true. The serial port is a sequential device.
+ Always returns \c true. The serial port is a sequential device.
*/
bool QSerialPort::isSequential() const
{
@@ -1281,8 +1286,8 @@ qint64 QSerialPort::bytesToWrite() const
/*!
\reimp
- Returns true if a line of data can be read from the serial port;
- otherwise returns false.
+ Returns \c true if a line of data can be read from the serial port;
+ otherwise returns \c false.
\sa readLine()
*/
@@ -1316,7 +1321,7 @@ bool QSerialPort::waitForReadyRead(int msecs)
\since 5.2
If the platform is supported and the serial port is open, returns the native
- serial port handle; otherwise returns -1.
+ serial port handle; otherwise returns \c -1.
\warning This function is for expert use only; use it at your own risk.
Furthermore, this function carries no compatibility promise between minor
@@ -1344,16 +1349,16 @@ bool QSerialPort::waitForBytesWritten(int msecs)
/*!
Sends a continuous stream of zero bits during a specified period
of time \a duration in msec if the terminal is using asynchronous
- serial data. If successful, returns true; otherwise returns false.
+ serial data. If successful, returns \c true; otherwise returns \c false.
If the duration is zero then zero bits are transmitted by at least
- 0.25 seconds, but no more than 0.5 seconds.
+ \c 0.25 seconds, but no more than \c 0.5 seconds.
If the duration is non zero then zero bits are transmitted within a certain
period of time depending on the implementation.
\note The serial port has to be open before trying to send a break
- duration; otherwise returns false and sets the NotOpenError error code.
+ duration; otherwise returns \c false and sets the NotOpenError error code.
\sa setBreakEnabled()
*/
@@ -1376,12 +1381,12 @@ bool QSerialPort::sendBreak(int duration)
\since 5.5
\brief the state of the transmission line in break
- Returns true on success, false otherwise.
- If the flag is true then the transmission line is in break state;
+ Returns \c true on success, \c false otherwise.
+ If the flag is \c true then the transmission line is in break state;
otherwise is in non-break state.
\note The serial port has to be open before trying to set or get this
- property; otherwise returns false and sets the NotOpenError error code.
+ property; otherwise returns \c false and sets the NotOpenError error code.
This is a bit unusual as opposed to the regular Qt property settings of
a class. However, this is a special use case since the property is set
through the interaction with the kernel and hardware. Hence, the two
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.
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/src/serialport/qserialportinfo.cpp b/src/serialport/qserialportinfo.cpp
index d978665d..2547e01d 100644
--- a/src/serialport/qserialportinfo.cpp
+++ b/src/serialport/qserialportinfo.cpp
@@ -228,8 +228,8 @@ quint16 QSerialPortInfo::productIdentifier() const
}
/*!
- Returns true if there is a valid 16-bit vendor number present; otherwise
- returns false.
+ Returns \c true if there is a valid \c 16-bit vendor number present; otherwise
+ returns \c false.
\sa vendorIdentifier(), productIdentifier(), hasProductIdentifier()
*/
@@ -240,8 +240,8 @@ bool QSerialPortInfo::hasVendorIdentifier() const
}
/*!
- Returns true if there is a valid 16-bit product number present; otherwise
- returns false.
+ Returns \c true if there is a valid \c 16-bit product number present; otherwise
+ returns \c false.
\sa productIdentifier(), vendorIdentifier(), hasVendorIdentifier()
*/
@@ -264,8 +264,8 @@ bool QSerialPortInfo::hasProductIdentifier() const
/*!
\fn bool QSerialPortInfo::isBusy() const
- Returns true if serial port is busy;
- otherwise returns false.
+ Returns \c true if serial port is busy;
+ otherwise returns \c false.
\sa isNull()
*/
@@ -276,8 +276,8 @@ bool QSerialPortInfo::hasProductIdentifier() const
\fn bool QSerialPortInfo::isValid() const
\obsolete
- Returns true if serial port is present on system;
- otherwise returns false.
+ Returns \c true if serial port is present on system;
+ otherwise returns \c false.
\sa isNull(), isBusy()
*/
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" => "",
-);
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<bool>(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()));