From a2b094102999af646dd1dd962ced435197466b97 Mon Sep 17 00:00:00 2001 From: Sky Date: Thu, 12 Dec 2013 14:56:32 +0000 Subject: Java version list should be sorted, JRE->JDK, 64->32 --- logic/JavaUtils.cpp | 31 ++++++++++++++++++++----------- logic/JavaUtils.h | 2 +- logic/lists/JavaVersionList.cpp | 20 +++++++------------- 3 files changed, 28 insertions(+), 25 deletions(-) (limited to 'logic') 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 JavaUtils::FindJavaFromRegistryKey(DWORD keyType, QString return javas; } -QList JavaUtils::FindJavaPaths() +QList JavaUtils::FindJavaPaths() { - QList candidates; + QList java_candidates; QList JRE64s = this->FindJavaFromRegistryKey( KEY_WOW64_64KEY, "SOFTWARE\\JavaSoft\\Java Runtime Environment"); @@ -152,17 +152,26 @@ QList JavaUtils::FindJavaPaths() QList 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 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 FindJavaPaths(); + QList 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 candidate_paths; JavaUtils ju; - - QList candidates = ju.FindJavaPaths(); - - for(JavaVersionPtr &candidate : candidates) - { - candidate_paths.insert(candidate->path); - } + QList candidate_paths = ju.FindJavaPaths(); auto job = new JavaCheckerJob("Java detection"); connect(job, SIGNAL(finished(QList)), this, SLOT(javaCheckerFinished(QList))); 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 results) { QList 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 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 results) } m_list->updateListData(javas_bvp); - emitSucceeded(); } -- cgit v1.2.3