Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F112302
D177.1732290943.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D177.1732290943.diff
View Options
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
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 22, 7:55 AM (6 h, 21 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
38906
Default Alt Text
D177.1732290943.diff (1 KB)
Attached To
Mode
D177: Fix the problem that kazv cannot be closed when cached files
Attached
Detach File
Event Timeline
Log In to Comment