Page MenuHomePhorge

D177.1732290943.diff
No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None

D177.1732290943.diff

diff --git a/src/kazv-io-manager.cpp b/src/kazv-io-manager.cpp
--- a/src/kazv-io-manager.cpp
+++ b/src/kazv-io-manager.cpp
@@ -46,7 +46,7 @@
*/
QDir cacheDir{tmpDir.path()};
Kazv::RandomInterface randomGenerator = QtRandAdapter{};
- QMap<QString, QSharedPointer<KazvIODownloadJob>> cacheJobs;
+ QMap<QString, QPointer<KazvIODownloadJob>> cacheJobs;
QMap<QString, QSharedPointer<KazvIODownloadJob>> downloadJobs;
QMap<QString, QSharedPointer<UploadJobModel>> uploadJobs;
};
@@ -80,8 +80,9 @@
QDir dir(m_d->cacheDir.path());
if (!dir.exists(id) && this->getCacheJob(id) == nullptr) {
auto job = this->makeDownloadJob(fileUrl, QUrl::fromLocalFile(filePath), hash, key, iv);
- m_d->cacheJobs[id].reset(job);
+ m_d->cacheJobs[id] = job;
connect(job, &KazvIOBaseJob::result, this, [this, id](auto /* result */) {
+ m_d->cacheJobs[id]->deleteLater();
m_d->cacheJobs.remove(id);
});
}
@@ -184,6 +185,13 @@
void KazvIOManager::clearJobs()
{
+ /**
+ * KazvIOBaseJob::cancel() for cache jobs will remove itself from cacheJobs,
+ * so iterators and loops for m_d->cacheJobs cannot be used reliably.
+ */
+ for (auto key : m_d->cacheJobs.keys()) {
+ m_d->cacheJobs[key]->cancel();
+ }
std::for_each(m_d->downloadJobs.begin(), m_d->downloadJobs.end(), [this](auto job){
job->cancel();
});

File Metadata

Mime Type
text/plain
Expires
Fri, Nov 22, 7:55 AM (5 h, 7 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
38906
Default Alt Text
D177.1732290943.diff (1 KB)

Event Timeline