add extra protection against empty download link

Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
(cherry picked from commit 8daa1219a508ddb37070c01046c78b731a277887)
This commit is contained in:
Trial97 2024-10-25 01:05:58 +03:00 committed by github-actions[bot]
parent 42190819ae
commit 3d55236fdf

View File

@ -39,6 +39,7 @@
#include "ResourcePage.h"
#include "modplatform/ModIndex.h"
#include "ui/dialogs/CustomMessageBox.h"
#include "ui_ResourcePage.h"
#include <QDesktopServices>
@ -324,9 +325,9 @@ void ResourcePage::onSelectionChanged(QModelIndex curr, [[maybe_unused]] QModelI
updateUi();
}
void ResourcePage::onVersionSelectionChanged(int index)
void ResourcePage::onVersionSelectionChanged(int)
{
m_selected_version_index = index;
m_selected_version_index = m_ui->versionSelectionBox->currentData().toInt();
updateSelectionButton();
}
@ -358,10 +359,18 @@ void ResourcePage::onResourceSelected()
return;
auto current_pack = getCurrentPack();
if (!current_pack || !current_pack->versionsLoaded)
if (!current_pack || !current_pack->versionsLoaded || current_pack->versions.size() < m_selected_version_index)
return;
auto& version = current_pack->versions[m_selected_version_index];
if (version.downloadUrl.isNull()) {
CustomMessageBox::selectable(this, tr("How?"),
"You managed to select a resource that doesn't have a download link. Because of this missing "
"information prism will not try to download it.",
QMessageBox::Warning)
->show();
return;
}
if (version.is_currently_selected)
removeResourceFromDialog(current_pack->name);
else