Use temporary files for the java checker
This commit is contained in:
parent
45aa858090
commit
bf34aa7fbd
@ -2,6 +2,7 @@
|
|||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
|
#include <QTemporaryFile>
|
||||||
|
|
||||||
#define CHECKER_FILE "JavaChecker.jar"
|
#define CHECKER_FILE "JavaChecker.jar"
|
||||||
|
|
||||||
@ -11,14 +12,15 @@ JavaChecker::JavaChecker(QObject *parent) : QObject(parent)
|
|||||||
|
|
||||||
void JavaChecker::performCheck()
|
void JavaChecker::performCheck()
|
||||||
{
|
{
|
||||||
if(QFile::exists(CHECKER_FILE))
|
checkerJar.setFileTemplate("checker_XXXXXX.jar");
|
||||||
{
|
checkerJar.open();
|
||||||
QFile::remove(CHECKER_FILE);
|
QFile inner(":/java/checker.jar");
|
||||||
}
|
inner.open(QIODevice::ReadOnly);
|
||||||
// extract the checker
|
checkerJar.write(inner.readAll());
|
||||||
QFile(":/java/checker.jar").copy(CHECKER_FILE);
|
inner.close();
|
||||||
|
checkerJar.close();
|
||||||
|
|
||||||
QStringList args = {"-jar", CHECKER_FILE};
|
QStringList args = {"-jar", checkerJar.fileName()};
|
||||||
|
|
||||||
process.reset(new QProcess());
|
process.reset(new QProcess());
|
||||||
process->setArguments(args);
|
process->setArguments(args);
|
||||||
@ -40,6 +42,7 @@ void JavaChecker::finished(int exitcode, QProcess::ExitStatus status)
|
|||||||
killTimer.stop();
|
killTimer.stop();
|
||||||
QProcessPtr _process;
|
QProcessPtr _process;
|
||||||
_process.swap(process);
|
_process.swap(process);
|
||||||
|
checkerJar.remove();
|
||||||
|
|
||||||
JavaCheckResult result;
|
JavaCheckResult result;
|
||||||
{
|
{
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
#include <QTemporaryFile>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
class JavaChecker;
|
class JavaChecker;
|
||||||
|
|
||||||
|
|
||||||
struct JavaCheckResult
|
struct JavaCheckResult
|
||||||
{
|
{
|
||||||
QString path;
|
QString path;
|
||||||
@ -31,6 +33,7 @@ signals:
|
|||||||
private:
|
private:
|
||||||
QProcessPtr process;
|
QProcessPtr process;
|
||||||
QTimer killTimer;
|
QTimer killTimer;
|
||||||
|
QTemporaryFile checkerJar;
|
||||||
public
|
public
|
||||||
slots:
|
slots:
|
||||||
void timeout();
|
void timeout();
|
||||||
|
Loading…
Reference in New Issue
Block a user