summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMika Salmela <mika.salmela@qt.io>2017-08-28 11:22:19 +0300
committerMika Salmela <mika.salmela@qt.io>2017-08-30 05:58:45 +0000
commita8c6d5e2dd2e1d0b51d6adf9e163b61b94366369 (patch)
tree53fcb36c8ce4f7d0f10c0eefc7f95daf5519d027
parent93b539140c06da07d330c9ecad67ab5ed3f9b0c8 (diff)
downloadqtserialport-a8c6d5e2dd2e1d0b51d6adf9e163b61b94366369.tar.gz
Check if the currentPortName is empty on blockingmaster example
If there isn't serial ports available and the user still press the Start button, the example will crash. This patch adds the check if the currentPortName is empty and throws an error on that case. Change-Id: I7e85f398e2844064fb9b00cecfdf2afa271d7de0 Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
-rw-r--r--examples/serialport/blockingmaster/masterthread.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/examples/serialport/blockingmaster/masterthread.cpp b/examples/serialport/blockingmaster/masterthread.cpp
index c81c819..5ad93fd 100644
--- a/examples/serialport/blockingmaster/masterthread.cpp
+++ b/examples/serialport/blockingmaster/masterthread.cpp
@@ -107,6 +107,11 @@ void MasterThread::run()
//! [5] //! [6]
QSerialPort serial;
+ if (currentPortName.isEmpty()) {
+ emit error(tr("No port name specified"));
+ return;
+ }
+
while (!quit) {
//![6] //! [7]
if (currentPortNameChanged) {