summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Shienkov <denis.shienkov@gmail.com>2015-05-07 20:55:39 +0300
committerDenis Shienkov <denis.shienkov@gmail.com>2015-05-12 13:08:48 +0000
commitad56086040e6b40565214380b083ecf986924f92 (patch)
treedf6c471ededff82ff014efe42fce9dbca9a89c80
parentda396bc54b776da682ffdcd2aa61f504d607bc12 (diff)
downloadqtserialport-ad56086040e6b40565214380b083ecf986924f92.tar.gz
Allow to open the device when using the App Sandbox on OSX
When running the App Sandbox, a system has no any temporary directories which can be shared between applications (or, maybe, it is configurable option): * https://developer.apple.com/library/mac/documentation/Security/Conceptual/AppSandboxDesignGuide/AboutAppSandbox/AboutAppSandbox.html In this case QSP::open() can not create a lock file that lead to fails when opening. Workaround it is to use the QStandardPaths::writableLocation(QStandardPaths::TempLocation) for receiving a temporal directory of application. Where the writableLocation() implicitly uses the NSTemporaryDirectory function that is the recommended way (see "The App Sandbox Container Directory") in here: * https://developer.apple.com/library/mac/documentation/Security/Conceptual/AppSandboxDesignGuide/AppSandboxInDepth/AppSandboxInDepth.html#//apple_ref/doc/uid/TP40011183-CH3-SW4 This will allow to open the serial port, but the locking feature will not work properly. Task-number: QTBUG-45338 Change-Id: Iea52aada11493126b0f58c40488c38c86f69fca5 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
-rw-r--r--src/serialport/qserialport_unix.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/serialport/qserialport_unix.cpp b/src/serialport/qserialport_unix.cpp
index 9048a3b..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)
@@ -94,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)