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 <sys.h>
|
||||||
|
|
||||||
#include "FileSystem.h"
|
|
||||||
#include "JavaCommon.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/JavaSettingsWidget.h"
|
||||||
#include "ui/widgets/VersionSelectWidget.h"
|
#include "ui/widgets/VersionSelectWidget.h"
|
||||||
|
|
||||||
@ -57,8 +53,8 @@ bool JavaWizardPage::validatePage()
|
|||||||
{
|
{
|
||||||
auto settings = APPLICATION->settings();
|
auto settings = APPLICATION->settings();
|
||||||
auto result = m_java_widget->validate();
|
auto result = m_java_widget->validate();
|
||||||
settings->set("AutomaticJavaSwitch", m_java_widget->autodetectJava());
|
settings->set("AutomaticJavaSwitch", m_java_widget->autoDetectJava());
|
||||||
settings->set("AutomaticJavaDownload", m_java_widget->autodownloadJava());
|
settings->set("AutomaticJavaDownload", m_java_widget->autoDownloadJava());
|
||||||
switch (result) {
|
switch (result) {
|
||||||
default:
|
default:
|
||||||
case JavaSettingsWidget::ValidationStatus::Bad: {
|
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_javaBrowseBtn, &QPushButton::clicked, this, &JavaSettingsWidget::on_javaBrowseBtn_clicked);
|
||||||
connect(m_javaPathTextBox, &QLineEdit::textEdited, this, &JavaSettingsWidget::javaPathEdited);
|
connect(m_javaPathTextBox, &QLineEdit::textEdited, this, &JavaSettingsWidget::javaPathEdited);
|
||||||
connect(m_javaStatusBtn, &QToolButton::clicked, this, &JavaSettingsWidget::on_javaStatusBtn_clicked);
|
connect(m_javaStatusBtn, &QToolButton::clicked, this, &JavaSettingsWidget::on_javaStatusBtn_clicked);
|
||||||
connect(m_javaDownloadBtn, &QPushButton::clicked, this, &JavaSettingsWidget::on_javaDownloadBtn_clicked);
|
if (BuildConfig.JAVA_DOWNLOADER_ENABLED) {
|
||||||
|
connect(m_javaDownloadBtn, &QPushButton::clicked, this, &JavaSettingsWidget::on_javaDownloadBtn_clicked);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void JavaSettingsWidget::setupUi()
|
void JavaSettingsWidget::setupUi()
|
||||||
@ -176,18 +178,21 @@ void JavaSettingsWidget::initialize()
|
|||||||
m_permGenSpinBox->setValue(observedPermGenMemory);
|
m_permGenSpinBox->setValue(observedPermGenMemory);
|
||||||
updateThresholds();
|
updateThresholds();
|
||||||
|
|
||||||
auto button = CustomMessageBox::selectable(this, tr("Auto Java Download"),
|
if (BuildConfig.JAVA_DOWNLOADER_ENABLED) {
|
||||||
tr("%1 can automatically download the correct Java version for each version of Minecraft..\n"
|
auto button =
|
||||||
"Do you want to enable Java auto-download?\n")
|
CustomMessageBox::selectable(this, tr("Auto Java Download"),
|
||||||
.arg(BuildConfig.LAUNCHER_DISPLAYNAME),
|
tr("%1 can automatically download the correct Java version for each version of Minecraft..\n"
|
||||||
QMessageBox::Question, QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes)
|
"Do you want to enable Java auto-download?\n")
|
||||||
->exec();
|
.arg(BuildConfig.LAUNCHER_DISPLAYNAME),
|
||||||
if (button == QMessageBox::Yes) {
|
QMessageBox::Question, QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes)
|
||||||
m_autodetectJavaCheckBox->setChecked(true);
|
->exec();
|
||||||
m_autodownloadCheckBox->setChecked(true);
|
if (button == QMessageBox::Yes) {
|
||||||
} else {
|
m_autodetectJavaCheckBox->setChecked(true);
|
||||||
m_autodetectJavaCheckBox->setChecked(s->get("AutomaticJavaSwitch").toBool());
|
m_autodownloadCheckBox->setChecked(true);
|
||||||
m_autodownloadCheckBox->setChecked(s->get("AutomaticJavaSwitch").toBool() && s->get("AutomaticJavaDownload").toBool());
|
} else {
|
||||||
|
m_autodetectJavaCheckBox->setChecked(s->get("AutomaticJavaSwitch").toBool());
|
||||||
|
m_autodownloadCheckBox->setChecked(s->get("AutomaticJavaSwitch").toBool() && s->get("AutomaticJavaDownload").toBool());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,7 +216,7 @@ JavaSettingsWidget::ValidationStatus JavaSettingsWidget::validate()
|
|||||||
case JavaStatus::DoesNotStart:
|
case JavaStatus::DoesNotStart:
|
||||||
/* fallthrough */
|
/* fallthrough */
|
||||||
case JavaStatus::ReturnedInvalidData: {
|
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;
|
int button = QMessageBox::No;
|
||||||
if (m_result.mojangPlatform == "32" && maxHeapSize() > 2048) {
|
if (m_result.mojangPlatform == "32" && maxHeapSize() > 2048) {
|
||||||
button = CustomMessageBox::selectable(
|
button = CustomMessageBox::selectable(
|
||||||
@ -488,7 +493,9 @@ void JavaSettingsWidget::retranslate()
|
|||||||
m_minMemSpinBox->setToolTip(tr("The amount of memory Minecraft is started with."));
|
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_permGenSpinBox->setToolTip(tr("The amount of memory available to store loaded Java classes."));
|
||||||
m_javaBrowseBtn->setText(tr("Browse"));
|
m_javaBrowseBtn->setText(tr("Browse"));
|
||||||
m_autodownloadCheckBox->setText(tr("Auto-download Mojang Java"));
|
if (BuildConfig.JAVA_DOWNLOADER_ENABLED) {
|
||||||
|
m_autodownloadCheckBox->setText(tr("Auto-download Mojang Java"));
|
||||||
|
}
|
||||||
m_autodetectJavaCheckBox->setText(tr("Autodetect Java version"));
|
m_autodetectJavaCheckBox->setText(tr("Autodetect Java version"));
|
||||||
m_autoJavaGroupBox->setTitle(tr("Autodetect Java"));
|
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();
|
return m_autodetectJavaCheckBox->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool JavaSettingsWidget::autodetectJava() const
|
|
||||||
{
|
|
||||||
return m_autodownloadCheckBox->isChecked();
|
|
||||||
}
|
|
||||||
|
@ -42,8 +42,8 @@ class JavaSettingsWidget : public QWidget {
|
|||||||
int minHeapSize() const;
|
int minHeapSize() const;
|
||||||
int maxHeapSize() const;
|
int maxHeapSize() const;
|
||||||
QString javaPath() const;
|
QString javaPath() const;
|
||||||
bool autodetectJava() const;
|
bool autoDetectJava() const;
|
||||||
bool autodownloadJava() const;
|
bool autoDownloadJava() const;
|
||||||
|
|
||||||
void updateThresholds();
|
void updateThresholds();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user