summaryrefslogtreecommitdiffstats
path: root/api/logic/java
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2017-06-27 04:32:53 +0200
committerPetr Mrázek <peterix@gmail.com>2017-06-27 04:32:53 +0200
commit36f3e24cf31cfe6fad413d70ab8ad187a5251fb7 (patch)
tree8da3bebaf8f8f4aa275d348e8c2ed8028202c445 /api/logic/java
parent89d3a66658ebdb16582a4d7a2cab57cfd6906393 (diff)
downloadMultiMC-36f3e24cf31cfe6fad413d70ab8ad187a5251fb7.tar
MultiMC-36f3e24cf31cfe6fad413d70ab8ad187a5251fb7.tar.gz
MultiMC-36f3e24cf31cfe6fad413d70ab8ad187a5251fb7.tar.lz
MultiMC-36f3e24cf31cfe6fad413d70ab8ad187a5251fb7.tar.xz
MultiMC-36f3e24cf31cfe6fad413d70ab8ad187a5251fb7.zip
NOISSUE remove some bad code in various Task related classes
Diffstat (limited to 'api/logic/java')
-rw-r--r--api/logic/java/JavaCheckerJob.cpp2
-rw-r--r--api/logic/java/JavaCheckerJob.h29
-rw-r--r--api/logic/java/JavaInstallList.cpp5
-rw-r--r--api/logic/java/JavaInstallList.h2
-rw-r--r--api/logic/java/JavaUtils.cpp1
-rw-r--r--api/logic/java/JavaUtils.h1
6 files changed, 10 insertions, 30 deletions
diff --git a/api/logic/java/JavaCheckerJob.cpp b/api/logic/java/JavaCheckerJob.cpp
index a111af20..c787233c 100644
--- a/api/logic/java/JavaCheckerJob.cpp
+++ b/api/logic/java/JavaCheckerJob.cpp
@@ -28,7 +28,7 @@ void JavaCheckerJob::partFinished(JavaCheckResult result)
if (num_finished == javacheckers.size())
{
- emit finished(javaresults);
+ emitSucceeded();
}
}
diff --git a/api/logic/java/JavaCheckerJob.h b/api/logic/java/JavaCheckerJob.h
index c27a50c3..dc035cb2 100644
--- a/api/logic/java/JavaCheckerJob.h
+++ b/api/logic/java/JavaCheckerJob.h
@@ -22,6 +22,7 @@
class JavaCheckerJob;
typedef std::shared_ptr<JavaCheckerJob> JavaCheckerJobPtr;
+// FIXME: this just seems horribly redundant
class JavaCheckerJob : public Task
{
Q_OBJECT
@@ -31,37 +32,19 @@ public:
bool addJavaCheckerAction(JavaCheckerPtr base)
{
javacheckers.append(base);
- total_progress++;
// if this is already running, the action needs to be started right away!
if (isRunning())
{
- setProgress(current_progress, total_progress);
- connect(base.get(), SIGNAL(checkFinished(JavaCheckResult)), SLOT(partFinished(JavaCheckResult)));
-
+ setProgress(num_finished, javacheckers.size());
+ connect(base.get(), &JavaChecker::checkFinished, this, &JavaCheckerJob::partFinished);
base->performCheck();
}
return true;
}
-
- JavaCheckerPtr operator[](int index)
- {
- return javacheckers[index];
- }
- ;
- JavaCheckerPtr first()
+ QList<JavaCheckResult> getResults()
{
- if (javacheckers.size())
- return javacheckers[0];
- return JavaCheckerPtr();
+ return javaresults;
}
- int size() const
- {
- return javacheckers.size();
- }
-
-signals:
- void started();
- void finished(QList<JavaCheckResult>);
private slots:
void partFinished(JavaCheckResult result);
@@ -73,7 +56,5 @@ private:
QString m_job_name;
QList<JavaCheckerPtr> javacheckers;
QList<JavaCheckResult> javaresults;
- qint64 current_progress = 0;
- qint64 total_progress = 0;
int num_finished = 0;
};
diff --git a/api/logic/java/JavaInstallList.cpp b/api/logic/java/JavaInstallList.cpp
index 44ac861d..39657f40 100644
--- a/api/logic/java/JavaInstallList.cpp
+++ b/api/logic/java/JavaInstallList.cpp
@@ -150,7 +150,7 @@ void JavaListLoadTask::executeTask()
QList<QString> candidate_paths = ju.FindJavaPaths();
m_job = std::shared_ptr<JavaCheckerJob>(new JavaCheckerJob("Java detection"));
- connect(m_job.get(), SIGNAL(finished(QList<JavaCheckResult>)), this, SLOT(javaCheckerFinished(QList<JavaCheckResult>)));
+ connect(m_job.get(), &Task::finished, this, &JavaListLoadTask::javaCheckerFinished);
connect(m_job.get(), &Task::progress, this, &Task::setProgress);
qDebug() << "Probing the following Java paths: ";
@@ -170,9 +170,10 @@ void JavaListLoadTask::executeTask()
m_job->start();
}
-void JavaListLoadTask::javaCheckerFinished(QList<JavaCheckResult> results)
+void JavaListLoadTask::javaCheckerFinished()
{
QList<JavaInstallPtr> candidates;
+ auto results = m_job->getResults();
qDebug() << "Found the following valid Java installations:";
for(JavaCheckResult result : results)
diff --git a/api/logic/java/JavaInstallList.h b/api/logic/java/JavaInstallList.h
index 934e588b..e0fa842e 100644
--- a/api/logic/java/JavaInstallList.h
+++ b/api/logic/java/JavaInstallList.h
@@ -72,7 +72,7 @@ public:
void executeTask() override;
public slots:
- void javaCheckerFinished(QList<JavaCheckResult> results);
+ void javaCheckerFinished();
protected:
std::shared_ptr<JavaCheckerJob> m_job;
diff --git a/api/logic/java/JavaUtils.cpp b/api/logic/java/JavaUtils.cpp
index 0c2e72d7..fd28cca9 100644
--- a/api/logic/java/JavaUtils.cpp
+++ b/api/logic/java/JavaUtils.cpp
@@ -22,7 +22,6 @@
#include <QDebug>
#include "java/JavaUtils.h"
-#include "java/JavaCheckerJob.h"
#include "java/JavaInstallList.h"
#include "FileSystem.h"
diff --git a/api/logic/java/JavaUtils.h b/api/logic/java/JavaUtils.h
index 4418ac26..25fd57f5 100644
--- a/api/logic/java/JavaUtils.h
+++ b/api/logic/java/JavaUtils.h
@@ -17,7 +17,6 @@
#include <QStringList>
-#include "JavaCheckerJob.h"
#include "JavaChecker.h"
#include "JavaInstallList.h"