aboutsummaryrefslogtreecommitdiff
path: root/launcher/ui/pages/modplatform/modrinth
diff options
context:
space:
mode:
authortimoreo <timo.oreo34@gmail.com>2022-02-19 15:17:45 +0100
committertimoreo <timo.oreo34@gmail.com>2022-02-19 15:17:45 +0100
commitadacab33494f307a93e41ac0eee4fdd226c39614 (patch)
tree1a19d70a6a66ea99973421dfdba3551004a07e88 /launcher/ui/pages/modplatform/modrinth
parent02384f81c72b8112b00531d2099ea1cce4531397 (diff)
downloadPrismLauncher-adacab33494f307a93e41ac0eee4fdd226c39614.tar.gz
PrismLauncher-adacab33494f307a93e41ac0eee4fdd226c39614.tar.bz2
PrismLauncher-adacab33494f307a93e41ac0eee4fdd226c39614.zip
Fixed segfault when closing window while version info download is still going
Diffstat (limited to 'launcher/ui/pages/modplatform/modrinth')
-rw-r--r--launcher/ui/pages/modplatform/modrinth/ModrinthPage.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/launcher/ui/pages/modplatform/modrinth/ModrinthPage.cpp b/launcher/ui/pages/modplatform/modrinth/ModrinthPage.cpp
index c5a54c29..577a7bcb 100644
--- a/launcher/ui/pages/modplatform/modrinth/ModrinthPage.cpp
+++ b/launcher/ui/pages/modplatform/modrinth/ModrinthPage.cpp
@@ -98,13 +98,12 @@ void ModrinthPage::onSelectionChanged(QModelIndex first, QModelIndex second)
{
qDebug() << "Loading Modrinth mod versions";
auto netJob = new NetJob(QString("Modrinth::ModVersions(%1)").arg(current.name), APPLICATION->network());
- std::shared_ptr<QByteArray> response = std::make_shared<QByteArray>();
+ auto response = new QByteArray();
QString addonId = current.addonId;
- netJob->addNetAction(Net::Download::makeByteArray(QString("https://api.modrinth.com/v2/project/%1/version").arg(addonId), response.get()));
+ netJob->addNetAction(Net::Download::makeByteArray(QString("https://api.modrinth.com/v2/project/%1/version").arg(addonId), response));
- QObject::connect(netJob, &NetJob::succeeded, this, [this, response, netJob]
+ QObject::connect(netJob, &NetJob::succeeded, this, [this, response]
{
- netJob->deleteLater();
QJsonParseError parse_error;
QJsonDocument doc = QJsonDocument::fromJson(*response, &parse_error);
if(parse_error.error != QJsonParseError::NoError) {
@@ -138,6 +137,10 @@ void ModrinthPage::onSelectionChanged(QModelIndex first, QModelIndex second)
suggestCurrent();
});
+ QObject::connect(netJob, &NetJob::finished, this, [response, netJob]{
+ netJob->deleteLater();
+ delete response;
+ });
netJob->start();
}
else