Cleanly free NetJob in flame modpack
This commit is contained in:
parent
2745325ae0
commit
ccc493cb2b
@ -109,10 +109,10 @@ void FlamePage::onSelectionChanged(QModelIndex first, QModelIndex second)
|
|||||||
if (current.versionsLoaded == false)
|
if (current.versionsLoaded == false)
|
||||||
{
|
{
|
||||||
qDebug() << "Loading flame modpack versions";
|
qDebug() << "Loading flame modpack versions";
|
||||||
NetJob *netJob = new NetJob(QString("Flame::PackVersions(%1)").arg(current.name), APPLICATION->network());
|
auto netJob = new NetJob(QString("Flame::PackVersions(%1)").arg(current.name), APPLICATION->network());
|
||||||
std::shared_ptr<QByteArray> response = std::make_shared<QByteArray>();
|
auto response = new QByteArray();
|
||||||
int addonId = current.addonId;
|
int addonId = current.addonId;
|
||||||
netJob->addNetAction(Net::Download::makeByteArray(QString("https://addons-ecs.forgesvc.net/api/v2/addon/%1/files").arg(addonId), response.get()));
|
netJob->addNetAction(Net::Download::makeByteArray(QString("https://addons-ecs.forgesvc.net/api/v2/addon/%1/files").arg(addonId), response));
|
||||||
|
|
||||||
QObject::connect(netJob, &NetJob::succeeded, this, [this, response, addonId]
|
QObject::connect(netJob, &NetJob::succeeded, this, [this, response, addonId]
|
||||||
{
|
{
|
||||||
@ -143,6 +143,11 @@ void FlamePage::onSelectionChanged(QModelIndex first, QModelIndex second)
|
|||||||
|
|
||||||
suggestCurrent();
|
suggestCurrent();
|
||||||
});
|
});
|
||||||
|
QObject::connect(netJob, &NetJob::finished, this, [response, netJob]
|
||||||
|
{
|
||||||
|
netJob->deleteLater();
|
||||||
|
delete response;
|
||||||
|
});
|
||||||
netJob->start();
|
netJob->start();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user