diff --git a/launcher/ui/java/InstallJavaDialog.cpp b/launcher/ui/java/InstallJavaDialog.cpp index decbfb77d..4fb9fc2d2 100644 --- a/launcher/ui/java/InstallJavaDialog.cpp +++ b/launcher/ui/java/InstallJavaDialog.cpp @@ -259,14 +259,14 @@ InstallDialog::InstallDialog(const QString& uid, BaseInstance* instance, QWidget auto cast = pageCast(page); cast->setRecomend(true); - connect(cast, &InstallJavaPage::selectionChanged, this, [this] { validate(); }); + connect(cast, &InstallJavaPage::selectionChanged, this, [this, cast] { validate(cast); }); if (!recommendedJavas.isEmpty()) { cast->setRecommendedMajors(recommendedJavas); } } - connect(container, &PageContainer::selectedPageChanged, this, [this] { validate(); }); + connect(container, &PageContainer::selectedPageChanged, this, [this](BasePage* previous, BasePage* selected) { validate(selected); }); pageCast(container->selectedPage())->selectSearch(); - validate(); + validate(container->selectedPage()); } QList InstallDialog::getPages() @@ -286,10 +286,9 @@ QString InstallDialog::dialogTitle() return tr("Install Java"); } -void InstallDialog::validate() +void InstallDialog::validate(BasePage* selected) { - buttons->button(QDialogButtonBox::Ok) - ->setEnabled(!!std::dynamic_pointer_cast(pageCast(container->selectedPage())->selectedVersion())); + buttons->button(QDialogButtonBox::Ok)->setEnabled(!!std::dynamic_pointer_cast(pageCast(selected)->selectedVersion())); } void InstallDialog::done(int result) diff --git a/launcher/ui/java/InstallJavaDialog.h b/launcher/ui/java/InstallJavaDialog.h index d6f879207..7d0edbfdd 100644 --- a/launcher/ui/java/InstallJavaDialog.h +++ b/launcher/ui/java/InstallJavaDialog.h @@ -37,7 +37,7 @@ class InstallDialog final : public QDialog, private BasePageProvider { QList getPages() override; QString dialogTitle() override; - void validate(); + void validate(BasePage* selected); void done(int result) override; private: