2015-05-04 04:50:48 +05:30
|
|
|
#include "JavaCommon.h"
|
|
|
|
#include "dialogs/CustomMessageBox.h"
|
|
|
|
#include <MMCStrings.h>
|
|
|
|
|
|
|
|
bool JavaCommon::checkJVMArgs(QString jvmargs, QWidget *parent)
|
|
|
|
{
|
|
|
|
if (jvmargs.contains("-XX:PermSize=") || jvmargs.contains(QRegExp("-Xm[sx]")))
|
|
|
|
{
|
|
|
|
CustomMessageBox::selectable(
|
|
|
|
parent, QObject::tr("JVM arguments warning"),
|
|
|
|
QObject::tr("You tried to manually set a JVM memory option (using "
|
|
|
|
" \"-XX:PermSize\", \"-Xmx\" or \"-Xms\") - there"
|
|
|
|
" are dedicated boxes for these in the settings (Java"
|
|
|
|
" tab, in the Memory group at the top).\n"
|
|
|
|
"Your manual settings will be overridden by the"
|
|
|
|
" dedicated options.\n"
|
|
|
|
"This message will be displayed until you remove them"
|
|
|
|
" from the JVM arguments."),
|
|
|
|
QMessageBox::Warning)->exec();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-01-07 11:22:09 +05:30
|
|
|
void JavaCommon::javaWasOk(QWidget *parent, JavaCheckResult result)
|
2015-05-04 04:50:48 +05:30
|
|
|
{
|
|
|
|
QString text;
|
2017-01-07 11:22:09 +05:30
|
|
|
text += QObject::tr("Java test succeeded!<br />Platform reported: %1<br />Java version "
|
|
|
|
"reported: %2<br />").arg(result.realPlatform, result.javaVersion.toString());
|
2015-05-04 04:58:16 +05:30
|
|
|
if (result.errorLog.size())
|
2015-05-04 04:50:48 +05:30
|
|
|
{
|
2015-05-04 04:58:16 +05:30
|
|
|
auto htmlError = result.errorLog;
|
2015-05-04 04:50:48 +05:30
|
|
|
htmlError.replace('\n', "<br />");
|
2017-01-07 11:22:09 +05:30
|
|
|
text += QObject::tr("<br />Warnings:<br /><font color=\"orange\">%1</font>").arg(htmlError);
|
2015-05-04 04:50:48 +05:30
|
|
|
}
|
2017-01-07 11:22:09 +05:30
|
|
|
CustomMessageBox::selectable(parent, QObject::tr("Java test success"), text, QMessageBox::Information)->show();
|
2015-05-04 04:50:48 +05:30
|
|
|
}
|
|
|
|
|
2017-01-07 11:22:09 +05:30
|
|
|
void JavaCommon::javaArgsWereBad(QWidget *parent, JavaCheckResult result)
|
2015-05-04 04:50:48 +05:30
|
|
|
{
|
2015-05-04 04:58:16 +05:30
|
|
|
auto htmlError = result.errorLog;
|
2015-05-04 04:50:48 +05:30
|
|
|
QString text;
|
|
|
|
htmlError.replace('\n', "<br />");
|
2017-01-07 11:22:09 +05:30
|
|
|
text += QObject::tr("The specified java binary didn't work with the arguments you provided:<br />");
|
2016-03-23 03:58:47 +05:30
|
|
|
text += QString("<font color=\"red\">%1</font>").arg(htmlError);
|
2017-01-07 11:22:09 +05:30
|
|
|
CustomMessageBox::selectable(parent, QObject::tr("Java test failure"), text, QMessageBox::Warning)->show();
|
2015-05-04 04:50:48 +05:30
|
|
|
}
|
|
|
|
|
2017-01-07 11:22:09 +05:30
|
|
|
void JavaCommon::javaBinaryWasBad(QWidget *parent, JavaCheckResult result)
|
2015-05-04 04:50:48 +05:30
|
|
|
{
|
|
|
|
QString text;
|
2017-01-07 11:22:09 +05:30
|
|
|
text += QObject::tr(
|
2015-05-04 04:50:48 +05:30
|
|
|
"The specified java binary didn't work.<br />You should use the auto-detect feature, "
|
|
|
|
"or set the path to the java executable.<br />");
|
2017-01-07 11:22:09 +05:30
|
|
|
CustomMessageBox::selectable(parent, QObject::tr("Java test failure"), text, QMessageBox::Warning)->show();
|
2015-05-04 04:50:48 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
void JavaCommon::TestCheck::run()
|
|
|
|
{
|
|
|
|
if (!JavaCommon::checkJVMArgs(m_args, m_parent))
|
|
|
|
{
|
|
|
|
emit finished();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
checker.reset(new JavaChecker());
|
|
|
|
connect(checker.get(), SIGNAL(checkFinished(JavaCheckResult)), this,
|
|
|
|
SLOT(checkFinished(JavaCheckResult)));
|
|
|
|
checker->m_path = m_path;
|
|
|
|
checker->performCheck();
|
|
|
|
}
|
|
|
|
|
|
|
|
void JavaCommon::TestCheck::checkFinished(JavaCheckResult result)
|
|
|
|
{
|
2017-01-07 11:22:09 +05:30
|
|
|
if (result.validity != JavaCheckResult::Validity::Valid)
|
2015-05-04 04:50:48 +05:30
|
|
|
{
|
2017-01-07 11:22:09 +05:30
|
|
|
javaBinaryWasBad(m_parent, result);
|
2015-05-04 04:50:48 +05:30
|
|
|
emit finished();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
checker.reset(new JavaChecker());
|
|
|
|
connect(checker.get(), SIGNAL(checkFinished(JavaCheckResult)), this,
|
|
|
|
SLOT(checkFinishedWithArgs(JavaCheckResult)));
|
|
|
|
checker->m_path = m_path;
|
|
|
|
checker->m_args = m_args;
|
|
|
|
checker->m_minMem = m_minMem;
|
|
|
|
checker->m_maxMem = m_maxMem;
|
2016-01-02 05:05:54 +05:30
|
|
|
if (result.javaVersion.requiresPermGen())
|
2015-05-04 04:50:48 +05:30
|
|
|
{
|
|
|
|
checker->m_permGen = m_permGen;
|
|
|
|
}
|
|
|
|
checker->performCheck();
|
|
|
|
}
|
|
|
|
|
|
|
|
void JavaCommon::TestCheck::checkFinishedWithArgs(JavaCheckResult result)
|
|
|
|
{
|
2017-01-07 11:22:09 +05:30
|
|
|
if (result.validity == JavaCheckResult::Validity::Valid)
|
2015-05-04 04:50:48 +05:30
|
|
|
{
|
2017-01-07 11:22:09 +05:30
|
|
|
javaWasOk(m_parent, result);
|
2015-05-04 04:50:48 +05:30
|
|
|
emit finished();
|
|
|
|
return;
|
|
|
|
}
|
2017-01-07 11:22:09 +05:30
|
|
|
javaArgsWereBad(m_parent, result);
|
2015-05-04 04:50:48 +05:30
|
|
|
emit finished();
|
|
|
|
}
|