use qEnvironmentVariable instead of qgetenv in JavaUtils

Signed-off-by: Tayou <tayou@gmx.net>
This commit is contained in:
Tayou 2022-08-18 23:16:50 +02:00
parent bb4861cf0d
commit 26f31e9288
No known key found for this signature in database
GPG Key ID: 02CA43C1CB6E9887

View File

@ -174,17 +174,17 @@ JavaInstallPtr JavaUtils::GetDefaultJava()
QStringList addJavasFromEnv(QList<QString> javas) QStringList addJavasFromEnv(QList<QString> javas)
{ {
QByteArray env = qgetenv("POLYMC_JAVA_PATHS"); auto env = qEnvironmentVariable("POLYMC_JAVA_PATHS");
#if defined(Q_OS_WIN32) #if defined(Q_OS_WIN32)
QList<QString> javaPaths = QString::fromLocal8Bit(env).replace("\\", "/").split(QLatin1String(";")); QList<QString> javaPaths = env.replace("\\", "/").split(QLatin1String(";"));
QByteArray envPath = qgetenv("PATH"); auto envPath = qEnvironmentVariable("PATH");
QList<QString> javaPathsfromPath = QString::fromLocal8Bit(envPath).replace("\\", "/").split(QLatin1String(";")); QList<QString> javaPathsfromPath = envPath.replace("\\", "/").split(QLatin1String(";"));
for (QString string : javaPathsfromPath) { for (QString string : javaPathsfromPath) {
javaPaths.append(string + "/javaw.exe"); javaPaths.append(string + "/javaw.exe");
} }
#else #else
QList<QString> javaPaths = QString::fromLocal8Bit(env).split(QLatin1String(":")); QList<QString> javaPaths = env.split(QLatin1String(":"));
#endif #endif
for(QString i : javaPaths) for(QString i : javaPaths)
{ {