Return a properly sorted list of checked javas

This commit is contained in:
Sky 2014-01-07 03:16:47 +00:00
parent 012b007e56
commit 5fe0ed7e8f
4 changed files with 11 additions and 4 deletions

View File

@ -47,6 +47,7 @@ void JavaChecker::finished(int exitcode, QProcess::ExitStatus status)
JavaCheckResult result; JavaCheckResult result;
{ {
result.path = path; result.path = path;
result.id = id;
} }
if (status == QProcess::CrashExit || exitcode == 1) if (status == QProcess::CrashExit || exitcode == 1)
@ -104,6 +105,7 @@ void JavaChecker::error(QProcess::ProcessError err)
JavaCheckResult result; JavaCheckResult result;
{ {
result.path = path; result.path = path;
result.id = id;
} }
emit checkFinished(result); emit checkFinished(result);

View File

@ -15,6 +15,7 @@ struct JavaCheckResult
QString javaVersion; QString javaVersion;
bool valid = false; bool valid = false;
bool is_64bit = false; bool is_64bit = false;
int id;
}; };
typedef std::shared_ptr<QProcess> QProcessPtr; typedef std::shared_ptr<QProcess> QProcessPtr;
@ -27,6 +28,7 @@ public:
void performCheck(); void performCheck();
QString path; QString path;
int id;
signals: signals:
void checkFinished(JavaCheckResult result); void checkFinished(JavaCheckResult result);

View File

@ -26,10 +26,8 @@ void JavaCheckerJob::partFinished(JavaCheckResult result)
<< javacheckers.size(); << javacheckers.size();
emit progress(num_finished, javacheckers.size()); emit progress(num_finished, javacheckers.size());
javaresults.append(result); QLOG_INFO() << "after replace" << result.id << javaresults.size();
int result_size = javacheckers.size(); javaresults.replace(result.id, result);
emit progress(num_finished, result_size);
if (num_finished == javacheckers.size()) if (num_finished == javacheckers.size())
{ {
@ -43,6 +41,7 @@ void JavaCheckerJob::start()
m_running = true; m_running = true;
for (auto iter : javacheckers) for (auto iter : javacheckers)
{ {
javaresults.append(JavaCheckResult());
connect(iter.get(), SIGNAL(checkFinished(JavaCheckResult)), SLOT(partFinished(JavaCheckResult))); connect(iter.get(), SIGNAL(checkFinished(JavaCheckResult)), SLOT(partFinished(JavaCheckResult)));
iter->performCheck(); iter->performCheck();
} }

View File

@ -182,13 +182,17 @@ void JavaListLoadTask::executeTask()
connect(m_job.get(), SIGNAL(progress(int, int)), this, SLOT(checkerProgress(int, int))); connect(m_job.get(), SIGNAL(progress(int, int)), this, SLOT(checkerProgress(int, int)));
QLOG_DEBUG() << "Probing the following Java paths: "; QLOG_DEBUG() << "Probing the following Java paths: ";
int id = 0;
for(QString candidate : candidate_paths) for(QString candidate : candidate_paths)
{ {
QLOG_DEBUG() << " " << candidate; QLOG_DEBUG() << " " << candidate;
auto candidate_checker = new JavaChecker(); auto candidate_checker = new JavaChecker();
candidate_checker->path = candidate; candidate_checker->path = candidate;
candidate_checker->id = id;
m_job->addJavaCheckerAction(JavaCheckerPtr(candidate_checker)); m_job->addJavaCheckerAction(JavaCheckerPtr(candidate_checker));
id++;
} }
m_job->start(); m_job->start();