2015-05-04 04:50:48 +05:30
|
|
|
#include "JavaCommon.h"
|
2021-11-22 08:25:16 +05:30
|
|
|
#include "ui/dialogs/CustomMessageBox.h"
|
2015-05-04 04:50:48 +05:30
|
|
|
#include <MMCStrings.h>
|
|
|
|
|
|
|
|
bool JavaCommon::checkJVMArgs(QString jvmargs, QWidget *parent)
|
|
|
|
{
|
2018-07-15 18:21:05 +05:30
|
|
|
if (jvmargs.contains("-XX:PermSize=") || jvmargs.contains(QRegExp("-Xm[sx]"))
|
|
|
|
|| jvmargs.contains("-XX-MaxHeapSize") || jvmargs.contains("-XX:InitialHeapSize"))
|
|
|
|
{
|
|
|
|
auto warnStr = QObject::tr(
|
2022-03-21 18:51:06 +05:30
|
|
|
"You tried to manually set a JVM memory option (using \"-XX:PermSize\", \"-XX-MaxHeapSize\", \"-XX:InitialHeapSize\", \"-Xmx\" or \"-Xms\").\n"
|
2018-07-15 18:21:05 +05:30
|
|
|
"There are dedicated boxes for these in the settings (Java tab, in the Memory group at the top).\n"
|
|
|
|
"This message will be displayed until you remove them from the JVM arguments.");
|
|
|
|
CustomMessageBox::selectable(
|
|
|
|
parent, QObject::tr("JVM arguments warning"),
|
|
|
|
warnStr,
|
|
|
|
QMessageBox::Warning)->exec();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
2015-05-04 04:50:48 +05:30
|
|
|
}
|
|
|
|
|
2017-01-07 11:22:09 +05:30
|
|
|
void JavaCommon::javaWasOk(QWidget *parent, JavaCheckResult result)
|
2015-05-04 04:50:48 +05:30
|
|
|
{
|
2018-07-15 18:21:05 +05:30
|
|
|
QString text;
|
|
|
|
text += QObject::tr("Java test succeeded!<br />Platform reported: %1<br />Java version "
|
2020-09-08 01:58:41 +05:30
|
|
|
"reported: %2<br />Java vendor "
|
|
|
|
"reported: %3<br />").arg(result.realPlatform, result.javaVersion.toString(), result.javaVendor);
|
2018-07-15 18:21:05 +05:30
|
|
|
if (result.errorLog.size())
|
|
|
|
{
|
|
|
|
auto htmlError = result.errorLog;
|
|
|
|
htmlError.replace('\n', "<br />");
|
|
|
|
text += QObject::tr("<br />Warnings:<br /><font color=\"orange\">%1</font>").arg(htmlError);
|
|
|
|
}
|
|
|
|
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
|
|
|
{
|
2018-07-15 18:21:05 +05:30
|
|
|
auto htmlError = result.errorLog;
|
|
|
|
QString text;
|
|
|
|
htmlError.replace('\n', "<br />");
|
2022-03-21 18:51:06 +05:30
|
|
|
text += QObject::tr("The specified Java binary didn't work with the arguments you provided:<br />");
|
2018-07-15 18:21:05 +05:30
|
|
|
text += QString("<font color=\"red\">%1</font>").arg(htmlError);
|
|
|
|
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
|
|
|
{
|
2018-07-15 18:21:05 +05:30
|
|
|
QString text;
|
|
|
|
text += QObject::tr(
|
2022-03-21 18:51:06 +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 />");
|
2018-07-15 18:21:05 +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()
|
|
|
|
{
|
2018-07-15 18:21:05 +05:30
|
|
|
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();
|
2015-05-04 04:50:48 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
void JavaCommon::TestCheck::checkFinished(JavaCheckResult result)
|
|
|
|
{
|
2018-07-15 18:21:05 +05:30
|
|
|
if (result.validity != JavaCheckResult::Validity::Valid)
|
|
|
|
{
|
|
|
|
javaBinaryWasBad(m_parent, result);
|
|
|
|
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;
|
|
|
|
if (result.javaVersion.requiresPermGen())
|
|
|
|
{
|
|
|
|
checker->m_permGen = m_permGen;
|
|
|
|
}
|
|
|
|
checker->performCheck();
|
2015-05-04 04:50:48 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
void JavaCommon::TestCheck::checkFinishedWithArgs(JavaCheckResult result)
|
|
|
|
{
|
2018-07-15 18:21:05 +05:30
|
|
|
if (result.validity == JavaCheckResult::Validity::Valid)
|
|
|
|
{
|
|
|
|
javaWasOk(m_parent, result);
|
|
|
|
emit finished();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
javaArgsWereBad(m_parent, result);
|
|
|
|
emit finished();
|
2015-05-04 04:50:48 +05:30
|
|
|
}
|
2017-04-30 18:42:46 +05:30
|
|
|
|