diff --git a/src/gui/kernel/qhighdpiscaling.cpp b/src/gui/kernel/qhighdpiscaling.cpp index 3d518409a9e..6fead184c2a 100644 --- a/src/gui/kernel/qhighdpiscaling.cpp +++ b/src/gui/kernel/qhighdpiscaling.cpp @@ -30,18 +30,14 @@ static const char usePhysicalDpiEnvVar[] = "QT_USE_PHYSICAL_DPI"; static std::optional qEnvironmentVariableOptionalString(const char *name) { - if (!qEnvironmentVariableIsSet(name)) - return std::nullopt; - - return std::optional(qEnvironmentVariable(name)); + QString value = qEnvironmentVariable(name); + return value.isNull() ? std::nullopt : std::optional(std::move(value)); } static std::optional qEnvironmentVariableOptionalByteArray(const char *name) { - if (!qEnvironmentVariableIsSet(name)) - return std::nullopt; - - return std::optional(qgetenv(name)); + QByteArray value = qgetenv(name); + return value.isNull() ? std::nullopt : std::optional(std::move(value)); } static std::optional qEnvironmentVariableOptionalInt(const char *name) @@ -54,11 +50,12 @@ static std::optional qEnvironmentVariableOptionalInt(const char *name) static std::optional qEnvironmentVariableOptionalReal(const char *name) { - if (!qEnvironmentVariableIsSet(name)) + const QByteArray val = qgetenv(name); + if (val.isNull()) return std::nullopt; bool ok = false; - const qreal value = qEnvironmentVariable(name).toDouble(&ok); + const qreal value = val.toDouble(&ok); return ok ? std::optional(value) : std::nullopt; }