summaryrefslogtreecommitdiffstats
path: root/src/serialport/qserialport_unix_p.h
diff options
context:
space:
mode:
authorLaszlo Papp <lpapp@kde.org>2013-11-06 07:04:22 +0000
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-11-06 08:54:01 +0100
commited974e0b6cfda1b6b2ac33161ccf2db42b68c710 (patch)
tree40dfe560176f6967e227c10ffedce844d503df22 /src/serialport/qserialport_unix_p.h
parent26458aef426cde967433035d2af0ab244db3aec0 (diff)
Replace the home-grown QTtyLocker with QLockFile
This can be more widely adopted later, and not just for the Linux backend. It would be more than a few-liner change for stable, so this change change is kept minimal (of course apart from the big file integration). The only big problem with QLockFile currently is that we cannot change the file name on the fly as it seems, just for construction. Even the copy constructor and assignment operators are private. It means the class currently seems to be non-eligible for QtSerialPort needs where it is necessary to change for open anytime, and be accessible by open/serial for the before and after read/write session for the same file name. Also, I had to get rid of the QTemporary file internals because we cannot have access to the internal engine with Qt 4. I also had to make a small thread class for the protected msleep in QThread for Qt 4. There was a small improvement for the hidden dependency problem with gethostname. That was also sent to QtCore proper. Also, the windows backend for the QLockFile class is not copied for simplicity. It would not be used as of now. There is also a short convenience around QLockFile established to handle system-wide lock file paths. There is also some error handling added if the lock directory paths are not readable or writable. This will end users identify the problems like on Android. Tested on Archlinux with Qt 4 and then 5. Task-number: QTBUG-34474 Change-Id: I7adf29527c01ad331d3eeff5ae4c5a4113bde083 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Diffstat (limited to 'src/serialport/qserialport_unix_p.h')
-rw-r--r--src/serialport/qserialport_unix_p.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/serialport/qserialport_unix_p.h b/src/serialport/qserialport_unix_p.h
index 2d09ee42..15bb5f8f 100644
--- a/src/serialport/qserialport_unix_p.h
+++ b/src/serialport/qserialport_unix_p.h
@@ -45,6 +45,11 @@
#include "qserialport_p.h"
+#include <QtCore/qlockfile.h>
+#include <QtCore/qscopedpointer.h>
+#include <QtCore/qfileinfo.h>
+#include <QtCore/qstringlist.h>
+
#include <limits.h>
#include <termios.h>
#ifndef Q_OS_ANDROID
@@ -78,6 +83,8 @@ struct serial_struct {
QT_BEGIN_NAMESPACE
+QString serialPortLockFilePath(const QString &portName);
+
class QSocketNotifier;
class QSerialPortPrivate : public QSerialPortPrivateData
@@ -151,6 +158,8 @@ public:
bool emittedReadyRead;
bool emittedBytesWritten;
+ QScopedPointer<QLockFile> lockFileScopedPointer;
+
private:
bool updateTermios();