mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2025-06-13 05:37:42 +02:00
fix crash on first display with java downloader off
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
@ -12,12 +12,8 @@
|
||||
|
||||
#include <sys.h>
|
||||
|
||||
#include "FileSystem.h"
|
||||
#include "JavaCommon.h"
|
||||
#include "java/JavaInstall.h"
|
||||
#include "java/JavaUtils.h"
|
||||
|
||||
#include "ui/dialogs/CustomMessageBox.h"
|
||||
#include "ui/widgets/JavaSettingsWidget.h"
|
||||
#include "ui/widgets/VersionSelectWidget.h"
|
||||
|
||||
@ -57,8 +53,8 @@ bool JavaWizardPage::validatePage()
|
||||
{
|
||||
auto settings = APPLICATION->settings();
|
||||
auto result = m_java_widget->validate();
|
||||
settings->set("AutomaticJavaSwitch", m_java_widget->autodetectJava());
|
||||
settings->set("AutomaticJavaDownload", m_java_widget->autodownloadJava());
|
||||
settings->set("AutomaticJavaSwitch", m_java_widget->autoDetectJava());
|
||||
settings->set("AutomaticJavaDownload", m_java_widget->autoDownloadJava());
|
||||
switch (result) {
|
||||
default:
|
||||
case JavaSettingsWidget::ValidationStatus::Bad: {
|
||||
|
@ -43,7 +43,9 @@ JavaSettingsWidget::JavaSettingsWidget(QWidget* parent) : QWidget(parent)
|
||||
connect(m_javaBrowseBtn, &QPushButton::clicked, this, &JavaSettingsWidget::on_javaBrowseBtn_clicked);
|
||||
connect(m_javaPathTextBox, &QLineEdit::textEdited, this, &JavaSettingsWidget::javaPathEdited);
|
||||
connect(m_javaStatusBtn, &QToolButton::clicked, this, &JavaSettingsWidget::on_javaStatusBtn_clicked);
|
||||
if (BuildConfig.JAVA_DOWNLOADER_ENABLED) {
|
||||
connect(m_javaDownloadBtn, &QPushButton::clicked, this, &JavaSettingsWidget::on_javaDownloadBtn_clicked);
|
||||
}
|
||||
}
|
||||
|
||||
void JavaSettingsWidget::setupUi()
|
||||
@ -176,7 +178,9 @@ void JavaSettingsWidget::initialize()
|
||||
m_permGenSpinBox->setValue(observedPermGenMemory);
|
||||
updateThresholds();
|
||||
|
||||
auto button = CustomMessageBox::selectable(this, tr("Auto Java Download"),
|
||||
if (BuildConfig.JAVA_DOWNLOADER_ENABLED) {
|
||||
auto button =
|
||||
CustomMessageBox::selectable(this, tr("Auto Java Download"),
|
||||
tr("%1 can automatically download the correct Java version for each version of Minecraft..\n"
|
||||
"Do you want to enable Java auto-download?\n")
|
||||
.arg(BuildConfig.LAUNCHER_DISPLAYNAME),
|
||||
@ -189,6 +193,7 @@ void JavaSettingsWidget::initialize()
|
||||
m_autodetectJavaCheckBox->setChecked(s->get("AutomaticJavaSwitch").toBool());
|
||||
m_autodownloadCheckBox->setChecked(s->get("AutomaticJavaSwitch").toBool() && s->get("AutomaticJavaDownload").toBool());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void JavaSettingsWidget::refresh()
|
||||
@ -211,7 +216,7 @@ JavaSettingsWidget::ValidationStatus JavaSettingsWidget::validate()
|
||||
case JavaStatus::DoesNotStart:
|
||||
/* fallthrough */
|
||||
case JavaStatus::ReturnedInvalidData: {
|
||||
if (!m_autodownloadCheckBox->isChecked()) { // the java will not be autodownloaded
|
||||
if (!(BuildConfig.JAVA_DOWNLOADER_ENABLED && m_autodownloadCheckBox->isChecked())) { // the java will not be autodownloaded
|
||||
int button = QMessageBox::No;
|
||||
if (m_result.mojangPlatform == "32" && maxHeapSize() > 2048) {
|
||||
button = CustomMessageBox::selectable(
|
||||
@ -488,7 +493,9 @@ void JavaSettingsWidget::retranslate()
|
||||
m_minMemSpinBox->setToolTip(tr("The amount of memory Minecraft is started with."));
|
||||
m_permGenSpinBox->setToolTip(tr("The amount of memory available to store loaded Java classes."));
|
||||
m_javaBrowseBtn->setText(tr("Browse"));
|
||||
if (BuildConfig.JAVA_DOWNLOADER_ENABLED) {
|
||||
m_autodownloadCheckBox->setText(tr("Auto-download Mojang Java"));
|
||||
}
|
||||
m_autodetectJavaCheckBox->setText(tr("Autodetect Java version"));
|
||||
m_autoJavaGroupBox->setTitle(tr("Autodetect Java"));
|
||||
}
|
||||
@ -522,12 +529,12 @@ void JavaSettingsWidget::updateThresholds()
|
||||
}
|
||||
}
|
||||
|
||||
bool JavaSettingsWidget::autodownloadJava() const
|
||||
bool JavaSettingsWidget::autoDownloadJava() const
|
||||
{
|
||||
return m_autodownloadCheckBox && m_autodownloadCheckBox->isChecked();
|
||||
}
|
||||
|
||||
bool JavaSettingsWidget::autoDetectJava() const
|
||||
{
|
||||
return m_autodetectJavaCheckBox->isChecked();
|
||||
}
|
||||
|
||||
bool JavaSettingsWidget::autodetectJava() const
|
||||
{
|
||||
return m_autodownloadCheckBox->isChecked();
|
||||
}
|
||||
|
@ -42,8 +42,8 @@ class JavaSettingsWidget : public QWidget {
|
||||
int minHeapSize() const;
|
||||
int maxHeapSize() const;
|
||||
QString javaPath() const;
|
||||
bool autodetectJava() const;
|
||||
bool autodownloadJava() const;
|
||||
bool autoDetectJava() const;
|
||||
bool autoDownloadJava() const;
|
||||
|
||||
void updateThresholds();
|
||||
|
||||
|
Reference in New Issue
Block a user