From 6407b70395ef5b2afaa650edf280e537e50e662d Mon Sep 17 00:00:00 2001 From: Tihran Katolikian Date: Fri, 18 Oct 2024 10:41:42 +0300 Subject: [PATCH] add 'cancelPending' flag and use it for proper download cancelation --- src/QtLocationPlugin/QGCCachedTileSet.cpp | 11 +++++++++++ src/QtLocationPlugin/QGCCachedTileSet.h | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/QtLocationPlugin/QGCCachedTileSet.cpp b/src/QtLocationPlugin/QGCCachedTileSet.cpp index c6eab704ac2..94fb84019bd 100644 --- a/src/QtLocationPlugin/QGCCachedTileSet.cpp +++ b/src/QtLocationPlugin/QGCCachedTileSet.cpp @@ -61,6 +61,11 @@ QString QGCCachedTileSet::downloadStatus() const void QGCCachedTileSet::createDownloadTask() { + if (_cancelPending) { + setDownloading(false); + return; + } + if (!_downloading) { setErrorCount(0); setDownloading(true); @@ -82,11 +87,17 @@ void QGCCachedTileSet::createDownloadTask() void QGCCachedTileSet::resumeDownloadTask() { + _cancelPending = false; QGCUpdateTileDownloadStateTask* const task = new QGCUpdateTileDownloadStateTask(_id, QGCTile::StatePending, "*"); getQGCMapEngine()->addTask(task); createDownloadTask(); } +void QGCCachedTileSet::cancelDownloadTask() +{ + _cancelPending = true; +} + void QGCCachedTileSet::_tileListFetched(const QQueue &tiles) { _batchRequested = false; diff --git a/src/QtLocationPlugin/QGCCachedTileSet.h b/src/QtLocationPlugin/QGCCachedTileSet.h index 73ce1cbccbb..7f1d5cb8838 100644 --- a/src/QtLocationPlugin/QGCCachedTileSet.h +++ b/src/QtLocationPlugin/QGCCachedTileSet.h @@ -74,7 +74,7 @@ class QGCCachedTileSet : public QObject Q_INVOKABLE void createDownloadTask(); Q_INVOKABLE void resumeDownloadTask(); - Q_INVOKABLE void cancelDownloadTask() { setDownloading(false); } + Q_INVOKABLE void cancelDownloadTask(); const QString &name() const { return _name; } const QString &mapTypeStr() const { return _mapTypeStr; } @@ -184,6 +184,7 @@ private slots: bool _noMoreTiles = false; bool _batchRequested = false; bool _selected = false; + bool _cancelPending = false; QDateTime _creationDate; QHash _replies;