From 267094dc6c7e369c377dc201d923923b9162d3a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Wed, 1 Mar 2023 00:23:01 +0100 Subject: [PATCH] Fixed build with older Qt versions --- src/GUI/app.cpp | 1 + src/data/dem.cpp | 9 ++++++--- src/data/dem.h | 1 + 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/GUI/app.cpp b/src/GUI/app.cpp index e18ce0cd..d08caef2 100644 --- a/src/GUI/app.cpp +++ b/src/GUI/app.cpp @@ -56,6 +56,7 @@ App::App(int &argc, char **argv) : QApplication(argc, argv) "QThreadStorage: Thread X exited after QThreadStorage Y destroyed" */ Downloader::setNetworkManager(new QNetworkAccessManager(this)); DEM::setDir(ProgramPaths::demDir()); + DEM::setCacheSize(536870912/*512MB*/); QSurfaceFormat fmt; fmt.setStencilBufferSize(8); fmt.setSamples(4); diff --git a/src/data/dem.cpp b/src/data/dem.cpp index 7e31fb8c..1011f216 100644 --- a/src/data/dem.cpp +++ b/src/data/dem.cpp @@ -21,8 +21,6 @@ #include "common/rectc.h" #include "dem.h" -#define CACHE_SIZE 536870912 /* 512MB */ - #define SRTM3_SAMPLES 1201 #define SRTM1_SAMPLES 3601 #define SRTM05_SAMPLES 7201 @@ -89,13 +87,18 @@ QString DEM::Tile::baseName() const } QString DEM::_dir; -DEM::TileCache DEM::_data = DEM::TileCache(CACHE_SIZE); +DEM::TileCache DEM::_data; QString DEM::fileName(const QString &baseName) { return QDir(_dir).absoluteFilePath(baseName); } +void DEM::setCacheSize(int size) +{ + _data.setMaxCost(size); +} + void DEM::setDir(const QString &path) { _dir = path; diff --git a/src/data/dem.h b/src/data/dem.h index 1d62d168..727fe6ee 100644 --- a/src/data/dem.h +++ b/src/data/dem.h @@ -34,6 +34,7 @@ public: int _lon, _lat; }; + static void setCacheSize(int size); static void setDir(const QString &path); static void clearCache(); static qreal elevation(const Coordinates &c);