Skip to content

Commit

Permalink
add 'cancelPending' flag and use it for proper download cancelation
Browse files Browse the repository at this point in the history
  • Loading branch information
SleepingSoul authored and HTRamsey committed Oct 19, 2024
1 parent b858e18 commit 6407b70
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/QtLocationPlugin/QGCCachedTileSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ QString QGCCachedTileSet::downloadStatus() const

void QGCCachedTileSet::createDownloadTask()
{
if (_cancelPending) {
setDownloading(false);
return;
}

if (!_downloading) {
setErrorCount(0);
setDownloading(true);
Expand All @@ -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<QGCTile*> &tiles)
{
_batchRequested = false;
Expand Down
3 changes: 2 additions & 1 deletion src/QtLocationPlugin/QGCCachedTileSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down Expand Up @@ -184,6 +184,7 @@ private slots:
bool _noMoreTiles = false;
bool _batchRequested = false;
bool _selected = false;
bool _cancelPending = false;
QDateTime _creationDate;

QHash<QString, QNetworkReply*> _replies;
Expand Down

0 comments on commit 6407b70

Please sign in to comment.