Implement abort (possible broken?) and therefore make it work without crashing!
The shared pointer was going out of scope 🤦.
Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
parent
a2716f5cf6
commit
f583e617ec
@ -47,10 +47,16 @@ void ModrinthPackExportTask::executeTask()
|
|||||||
collectFiles();
|
collectFiles();
|
||||||
|
|
||||||
QByteArray* response = new QByteArray;
|
QByteArray* response = new QByteArray;
|
||||||
Task::Ptr versionsTask = api.currentVersions(fileHashes.values(), "sha512", response);
|
task = api.currentVersions(fileHashes.values(), "sha512", response);
|
||||||
connect(versionsTask.get(), &NetJob::succeeded, [this, response]() { parseApiResponse(response); });
|
connect(task.get(), &NetJob::succeeded, [this, response]() { parseApiResponse(response); });
|
||||||
connect(versionsTask.get(), &NetJob::failed, this, &ModrinthPackExportTask::emitFailed);
|
connect(task.get(), &NetJob::failed, this, &ModrinthPackExportTask::emitFailed);
|
||||||
versionsTask->start();
|
task->start();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ModrinthPackExportTask::abort() {
|
||||||
|
if (!task.isNull())
|
||||||
|
return task->abort();
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModrinthPackExportTask::collectFiles()
|
void ModrinthPackExportTask::collectFiles()
|
||||||
|
@ -34,6 +34,7 @@ class ModrinthPackExportTask : public Task {
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void executeTask() override;
|
void executeTask() override;
|
||||||
|
bool abort() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const QStringList PREFIXES;
|
static const QStringList PREFIXES;
|
||||||
@ -47,6 +48,7 @@ class ModrinthPackExportTask : public Task {
|
|||||||
ModrinthAPI api;
|
ModrinthAPI api;
|
||||||
QFileInfoList files;
|
QFileInfoList files;
|
||||||
QMap<QString, QString> fileHashes;
|
QMap<QString, QString> fileHashes;
|
||||||
|
Task::Ptr task;
|
||||||
|
|
||||||
struct ResolvedFile {
|
struct ResolvedFile {
|
||||||
QString sha1, sha512, url;
|
QString sha1, sha512, url;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user