diff options
author | Liang Qi <liang.qi@qt.io> | 2016-11-24 09:36:06 +0000 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2016-11-24 11:18:22 +0000 |
commit | 3966ab51ff140f173f1f0c23fa3a9ef985c73d27 (patch) | |
tree | f30302c2c40e8d1b30e3ab589917eca5883aa3a2 /src/corelib/io/qfilesystemengine_unix.cpp | |
parent | 0861c2176c6dc1c69b733c1a843c2db5ec8ea786 (diff) | |
parent | 4783de0473a288fdff7e5354c12315ba025ec7e0 (diff) |
Merge "Merge remote-tracking branch 'origin/5.7' into 5.8" into refs/staging/5.8
Diffstat (limited to 'src/corelib/io/qfilesystemengine_unix.cpp')
-rw-r--r-- | src/corelib/io/qfilesystemengine_unix.cpp | 20 |
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 } |