summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qfilesystemengine_unix.cpp
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-11-24 09:09:01 +0100
committerLiang Qi <liang.qi@qt.io>2016-11-24 10:31:21 +0100
commit4783de0473a288fdff7e5354c12315ba025ec7e0 (patch)
tree1dbd12129b4677c5a02307c1046fdb8cff056324 /src/corelib/io/qfilesystemengine_unix.cpp
parent60054b5940b19f4dd9780e63da1e2dce45baf131 (diff)
parent38c1057f696c4e3f168305091413428d99007c43 (diff)
Merge remote-tracking branch 'origin/5.7' into 5.8
Conflicts: src/network/socket/qnativesocketengine_winrt.cpp tools/configure/configureapp.cpp tools/configure/environment.cpp Change-Id: Ieae6f2ee004a87f041751852b687484f91ee4480
Diffstat (limited to 'src/corelib/io/qfilesystemengine_unix.cpp')
-rw-r--r--src/corelib/io/qfilesystemengine_unix.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp
index 5de85f9811..1b908eac55 100644
--- a/src/corelib/io/qfilesystemengine_unix.cpp
+++ b/src/corelib/io/qfilesystemengine_unix.cpp
@@ -65,6 +65,13 @@
#include <MobileCoreServices/MobileCoreServices.h>
#endif
+#if defined(Q_OS_DARWIN)
+// We cannot include <Foundation/Foundation.h> (it's an Objective-C header), but
+// we need these declarations:
+Q_FORWARD_DECLARE_OBJC_CLASS(NSString);
+extern "C" NSString *NSTemporaryDirectory();
+#endif
+
QT_BEGIN_NAMESPACE
#if defined(Q_OS_DARWIN)
@@ -703,8 +710,17 @@ QString QFileSystemEngine::tempPath()
return QLatin1String(QT_UNIX_TEMP_PATH_OVERRIDE);
#else
QString temp = QFile::decodeName(qgetenv("TMPDIR"));
- if (temp.isEmpty())
- temp = QLatin1String("/tmp");
+ if (temp.isEmpty()) {
+#if defined(Q_OS_DARWIN) && !defined(QT_BOOTSTRAPPED)
+ if (NSString *nsPath = NSTemporaryDirectory()) {
+ temp = QString::fromCFString((CFStringRef)nsPath);
+ } else {
+#else
+ {
+#endif
+ temp = QLatin1String("/tmp");
+ }
+ }
return QDir::cleanPath(temp);
#endif
}