Merge pull request #2897 from Trial97/fix_crash

fix crash when no resorce version is available
This commit is contained in:
Alexandru Ionut Tripon 2024-10-09 08:37:22 +03:00 committed by GitHub
commit c72cce6572
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -254,7 +254,10 @@ void ResourcePage::updateSelectionButton()
m_ui->resourceSelectionButton->setEnabled(true); m_ui->resourceSelectionButton->setEnabled(true);
if (auto current_pack = getCurrentPack(); current_pack) { if (auto current_pack = getCurrentPack(); current_pack) {
if (!current_pack->isVersionSelected(m_selected_version_index)) if (current_pack->versionsLoaded && current_pack->versions.empty()) {
m_ui->resourceSelectionButton->setEnabled(false);
qWarning() << tr("No version available for the selected pack");
} else if (!current_pack->isVersionSelected(m_selected_version_index))
m_ui->resourceSelectionButton->setText(tr("Select %1 for download").arg(resourceString())); m_ui->resourceSelectionButton->setText(tr("Select %1 for download").arg(resourceString()));
else else
m_ui->resourceSelectionButton->setText(tr("Deselect %1 for download").arg(resourceString())); m_ui->resourceSelectionButton->setText(tr("Deselect %1 for download").arg(resourceString()));