From 3841260ef1f4e6d7e30e68d1ccae09bfbf176ceb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sun, 22 Dec 2013 23:05:18 +0100 Subject: Fix Java checker leaving behind temporary jar files --- logic/JavaChecker.cpp | 2 +- logic/lists/JavaVersionList.cpp | 11 ++++++----- logic/lists/JavaVersionList.h | 1 + 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/logic/JavaChecker.cpp b/logic/JavaChecker.cpp index 2b94fbb6..113974ff 100644 --- a/logic/JavaChecker.cpp +++ b/logic/JavaChecker.cpp @@ -99,6 +99,7 @@ void JavaChecker::error(QProcess::ProcessError err) if(err == QProcess::FailedToStart) { killTimer.stop(); + checkerJar.remove(); JavaCheckResult result; { @@ -116,6 +117,5 @@ void JavaChecker::timeout() if(process) { process->kill(); - process.reset(); } } diff --git a/logic/lists/JavaVersionList.cpp b/logic/lists/JavaVersionList.cpp index d2f0972c..c2886c67 100644 --- a/logic/lists/JavaVersionList.cpp +++ b/logic/lists/JavaVersionList.cpp @@ -177,9 +177,9 @@ void JavaListLoadTask::executeTask() JavaUtils ju; 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))); + m_job = std::shared_ptr(new JavaCheckerJob("Java detection")); + connect(m_job.get(), SIGNAL(finished(QList)), this, SLOT(javaCheckerFinished(QList))); + connect(m_job.get(), SIGNAL(progress(int, int)), this, SLOT(checkerProgress(int, int))); QLOG_DEBUG() << "Probing the following Java paths: "; for(QString candidate : candidate_paths) @@ -188,10 +188,10 @@ void JavaListLoadTask::executeTask() auto candidate_checker = new JavaChecker(); candidate_checker->path = candidate; - job->addJavaCheckerAction(JavaCheckerPtr(candidate_checker)); + m_job->addJavaCheckerAction(JavaCheckerPtr(candidate_checker)); } - job->start(); + m_job->start(); } void JavaListLoadTask::checkerProgress(int current, int total) @@ -203,6 +203,7 @@ void JavaListLoadTask::checkerProgress(int current, int total) void JavaListLoadTask::javaCheckerFinished(QList results) { QList candidates; + m_job.reset(); QLOG_DEBUG() << "Found the following valid Java installations:"; for(JavaCheckResult result : results) diff --git a/logic/lists/JavaVersionList.h b/logic/lists/JavaVersionList.h index 879b2480..e6cc8e5f 100644 --- a/logic/lists/JavaVersionList.h +++ b/logic/lists/JavaVersionList.h @@ -90,6 +90,7 @@ public slots: void checkerProgress(int current, int total); protected: + std::shared_ptr m_job; JavaVersionList *m_list; JavaVersion *m_currentRecommended; }; -- cgit v1.2.3