From a8c6d5e2dd2e1d0b51d6adf9e163b61b94366369 Mon Sep 17 00:00:00 2001 From: Mika Salmela Date: Mon, 28 Aug 2017 11:22:19 +0300 Subject: 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 --- examples/serialport/blockingmaster/masterthread.cpp | 5 +++++ 1 file changed, 5 insertions(+) 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) { -- cgit v1.2.1