1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-10-06 14:53:21 +02:00

Fixed crash on ENC map unload

This commit is contained in:
Martin Tůma 2022-11-09 21:37:05 +01:00
parent af688314fb
commit 9d8c23bc32
2 changed files with 12 additions and 6 deletions

View File

@ -30,6 +30,7 @@ void ENCMap::load()
void ENCMap::unload()
{
cancelJobs(true);
_data.clear();
}
@ -56,7 +57,7 @@ int ENCMap::zoomFit(const QSize &size, const RectC &rect)
int ENCMap::zoomIn()
{
cancelJobs();
cancelJobs(false);
_zoom = qMin(_zoom + 1, ZOOMS.max());
updateTransform();
@ -65,7 +66,7 @@ int ENCMap::zoomIn()
int ENCMap::zoomOut()
{
cancelJobs();
cancelJobs(false);
_zoom = qMax(_zoom - 1, ZOOMS.min());
updateTransform();
@ -141,10 +142,10 @@ void ENCMap::jobFinished(ENCMapJob *job)
emit tilesLoaded();
}
void ENCMap::cancelJobs()
void ENCMap::cancelJobs(bool wait)
{
for (int i = 0; i < _jobs.size(); i++)
_jobs.at(i)->cancel();
_jobs.at(i)->cancel(wait);
}
QString ENCMap::key(int zoom, const QPoint &xy) const

View File

@ -23,7 +23,12 @@ public:
_future = QtConcurrent::map(_tiles, &ENC::RasterTile::render);
_watcher.setFuture(_future);
}
void cancel() {_future.cancel();}
void cancel(bool wait)
{
_future.cancel();
if (wait)
_future.waitForFinished();
}
const QList<ENC::RasterTile> &tiles() const {return _tiles;}
signals:
@ -82,7 +87,7 @@ private:
bool isRunning(int zoom, const QPoint &xy) const;
void runJob(ENCMapJob *job);
void removeJob(ENCMapJob *job);
void cancelJobs();
void cancelJobs(bool wait);
QString key(int zoom, const QPoint &xy) const;
ENC::MapData _data;