GH-1133 fix bad java path detection some more

This commit is contained in:
Petr Mrázek 2015-08-24 00:56:45 +02:00
parent 961c1c61b8
commit bc917668ff
3 changed files with 19 additions and 4 deletions

View File

@ -21,15 +21,19 @@
void CheckJava::executeTask() void CheckJava::executeTask()
{ {
auto instance = m_parent->instance(); auto instance = m_parent->instance();
auto javaPath = instance->settings()->get("JavaPath").toString(); m_javaPath = instance->settings()->get("JavaPath").toString();
emit logLine("Java path is:\n" + m_javaPath + "\n\n", MessageLevel::MultiMC);
auto realJavaPath = QStandardPaths::findExecutable(m_javaPath); auto realJavaPath = QStandardPaths::findExecutable(m_javaPath);
if (realJavaPath.isEmpty()) if (realJavaPath.isEmpty())
{ {
emit logLine(tr("The java binary \"%1\" couldn't be found. You may have to set up java " emit logLine(tr("The java binary \"%1\" couldn't be found. Please set up java in the settings.").arg(m_javaPath),
"if Minecraft fails to launch.").arg(m_javaPath),
MessageLevel::Warning); MessageLevel::Warning);
emitFailed(tr("Java path is not valid."));
return;
}
else
{
emit logLine("Java path is:\n" + m_javaPath + "\n\n", MessageLevel::MultiMC);
} }
QFileInfo javaInfo(realJavaPath); QFileInfo javaInfo(realJavaPath);
@ -47,6 +51,7 @@ void CheckJava::executeTask()
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->m_path = realJavaPath;
m_JavaChecker->performCheck(); m_JavaChecker->performCheck();
return;
} }
emitSucceeded(); emitSucceeded();
} }

View File

@ -31,6 +31,7 @@
#include <launch/steps/Update.h> #include <launch/steps/Update.h>
#include <launch/steps/PreLaunchCommand.h> #include <launch/steps/PreLaunchCommand.h>
#include <launch/steps/TextPrint.h> #include <launch/steps/TextPrint.h>
#include <launch/steps/CheckJava.h>
#include "minecraft/ModList.h" #include "minecraft/ModList.h"
#include <MMCZip.h> #include <MMCZip.h>
@ -136,6 +137,10 @@ std::shared_ptr<LaunchTask> LegacyInstance::createLaunchTask(AuthSessionPtr sess
{ {
process->appendStep(std::make_shared<TextPrint>(pptr, "Minecraft folder is:\n" + minecraftRoot() + "\n\n", MessageLevel::MultiMC)); process->appendStep(std::make_shared<TextPrint>(pptr, "Minecraft folder is:\n" + minecraftRoot() + "\n\n", MessageLevel::MultiMC));
} }
{
auto step = std::make_shared<CheckJava>(pptr);
process->appendStep(step);
}
// run pre-launch command if that's needed // run pre-launch command if that's needed
if(getPreLaunchCommand().size()) if(getPreLaunchCommand().size())
{ {

View File

@ -29,6 +29,7 @@
#include <launch/steps/PostLaunchCommand.h> #include <launch/steps/PostLaunchCommand.h>
#include <launch/steps/TextPrint.h> #include <launch/steps/TextPrint.h>
#include <launch/steps/ModMinecraftJar.h> #include <launch/steps/ModMinecraftJar.h>
#include <launch/steps/CheckJava.h>
#include "minecraft/OneSixProfileStrategy.h" #include "minecraft/OneSixProfileStrategy.h"
#include "MMCZip.h" #include "MMCZip.h"
@ -243,6 +244,10 @@ std::shared_ptr<LaunchTask> OneSixInstance::createLaunchTask(AuthSessionPtr sess
{ {
process->appendStep(std::make_shared<TextPrint>(pptr, "Minecraft folder is:\n" + minecraftRoot() + "\n\n", MessageLevel::MultiMC)); process->appendStep(std::make_shared<TextPrint>(pptr, "Minecraft folder is:\n" + minecraftRoot() + "\n\n", MessageLevel::MultiMC));
} }
{
auto step = std::make_shared<CheckJava>(pptr);
process->appendStep(step);
}
// run pre-launch command if that's needed // run pre-launch command if that's needed
if(getPreLaunchCommand().size()) if(getPreLaunchCommand().size())
{ {