summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSky <git@bunnies.cc>2013-12-12 14:56:32 +0000
committerSky <git@bunnies.cc>2013-12-12 14:56:32 +0000
commita2b094102999af646dd1dd962ced435197466b97 (patch)
treead266856e27129a83e671d7e492eb14ebe0410c1
parentf3fffd52594065995d4c355de1571b36b2f2bbeb (diff)
downloadMultiMC-a2b094102999af646dd1dd962ced435197466b97.tar
MultiMC-a2b094102999af646dd1dd962ced435197466b97.tar.gz
MultiMC-a2b094102999af646dd1dd962ced435197466b97.tar.lz
MultiMC-a2b094102999af646dd1dd962ced435197466b97.tar.xz
MultiMC-a2b094102999af646dd1dd962ced435197466b97.zip
Java version list should be sorted, JRE->JDK, 64->32
-rw-r--r--logic/JavaUtils.cpp31
-rw-r--r--logic/JavaUtils.h2
-rw-r--r--logic/lists/JavaVersionList.cpp20
3 files changed, 28 insertions, 25 deletions
diff --git a/logic/JavaUtils.cpp b/logic/JavaUtils.cpp
index 77972874..91463688 100644
--- a/logic/JavaUtils.cpp
+++ b/logic/JavaUtils.cpp
@@ -139,9 +139,9 @@ QList<JavaVersionPtr> JavaUtils::FindJavaFromRegistryKey(DWORD keyType, QString
return javas;
}
-QList<JavaVersionPtr> JavaUtils::FindJavaPaths()
+QList<QString> JavaUtils::FindJavaPaths()
{
- QList<JavaVersionPtr> candidates;
+ QList<JavaVersionPtr> java_candidates;
QList<JavaVersionPtr> JRE64s = this->FindJavaFromRegistryKey(
KEY_WOW64_64KEY, "SOFTWARE\\JavaSoft\\Java Runtime Environment");
@@ -152,17 +152,26 @@ QList<JavaVersionPtr> JavaUtils::FindJavaPaths()
QList<JavaVersionPtr> JDK32s = this->FindJavaFromRegistryKey(
KEY_WOW64_32KEY, "SOFTWARE\\JavaSoft\\Java Development Kit");
- candidates.append(JRE64s);
- candidates.append(JDK64s);
- candidates.append(JRE32s);
- candidates.append(JDK32s);
+ java_candidates.append(JRE64s);
+ java_candidates.append(JDK64s);
+ java_candidates.append(JRE32s);
+ java_candidates.append(JDK32s);
+
+ QList<QString> candidates;
+ for(JavaVersionPtr java_candidate : java_candidates)
+ {
+ if(!candidates.contains(java_candidate->path))
+ {
+ candidates.append(java_candidate->path);
+ }
+ }
- candidates.append(MakeJavaPtr("C:/Program Files/Java/jre7/bin/java.exe"));
- candidates.append(MakeJavaPtr("C:/Program Files/Java/jre6/bin/java.exe"));
- candidates.append(MakeJavaPtr("C:/Program Files (x86)/Java/jre7/bin/java.exe"));
- candidates.append(MakeJavaPtr("C:/Program Files (x86)/Java/jre6/bin/java.exe"));
+ candidates.append("C:/Program Files/Java/jre7/bin/java.exe");
+ candidates.append("C:/Program Files/Java/jre6/bin/java.exe");
+ candidates.append("C:/Program Files (x86)/Java/jre7/bin/java.exe");
+ candidates.append("C:/Program Files (x86)/Java/jre6/bin/java.exe");
- candidates.append(this->GetDefaultJava());
+ candidates.append(this->GetDefaultJava()->path);
return candidates;
}
diff --git a/logic/JavaUtils.h b/logic/JavaUtils.h
index d056cbbe..22a68ef3 100644
--- a/logic/JavaUtils.h
+++ b/logic/JavaUtils.h
@@ -34,7 +34,7 @@ public:
JavaUtils();
JavaVersionPtr MakeJavaPtr(QString path, QString id = "unknown", QString arch = "unknown");
- QList<JavaVersionPtr> FindJavaPaths();
+ QList<QString> FindJavaPaths();
JavaVersionPtr GetDefaultJava();
#if WINDOWS
diff --git a/logic/lists/JavaVersionList.cpp b/logic/lists/JavaVersionList.cpp
index f69c2b59..d2f0972c 100644
--- a/logic/lists/JavaVersionList.cpp
+++ b/logic/lists/JavaVersionList.cpp
@@ -174,28 +174,23 @@ void JavaListLoadTask::executeTask()
{
setStatus("Detecting Java installations...");
- QSet<QString> candidate_paths;
JavaUtils ju;
-
- QList<JavaVersionPtr> candidates = ju.FindJavaPaths();
-
- for(JavaVersionPtr &candidate : candidates)
- {
- candidate_paths.insert(candidate->path);
- }
+ QList<QString> candidate_paths = ju.FindJavaPaths();
auto job = new JavaCheckerJob("Java detection");
connect(job, SIGNAL(finished(QList<JavaCheckResult>)), this, SLOT(javaCheckerFinished(QList<JavaCheckResult>)));
connect(job, SIGNAL(progress(int, int)), this, SLOT(checkerProgress(int, int)));
- for(const QString candidate : candidate_paths)
+ QLOG_DEBUG() << "Probing the following Java paths: ";
+ for(QString candidate : candidate_paths)
{
+ QLOG_DEBUG() << " " << candidate;
+
auto candidate_checker = new JavaChecker();
candidate_checker->path = candidate;
job->addJavaCheckerAction(JavaCheckerPtr(candidate_checker));
}
- QLOG_DEBUG() << "Starting java checker job with" << job->size() << "candidates";
job->start();
}
@@ -209,7 +204,7 @@ void JavaListLoadTask::javaCheckerFinished(QList<JavaCheckResult> results)
{
QList<JavaVersionPtr> candidates;
- QLOG_DEBUG() << "Got Java checker results:";
+ QLOG_DEBUG() << "Found the following valid Java installations:";
for(JavaCheckResult result : results)
{
if(result.valid)
@@ -221,7 +216,7 @@ void JavaListLoadTask::javaCheckerFinished(QList<JavaCheckResult> results)
javaVersion->path = result.path;
candidates.append(javaVersion);
- QLOG_DEBUG() << javaVersion->id << javaVersion->arch << javaVersion->path;
+ QLOG_DEBUG() << " " << javaVersion->id << javaVersion->arch << javaVersion->path;
}
}
@@ -238,6 +233,5 @@ void JavaListLoadTask::javaCheckerFinished(QList<JavaCheckResult> results)
}
m_list->updateListData(javas_bvp);
-
emitSucceeded();
}