ProjectExplorer: Fix handling of the QTC_USER_FILE_PATH variable

Add a quick check whether the variable is set and return nullopt
in that case. Flip the check in the below code.

Change-Id: I655662f2940946150165107a66c003a3a4bc025d
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
Friedemann Kleint
2018-07-04 11:06:24 +02:00
parent edcb8efb8b
commit 955105b790

View File

@@ -342,10 +342,9 @@ static QString generateSuffix(const QString &suffix)
static inline Utils::optional<QString> defineExternalUserFileDir()
{
static const char userFilePathVariable[] = "QTC_USER_FILE_PATH";
static QString userFilePath = QFile::decodeName(qgetenv(userFilePathVariable));
if (userFilePath.isEmpty())
return QString();
const QFileInfo fi(userFilePath);
if (Q_LIKELY(!qEnvironmentVariableIsSet(userFilePathVariable)))
return nullopt;
const QFileInfo fi(QFile::decodeName(qgetenv(userFilePathVariable)));
const QString path = fi.absoluteFilePath();
if (fi.isDir() || fi.isSymLink())
return path;
@@ -395,7 +394,7 @@ static FileName externalUserFilePath(const Utils::FileName &projectFilePath, con
FileName result;
static const optional<QString> externalUserFileDir = defineExternalUserFileDir();
if (!externalUserFileDir) {
if (externalUserFileDir) {
// Recreate the relative project file hierarchy under the shared directory.
// PersistentSettingsWriter::write() takes care of creating the path.
result = FileName::fromString(externalUserFileDir.value());