From 151a0ca11ec658525e151b7130543a364c41a3e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Mon, 24 Aug 2015 09:38:05 +0200 Subject: [PATCH] GH-1124 tell user which java path is wrong. --- logic/launch/steps/CheckJava.cpp | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/logic/launch/steps/CheckJava.cpp b/logic/launch/steps/CheckJava.cpp index 4a9fcbf9..92c65d0a 100644 --- a/logic/launch/steps/CheckJava.cpp +++ b/logic/launch/steps/CheckJava.cpp @@ -21,13 +21,26 @@ void CheckJava::executeTask() { auto instance = m_parent->instance(); - m_javaPath = instance->settings()->get("JavaPath").toString(); + auto settings = instance->settings(); + m_javaPath = settings->get("JavaPath").toString(); + bool perInstance = settings->get("OverrideJava").toBool() || settings->get("OverrideJavaLocation").toBool(); auto realJavaPath = QStandardPaths::findExecutable(m_javaPath); if (realJavaPath.isEmpty()) { - emit logLine(tr("The java binary \"%1\" couldn't be found. Please set up java in the settings.").arg(m_javaPath), - MessageLevel::Warning); + if (perInstance) + { + emit logLine( + tr("The java binary \"%1\" couldn't be found. Please fix the java path " + "override in the instance's settings or disable it.").arg(m_javaPath), + MessageLevel::Warning); + } + else + { + emit logLine(tr("The java binary \"%1\" couldn't be found. Please set up java in " + "the settings.").arg(m_javaPath), + MessageLevel::Warning); + } emitFailed(tr("Java path is not valid.")); return; } @@ -38,17 +51,18 @@ void CheckJava::executeTask() QFileInfo javaInfo(realJavaPath); qlonglong javaUnixTime = javaInfo.lastModified().toMSecsSinceEpoch(); - auto storedUnixTime = instance->settings()->get("JavaTimestamp").toLongLong(); + auto storedUnixTime = settings->get("JavaTimestamp").toLongLong(); m_javaUnixTime = javaUnixTime; // if they are not the same, check! - if(javaUnixTime != storedUnixTime) + if (javaUnixTime != storedUnixTime) { m_JavaChecker = std::make_shared(); bool successful = false; QString errorLog; QString version; emit logLine(tr("Checking Java version..."), MessageLevel::MultiMC); - connect(m_JavaChecker.get(), &JavaChecker::checkFinished, this, &CheckJava::checkJavaFinished); + connect(m_JavaChecker.get(), &JavaChecker::checkFinished, this, + &CheckJava::checkJavaFinished); m_JavaChecker->m_path = realJavaPath; m_JavaChecker->performCheck(); return; @@ -58,7 +72,7 @@ void CheckJava::executeTask() void CheckJava::checkJavaFinished(JavaCheckResult result) { - if(!result.valid) + if (!result.valid) { // Error message displayed if java can't start emit logLine(tr("Could not start java:"), MessageLevel::Error); @@ -69,7 +83,8 @@ void CheckJava::checkJavaFinished(JavaCheckResult result) else { auto instance = m_parent->instance(); - emit logLine(tr("Java version is %1!\n").arg(result.javaVersion), MessageLevel::MultiMC); + emit logLine(tr("Java version is %1!\n").arg(result.javaVersion), + MessageLevel::MultiMC); instance->settings()->set("JavaVersion", result.javaVersion); instance->settings()->set("JavaTimestamp", m_javaUnixTime); emitSucceeded();