From e0d91fb76477d21f9152c16044f0492c4cac9998 Mon Sep 17 00:00:00 2001 From: Denis Shienkov Date: Thu, 4 Dec 2014 13:22:47 +0300 Subject: Mark a device as open only after all settings was aplied Otherwise it lead to emmiting of the QSP::NotOpenError in case we close a device from a slot, which is connected to QSP::SerialPortError signal. In this case QSP::close() called twice: from the slot, and from the QSP::open() method (this behavior can be reproduced with Terminal example). So, inside of QSP::open() we need to move QIODevice::open() down, and instead of QSP::close() to use QSPP::close(). Tested on Linux with USB PL2303 with trying to setup an unsupported baud rate as 14400 baud. Change-Id: I12dec085423dd9f5a08b7884f32dd2ba8aa8c951 Reviewed-by: Sergey Belyashov --- src/serialport/qserialport.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/serialport/qserialport.cpp b/src/serialport/qserialport.cpp index 2bd7c69..5e838c0 100644 --- a/src/serialport/qserialport.cpp +++ b/src/serialport/qserialport.cpp @@ -521,17 +521,17 @@ bool QSerialPort::open(OpenMode mode) if (!d->open(mode)) return false; - QIODevice::open(mode); - if (!d->setBaudRate() || !d->setDataBits(d->dataBits) || !d->setParity(d->parity) || !d->setStopBits(d->stopBits) || !d->setFlowControl(d->flowControl)) { - close(); + d->close(); return false; } + QIODevice::open(mode); + d->dataTerminalReady = isDataTerminalReady(); d->requestToSend = isRequestToSend(); -- cgit v1.2.1