Revert "QFileSystemEngine::tempPath: simplify handling of fallbacks"

This reverts commit 17f5cdd39ed8a6e9cf25e99003478adfef572485.

Reason for revert: QTBUG-137416

Change-Id: I401befd260440d08a159c67ea0d0617dc88a9065
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Jani Heikkinen 2025-06-07 20:19:53 +00:00 committed by The Qt Project
parent a1c1dda418
commit 2770bb4927

View File

@ -1864,8 +1864,6 @@ static constexpr QLatin1StringView nativeTempPath() noexcept
QLatin1StringView temp = _PATH_TMP ""_L1;
static_assert(_PATH_TMP[0] == '/', "_PATH_TMP needs to be absolute");
static_assert(_PATH_TMP[1] != '\0', "Are you really sure _PATH_TMP should be the root dir??");
if (temp.endsWith(u'/'))
temp.chop(1);
return temp;
}
@ -1875,12 +1873,17 @@ QString QFileSystemEngine::tempPath()
return QT_UNIX_TEMP_PATH_OVERRIDE ""_L1;
#else
QString temp = qEnvironmentVariable("TMPDIR");
# if defined(Q_OS_DARWIN) && !defined(QT_BOOTSTRAPPED)
if (NSString *nsPath; temp.isEmpty() && (nsPath = NSTemporaryDirectory()))
temp = QString::fromCFString((CFStringRef)nsPath);
# endif
if (temp.isEmpty())
return nativeTempPath();
if (temp.isEmpty()) {
if (false) {
#if defined(Q_OS_DARWIN) && !defined(QT_BOOTSTRAPPED)
} else if (NSString *nsPath = NSTemporaryDirectory()) {
temp = QString::fromCFString((CFStringRef)nsPath);
#endif
} else {
constexpr auto nativeTemp = nativeTempPath();
temp = nativeTemp;
}
}
// the environment variable may also end in '/'
if (temp.size() > 1 && temp.endsWith(u'/'))