summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2015-06-03 10:59:23 +0200
committerLiang Qi <liang.qi@theqtcompany.com>2015-06-03 10:59:23 +0200
commitab55707a73189ae35c422d77663b8b9d7b414c88 (patch)
tree70327e4eda8786b317f90578cebed19901e8a9e1
parent90ac0fffa223d8f81cf9a3c6a89cd4ec1de5f537 (diff)
parent71c38793265fc2966cde5ef64ef21c4bb122bd0f (diff)
downloadqtserialport-ab55707a73189ae35c422d77663b8b9d7b414c88.tar.gz
Merge remote-tracking branch 'origin/5.5' into dev
Change-Id: I17cb5c718702e845fe7d93e66a84c5df915268c0
-rw-r--r--src/serialport/qserialport.cpp3
-rw-r--r--src/serialport/qserialport.h10
-rw-r--r--src/serialport/qserialport_p.h1
-rw-r--r--src/serialport/qserialport_unix.cpp16
-rw-r--r--src/serialport/qserialport_win.cpp2
-rw-r--r--src/serialport/qserialportinfo_mac.cpp8
-rw-r--r--src/serialport/qserialportinfo_unix.cpp14
-rw-r--r--src/serialport/qserialportinfo_win.cpp14
-rw-r--r--src/serialport/qtudev_p.h6
-rw-r--r--tests/auto/qserialport/tst_qserialport.cpp21
-rw-r--r--tests/auto/qserialportinfo/tst_qserialportinfo.cpp4
-rw-r--r--tests/manual/qserialport/tst_qserialport.cpp4
12 files changed, 41 insertions, 62 deletions
diff --git a/src/serialport/qserialport.cpp b/src/serialport/qserialport.cpp
index a7075e0..e9c6922 100644
--- a/src/serialport/qserialport.cpp
+++ b/src/serialport/qserialport.cpp
@@ -67,7 +67,6 @@ QSerialPortPrivate::QSerialPortPrivate()
, handle(INVALID_HANDLE_VALUE)
, parityErrorOccurred(false)
, readChunkBuffer(ReadChunkSize, 0)
- , readyReadEmitted(0)
, writeStarted(false)
, readStarted(false)
, notifier(0)
@@ -1371,7 +1370,7 @@ void QSerialPort::setError(QSerialPort::SerialPortError serialPortError, const Q
d->error = serialPortError;
- if (errorString.isNull())
+ if (errorString.isNull() && (serialPortError != QSerialPort::NoError))
setErrorString(qt_error_string(-1));
else
setErrorString(errorString);
diff --git a/src/serialport/qserialport.h b/src/serialport/qserialport.h
index 3137ba1..cbf489d 100644
--- a/src/serialport/qserialport.h
+++ b/src/serialport/qserialport.h
@@ -246,7 +246,7 @@ public:
bool waitForBytesWritten(int msecs) Q_DECL_OVERRIDE;
#if QT_DEPRECATED_SINCE(5, 5)
- bool sendBreak(int duration = 0);
+ QT_DEPRECATED bool sendBreak(int duration = 0);
#endif
bool setBreakEnabled(bool set = true);
bool isBreakEnabled() const;
@@ -259,11 +259,15 @@ Q_SIGNALS:
void parityChanged(QSerialPort::Parity parity);
void stopBitsChanged(QSerialPort::StopBits stopBits);
void flowControlChanged(QSerialPort::FlowControl flowControl);
- void dataErrorPolicyChanged(QSerialPort::DataErrorPolicy policy);
+#if QT_DEPRECATED_SINCE(5, 2)
+ QT_DEPRECATED void dataErrorPolicyChanged(QSerialPort::DataErrorPolicy policy);
+#endif
void dataTerminalReadyChanged(bool set);
void requestToSendChanged(bool set);
void error(QSerialPort::SerialPortError serialPortError);
- void settingsRestoredOnCloseChanged(bool restore);
+#if QT_DEPRECATED_SINCE(5, 3)
+ QT_DEPRECATED void settingsRestoredOnCloseChanged(bool restore);
+#endif
void breakEnabledChanged(bool set);
protected:
diff --git a/src/serialport/qserialport_p.h b/src/serialport/qserialport_p.h
index 81e0e94..ad8d9d0 100644
--- a/src/serialport/qserialport_p.h
+++ b/src/serialport/qserialport_p.h
@@ -225,7 +225,6 @@ public:
HANDLE handle;
bool parityErrorOccurred;
QByteArray readChunkBuffer;
- bool readyReadEmitted;
bool writeStarted;
bool readStarted;
QWinOverlappedIoNotifier *notifier;
diff --git a/src/serialport/qserialport_unix.cpp b/src/serialport/qserialport_unix.cpp
index 30131ca..1f90a18 100644
--- a/src/serialport/qserialport_unix.cpp
+++ b/src/serialport/qserialport_unix.cpp
@@ -58,6 +58,10 @@
#include <QtCore/qsocketnotifier.h>
#include <QtCore/qmap.h>
+#ifdef Q_OS_MAC
+#include <QtCore/qstandardpaths.h>
+#endif
+
QT_BEGIN_NAMESPACE
QString serialPortLockFilePath(const QString &portName)
@@ -68,6 +72,9 @@ QString serialPortLockFilePath(const QString &portName)
<< QStringLiteral("/var/spool/locks")
<< QStringLiteral("/var/spool/uucp")
<< QStringLiteral("/tmp")
+ << QStringLiteral("/var/tmp")
+ << QStringLiteral("/var/lock/lockdev")
+ << QStringLiteral("/run/lock")
#ifdef Q_OS_ANDROID
<< QStringLiteral("/data/local/tmp")
#endif
@@ -75,7 +82,7 @@ QString serialPortLockFilePath(const QString &portName)
QString fileName = portName;
fileName.replace(QLatin1Char('/'), QLatin1Char('_'));
- fileName.prepend(QStringLiteral("/LCK.."));
+ fileName.prepend(QLatin1String("/LCK.."));
QString lockFilePath;
@@ -91,6 +98,13 @@ QString serialPortLockFilePath(const QString &portName)
}
}
+#ifdef Q_OS_MAC
+ // This is the workaround to specify a temporary directory
+ // on OSX when running the App Sandbox feature.
+ if (lockFilePath.isEmpty())
+ lockFilePath = QStandardPaths::writableLocation(QStandardPaths::TempLocation);
+#endif
+
if (lockFilePath.isEmpty()) {
qWarning("The following directories are not readable or writable for detaling with lock files\n");
foreach (const QString &lockDirectoryPath, lockDirectoryPaths)
diff --git a/src/serialport/qserialport_win.cpp b/src/serialport/qserialport_win.cpp
index c37aa3b..b3d5c9d 100644
--- a/src/serialport/qserialport_win.cpp
+++ b/src/serialport/qserialport_win.cpp
@@ -119,7 +119,6 @@ void QSerialPortPrivate::close()
writeBuffer.clear();
actualBytesToWrite = 0;
- readyReadEmitted = false;
parityErrorOccurred = false;
if (settingsRestoredOnClose) {
@@ -632,7 +631,6 @@ void QSerialPortPrivate::emitReadyRead()
{
Q_Q(QSerialPort);
- readyReadEmitted = true;
emit q->readyRead();
}
diff --git a/src/serialport/qserialportinfo_mac.cpp b/src/serialport/qserialportinfo_mac.cpp
index 6c175f6..558dcbd 100644
--- a/src/serialport/qserialportinfo_mac.cpp
+++ b/src/serialport/qserialportinfo_mac.cpp
@@ -240,14 +240,14 @@ bool QSerialPortInfo::isValid() const
QString QSerialPortInfoPrivate::portNameToSystemLocation(const QString &source)
{
return (source.startsWith(QLatin1Char('/'))
- || source.startsWith(QStringLiteral("./"))
- || source.startsWith(QStringLiteral("../")))
- ? source : (QStringLiteral("/dev/") + source);
+ || source.startsWith(QLatin1String("./"))
+ || source.startsWith(QLatin1String("../")))
+ ? source : (QLatin1String("/dev/") + source);
}
QString QSerialPortInfoPrivate::portNameFromSystemLocation(const QString &source)
{
- return source.startsWith(QStringLiteral("/dev/"))
+ return source.startsWith(QLatin1String("/dev/"))
? source.mid(5) : source;
}
diff --git a/src/serialport/qserialportinfo_unix.cpp b/src/serialport/qserialportinfo_unix.cpp
index 7da8f52..0add5b6 100644
--- a/src/serialport/qserialportinfo_unix.cpp
+++ b/src/serialport/qserialportinfo_unix.cpp
@@ -111,7 +111,7 @@ QList<QSerialPortInfo> availablePortsByFiltersOfDevices(bool &ok)
static bool isSerial8250Driver(const QString &driverName)
{
- return (driverName == QStringLiteral("serial8250"));
+ return (driverName == QLatin1String("serial8250"));
}
static bool isValidSerial8250(const QString &systemLocation)
@@ -134,7 +134,7 @@ static bool isValidSerial8250(const QString &systemLocation)
static bool isRfcommDevice(const QString &portName)
{
- if (!portName.startsWith(QStringLiteral("rfcomm")))
+ if (!portName.startsWith(QLatin1String("rfcomm")))
return false;
bool ok;
@@ -170,7 +170,7 @@ static QString deviceName(const QDir &targetDir)
static QString deviceDriver(const QDir &targetDir)
{
- const QDir deviceDir(targetDir.absolutePath() + QStringLiteral("/device"));
+ const QDir deviceDir(targetDir.absolutePath() + QLatin1String("/device"));
return ueventProperty(deviceDir, "DRIVER=");
}
@@ -472,14 +472,14 @@ bool QSerialPortInfo::isValid() const
QString QSerialPortInfoPrivate::portNameToSystemLocation(const QString &source)
{
return (source.startsWith(QLatin1Char('/'))
- || source.startsWith(QStringLiteral("./"))
- || source.startsWith(QStringLiteral("../")))
- ? source : (QStringLiteral("/dev/") + source);
+ || source.startsWith(QLatin1String("./"))
+ || source.startsWith(QLatin1String("../")))
+ ? source : (QLatin1String("/dev/") + source);
}
QString QSerialPortInfoPrivate::portNameFromSystemLocation(const QString &source)
{
- return source.startsWith(QStringLiteral("/dev/"))
+ return source.startsWith(QLatin1String("/dev/"))
? source.mid(5) : source;
}
diff --git a/src/serialport/qserialportinfo_win.cpp b/src/serialport/qserialportinfo_win.cpp
index df0942f..546d5e1 100644
--- a/src/serialport/qserialportinfo_win.cpp
+++ b/src/serialport/qserialportinfo_win.cpp
@@ -258,13 +258,13 @@ static QString parseDeviceSerialNumber(const QString &instanceIdentifier)
{
int firstbound = instanceIdentifier.lastIndexOf(QLatin1Char('\\'));
int lastbound = instanceIdentifier.indexOf(QLatin1Char('_'), firstbound);
- if (instanceIdentifier.startsWith(QStringLiteral("USB\\"))) {
+ if (instanceIdentifier.startsWith(QLatin1String("USB\\"))) {
if (lastbound != instanceIdentifier.size() - 3)
lastbound = instanceIdentifier.size();
int ampersand = instanceIdentifier.indexOf(QLatin1Char('&'), firstbound);
if (ampersand != -1 && ampersand < lastbound)
return QString();
- } else if (instanceIdentifier.startsWith(QStringLiteral("FTDIBUS\\"))) {
+ } else if (instanceIdentifier.startsWith(QLatin1String("FTDIBUS\\"))) {
firstbound = instanceIdentifier.lastIndexOf(QLatin1Char('+'));
lastbound = instanceIdentifier.indexOf(QLatin1Char('\\'), firstbound);
if (lastbound == -1)
@@ -304,7 +304,7 @@ QList<QSerialPortInfo> QSerialPortInfo::availablePorts()
DWORD index = 0;
while (::SetupDiEnumDeviceInfo(deviceInfoSet, index++, &deviceInfoData)) {
const QString portName = devicePortName(deviceInfoSet, &deviceInfoData);
- if (portName.isEmpty() || portName.contains(QStringLiteral("LPT")))
+ if (portName.isEmpty() || portName.contains(QLatin1String("LPT")))
continue;
if (std::find_if(serialPortInfoList.begin(), serialPortInfoList.end(),
@@ -381,14 +381,14 @@ bool QSerialPortInfo::isValid() const
QString QSerialPortInfoPrivate::portNameToSystemLocation(const QString &source)
{
- return source.startsWith(QStringLiteral("COM"))
- ? (QStringLiteral("\\\\.\\") + source) : source;
+ return source.startsWith(QLatin1String("COM"))
+ ? (QLatin1String("\\\\.\\") + source) : source;
}
QString QSerialPortInfoPrivate::portNameFromSystemLocation(const QString &source)
{
- return (source.startsWith(QStringLiteral("\\\\.\\"))
- || source.startsWith(QStringLiteral("//./")))
+ return (source.startsWith(QLatin1String("\\\\.\\"))
+ || source.startsWith(QLatin1String("//./")))
? source.mid(4) : source;
}
diff --git a/src/serialport/qtudev_p.h b/src/serialport/qtudev_p.h
index f2eedd3..6f2cabd 100644
--- a/src/serialport/qtudev_p.h
+++ b/src/serialport/qtudev_p.h
@@ -93,15 +93,9 @@ GENERATE_SYMBOL_VARIABLE(void, udev_device_unref, struct udev_device *)
GENERATE_SYMBOL_VARIABLE(void, udev_enumerate_unref, struct udev_enumerate *)
GENERATE_SYMBOL_VARIABLE(void, udev_unref, struct udev *)
-#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
inline QFunctionPointer resolveSymbol(QLibrary *udevLibrary, const char *symbolName)
{
QFunctionPointer symbolFunctionPointer = udevLibrary->resolve(symbolName);
-#else
-inline void *resolveSymbol(QLibrary *udevLibrary, const char *symbolName)
-{
- void *symbolFunctionPointer = udevLibrary->resolve(symbolName);
-#endif
if (!symbolFunctionPointer)
qWarning("Failed to resolve the udev symbol: %s", symbolName);
diff --git a/tests/auto/qserialport/tst_qserialport.cpp b/tests/auto/qserialport/tst_qserialport.cpp
index 627de6c..1a714b2 100644
--- a/tests/auto/qserialport/tst_qserialport.cpp
+++ b/tests/auto/qserialport/tst_qserialport.cpp
@@ -56,12 +56,7 @@ public:
static void enterLoopMsecs(int msecs)
{
++loopLevel;
-#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
QTestEventLoop::instance().enterLoopMSecs(msecs);
-#else
- Q_UNUSED(msecs);
- QTestEventLoop::instance().enterLoop(1);
-#endif
--loopLevel;
}
@@ -176,11 +171,7 @@ void tst_QSerialPort::initTestCase()
"\n";
#endif
-#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
QSKIP(message);
-#else
- QSKIP(message, SkipAll);
-#endif
} else {
m_availablePortNames << m_senderPortName << m_receiverPortName;
}
@@ -243,11 +234,7 @@ void tst_QSerialPort::constructByInfo()
static const char message[] =
"Test doesn't work because the specified serial ports aren't"
" found in system and can't be constructed by QSerialPortInfo.\n";
-#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
QSKIP(message);
-#else
- QSKIP(message, SkipAll);
-#endif
}
#endif
@@ -334,11 +321,7 @@ void tst_QSerialPort::handleBytesWrittenAndExitLoopSlot(qint64 bytesWritten)
void tst_QSerialPort::flush()
{
#ifdef Q_OS_WIN
-#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
QSKIP("flush() does not work on Windows");
-#else
- QSKIP("flush() does not work on Windows", SkipAll);
-#endif
#endif
QSerialPort serialPort(m_senderPortName);
@@ -369,11 +352,7 @@ void tst_QSerialPort::handleBytesWrittenAndExitLoopSlot2(qint64 bytesWritten)
void tst_QSerialPort::doubleFlush()
{
#ifdef Q_OS_WIN
-#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
QSKIP("flush() does not work on Windows");
-#else
- QSKIP("flush() does not work on Windows", SkipAll);
-#endif
#endif
QSerialPort serialPort(m_senderPortName);
diff --git a/tests/auto/qserialportinfo/tst_qserialportinfo.cpp b/tests/auto/qserialportinfo/tst_qserialportinfo.cpp
index 54f1825..f0e6e9a 100644
--- a/tests/auto/qserialportinfo/tst_qserialportinfo.cpp
+++ b/tests/auto/qserialportinfo/tst_qserialportinfo.cpp
@@ -75,11 +75,7 @@ void tst_QSerialPortInfo::initTestCase()
#else
"\n";
#endif
-#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
QSKIP(message);
-#else
- QSKIP(message, SkipAll);
-#endif
} else {
m_availablePortNames << m_senderPortName << m_receiverPortName;
}
diff --git a/tests/manual/qserialport/tst_qserialport.cpp b/tests/manual/qserialport/tst_qserialport.cpp
index 380af39..f6f3252 100644
--- a/tests/manual/qserialport/tst_qserialport.cpp
+++ b/tests/manual/qserialport/tst_qserialport.cpp
@@ -61,11 +61,7 @@ void tst_QSerialPort::initTestCase()
serialPortInfoList = QSerialPortInfo::availablePorts();
if (serialPortInfoList.isEmpty()) {
-#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
QSKIP("Test doesn't work because the serial ports are not detected.");
-#else
- QSKIP("Test doesn't work because the serial ports are not detected.", SkipAll);
-#endif
}
}