summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-05-19 21:37:33 +0200
committerLiang Qi <liang.qi@qt.io>2016-05-19 21:37:33 +0200
commit9e8daaed0466d760e047c5da58811e55e7807c0a (patch)
treeeb75deaa8be7b1bbd777416aa1995990cd0f86a1
parent2ac9c0c0e6210f73884bbe2bcb3d8269519003a8 (diff)
parent9c9255eda50af191636ff9f18df35567c307dd8c (diff)
Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts: .qmake.conf Change-Id: I6a4c3e446633e6f142b87c268096b1bdc1598a62
-rw-r--r--examples/serialport/blockingmaster/blockingmaster.pro3
-rw-r--r--examples/serialport/blockingslave/blockingslave.pro3
-rw-r--r--examples/serialport/cenumerator/cenumerator.pro3
-rw-r--r--examples/serialport/creaderasync/creaderasync.pro3
-rw-r--r--examples/serialport/creadersync/creadersync.pro3
-rw-r--r--examples/serialport/cwriterasync/cwriterasync.pro3
-rw-r--r--examples/serialport/cwritersync/cwritersync.pro3
-rw-r--r--examples/serialport/enumerator/enumerator.pro3
-rw-r--r--examples/serialport/master/master.pro3
-rw-r--r--examples/serialport/serialport.pro3
-rw-r--r--examples/serialport/slave/slave.pro3
-rw-r--r--examples/serialport/terminal/terminal.pro3
-rw-r--r--src/serialport/doc/qtserialport.qdocconf2
-rw-r--r--src/serialport/qserialport_p.h2
-rw-r--r--src/serialport/qserialport_unix.cpp12
-rw-r--r--src/serialport/qserialport_win.cpp29
-rw-r--r--src/serialport/qserialportinfo_unix.cpp2
17 files changed, 61 insertions, 22 deletions
diff --git a/examples/serialport/blockingmaster/blockingmaster.pro b/examples/serialport/blockingmaster/blockingmaster.pro
index 8f3e0a15..7cf76d8b 100644
--- a/examples/serialport/blockingmaster/blockingmaster.pro
+++ b/examples/serialport/blockingmaster/blockingmaster.pro
@@ -11,3 +11,6 @@ SOURCES += \
main.cpp \
dialog.cpp \
masterthread.cpp
+
+target.path = $$[QT_INSTALL_EXAMPLES]/serialport/blockingmaster
+INSTALLS += target
diff --git a/examples/serialport/blockingslave/blockingslave.pro b/examples/serialport/blockingslave/blockingslave.pro
index 2477b52c..11b9b80b 100644
--- a/examples/serialport/blockingslave/blockingslave.pro
+++ b/examples/serialport/blockingslave/blockingslave.pro
@@ -11,3 +11,6 @@ SOURCES += \
main.cpp \
dialog.cpp \
slavethread.cpp
+
+target.path = $$[QT_INSTALL_EXAMPLES]/serialport/blockingslave
+INSTALLS += target
diff --git a/examples/serialport/cenumerator/cenumerator.pro b/examples/serialport/cenumerator/cenumerator.pro
index f5494fd7..75a43e36 100644
--- a/examples/serialport/cenumerator/cenumerator.pro
+++ b/examples/serialport/cenumerator/cenumerator.pro
@@ -9,3 +9,6 @@ TEMPLATE = app
SOURCES += \
main.cpp
+
+target.path = $$[QT_INSTALL_EXAMPLES]/serialport/cenumerator
+INSTALLS += target
diff --git a/examples/serialport/creaderasync/creaderasync.pro b/examples/serialport/creaderasync/creaderasync.pro
index 3565dc9e..38d8b529 100644
--- a/examples/serialport/creaderasync/creaderasync.pro
+++ b/examples/serialport/creaderasync/creaderasync.pro
@@ -13,3 +13,6 @@ HEADERS += \
SOURCES += \
main.cpp \
serialportreader.cpp
+
+target.path = $$[QT_INSTALL_EXAMPLES]/serialport/creaderasync
+INSTALLS += target
diff --git a/examples/serialport/creadersync/creadersync.pro b/examples/serialport/creadersync/creadersync.pro
index ee9eaf23..a2690aaf 100644
--- a/examples/serialport/creadersync/creadersync.pro
+++ b/examples/serialport/creadersync/creadersync.pro
@@ -9,3 +9,6 @@ TEMPLATE = app
SOURCES += \
main.cpp
+
+target.path = $$[QT_INSTALL_EXAMPLES]/serialport/creadersync
+INSTALLS += target
diff --git a/examples/serialport/cwriterasync/cwriterasync.pro b/examples/serialport/cwriterasync/cwriterasync.pro
index 0945f1d4..f6105bc9 100644
--- a/examples/serialport/cwriterasync/cwriterasync.pro
+++ b/examples/serialport/cwriterasync/cwriterasync.pro
@@ -13,3 +13,6 @@ HEADERS += \
SOURCES += \
main.cpp \
serialportwriter.cpp
+
+target.path = $$[QT_INSTALL_EXAMPLES]/serialport/cwriterasync
+INSTALLS += target
diff --git a/examples/serialport/cwritersync/cwritersync.pro b/examples/serialport/cwritersync/cwritersync.pro
index 08f50a28..1e0996dc 100644
--- a/examples/serialport/cwritersync/cwritersync.pro
+++ b/examples/serialport/cwritersync/cwritersync.pro
@@ -9,3 +9,6 @@ TEMPLATE = app
SOURCES += \
main.cpp
+
+target.path = $$[QT_INSTALL_EXAMPLES]/serialport/cwritersync
+INSTALLS += target
diff --git a/examples/serialport/enumerator/enumerator.pro b/examples/serialport/enumerator/enumerator.pro
index 9819fd7d..3989335a 100644
--- a/examples/serialport/enumerator/enumerator.pro
+++ b/examples/serialport/enumerator/enumerator.pro
@@ -5,3 +5,6 @@ TEMPLATE = app
SOURCES += \
main.cpp
+
+target.path = $$[QT_INSTALL_EXAMPLES]/serialport/enumerator
+INSTALLS += target
diff --git a/examples/serialport/master/master.pro b/examples/serialport/master/master.pro
index 977de6c7..354d1745 100644
--- a/examples/serialport/master/master.pro
+++ b/examples/serialport/master/master.pro
@@ -13,3 +13,6 @@ HEADERS += \
SOURCES += \
main.cpp \
dialog.cpp
+
+target.path = $$[QT_INSTALL_EXAMPLES]/serialport/master
+INSTALLS += target
diff --git a/examples/serialport/serialport.pro b/examples/serialport/serialport.pro
index c0e77dfd..6d00a225 100644
--- a/examples/serialport/serialport.pro
+++ b/examples/serialport/serialport.pro
@@ -1,4 +1,3 @@
TEMPLATE = subdirs
-CONFIG += ordered
SUBDIRS = cenumerator creaderasync creadersync cwriterasync cwritersync
-!isEmpty(QT.widgets.name):SUBDIRS += enumerator terminal blockingmaster blockingslave
+!isEmpty(QT.widgets.name):SUBDIRS += enumerator terminal blockingmaster blockingslave master slave
diff --git a/examples/serialport/slave/slave.pro b/examples/serialport/slave/slave.pro
index df996ac1..54e7d027 100644
--- a/examples/serialport/slave/slave.pro
+++ b/examples/serialport/slave/slave.pro
@@ -13,3 +13,6 @@ HEADERS += \
SOURCES += \
main.cpp \
dialog.cpp
+
+target.path = $$[QT_INSTALL_EXAMPLES]/serialport/slave
+INSTALLS += target
diff --git a/examples/serialport/terminal/terminal.pro b/examples/serialport/terminal/terminal.pro
index 1e45e557..4dbed02d 100644
--- a/examples/serialport/terminal/terminal.pro
+++ b/examples/serialport/terminal/terminal.pro
@@ -20,3 +20,6 @@ FORMS += \
RESOURCES += \
terminal.qrc
+
+target.path = $$[QT_INSTALL_EXAMPLES]/serialport/terminal
+INSTALLS += target
diff --git a/src/serialport/doc/qtserialport.qdocconf b/src/serialport/doc/qtserialport.qdocconf
index ac1fc1ea..78c1b355 100644
--- a/src/serialport/doc/qtserialport.qdocconf
+++ b/src/serialport/doc/qtserialport.qdocconf
@@ -34,7 +34,7 @@ exampledirs += ../../../examples/serialport
imagedirs += images
excludedirs += ../qt4support
-examplesinstallpath = qtserialport/serialport
+examplesinstallpath = serialport
depends += qtcore qtdoc qtnetwork qmake
diff --git a/src/serialport/qserialport_p.h b/src/serialport/qserialport_p.h
index ae2089da..cb300ad7 100644
--- a/src/serialport/qserialport_p.h
+++ b/src/serialport/qserialport_p.h
@@ -188,6 +188,8 @@ public:
bool getDcb(DCB *dcb);
OVERLAPPED *waitForNotified(int msecs);
+ qint64 queuedBytesCount(QSerialPort::Direction direction) const;
+
bool completeAsyncCommunication(qint64 bytesTransferred);
bool completeAsyncRead(qint64 bytesTransferred);
bool completeAsyncWrite(qint64 bytesTransferred);
diff --git a/src/serialport/qserialport_unix.cpp b/src/serialport/qserialport_unix.cpp
index 41dad55f..2d498220 100644
--- a/src/serialport/qserialport_unix.cpp
+++ b/src/serialport/qserialport_unix.cpp
@@ -250,15 +250,11 @@ void QSerialPortPrivate::close()
::ioctl(descriptor, TIOCNXCL);
#endif
- if (readNotifier) {
- delete readNotifier;
- readNotifier = Q_NULLPTR;
- }
+ delete readNotifier;
+ readNotifier = Q_NULLPTR;
- if (writeNotifier) {
- delete writeNotifier;
- writeNotifier = Q_NULLPTR;
- }
+ delete writeNotifier;
+ writeNotifier = Q_NULLPTR;
qt_safe_close(descriptor);
diff --git a/src/serialport/qserialport_win.cpp b/src/serialport/qserialport_win.cpp
index 36e7164c..5dccd39b 100644
--- a/src/serialport/qserialport_win.cpp
+++ b/src/serialport/qserialport_win.cpp
@@ -112,15 +112,11 @@ void QSerialPortPrivate::close()
{
::CancelIo(handle);
- if (notifier) {
- delete notifier;
- notifier = Q_NULLPTR;
- }
+ delete notifier;
+ notifier = Q_NULLPTR;
- if (startAsyncWriteTimer) {
- delete startAsyncWriteTimer;
- startAsyncWriteTimer = Q_NULLPTR;
- }
+ delete startAsyncWriteTimer;
+ startAsyncWriteTimer = Q_NULLPTR;
communicationStarted = false;
readStarted = false;
@@ -443,10 +439,13 @@ bool QSerialPortPrivate::completeAsyncRead(qint64 bytesTransferred)
readStarted = false;
bool result = true;
- if (bytesTransferred == ReadChunkSize)
+ if (bytesTransferred == ReadChunkSize
+ || queuedBytesCount(QSerialPort::Input) > 0) {
result = startAsyncRead();
- else if (readBufferMaxSize == 0 || readBufferMaxSize > buffer.size())
+ } else if (readBufferMaxSize == 0
+ || readBufferMaxSize > buffer.size()) {
result = startAsyncCommunication();
+ }
if (bytesTransferred > 0)
emitReadyRead();
@@ -604,6 +603,16 @@ OVERLAPPED *QSerialPortPrivate::waitForNotified(int msecs)
return overlapped;
}
+qint64 QSerialPortPrivate::queuedBytesCount(QSerialPort::Direction direction) const
+{
+ COMSTAT comstat;
+ if (::ClearCommError(handle, Q_NULLPTR, &comstat) == 0)
+ return -1;
+ return (direction == QSerialPort::Input)
+ ? comstat.cbInQue
+ : ((direction == QSerialPort::Output) ? comstat.cbOutQue : -1);
+}
+
inline bool QSerialPortPrivate::initialize()
{
Q_Q(QSerialPort);
diff --git a/src/serialport/qserialportinfo_unix.cpp b/src/serialport/qserialportinfo_unix.cpp
index 3a379996..08e75c1e 100644
--- a/src/serialport/qserialportinfo_unix.cpp
+++ b/src/serialport/qserialportinfo_unix.cpp
@@ -157,7 +157,7 @@ static bool isRfcommDevice(const QString &portName)
return false;
bool ok;
- const int portNumber = portName.mid(6).toInt(&ok);
+ const int portNumber = portName.midRef(6).toInt(&ok);
if (!ok || (portNumber < 0) || (portNumber > 255))
return false;
return true;