diff --git a/libosmscout-client-qt/include/osmscoutclientqt/TileCache.h b/libosmscout-client-qt/include/osmscoutclientqt/TileCache.h index 591eb2ab1..38fc0fa88 100644 --- a/libosmscout-client-qt/include/osmscoutclientqt/TileCache.h +++ b/libosmscout-client-qt/include/osmscoutclientqt/TileCache.h @@ -71,7 +71,8 @@ QDebug& operator<<(QDebug &out, const TileCacheKey &key); */ struct TileCacheVal { - std::chrono::steady_clock::time_point lastAccess; + using clock=std::chrono::steady_clock; + clock::time_point lastAccess; QImage image; size_t epoch; }; diff --git a/libosmscout-client-qt/src/osmscoutclientqt/TileCache.cpp b/libosmscout-client-qt/src/osmscoutclientqt/TileCache.cpp index e53e4170b..158191cc5 100644 --- a/libosmscout-client-qt/src/osmscoutclientqt/TileCache.cpp +++ b/libosmscout-client-qt/src/osmscoutclientqt/TileCache.cpp @@ -167,10 +167,10 @@ TileCacheVal TileCache::get(uint32_t zoomLevel, uint32_t x, uint32_t y) TileCacheKey key = {zoomLevel, x, y}; if (!tiles.contains(key)){ qWarning() << this << "No tile in cache for key " << key; - return {std::chrono::steady_clock::now(), QImage(), epoch}; // throw std::underflow_error ? + return {TileCacheVal::clock::now(), QImage(), epoch}; // throw std::underflow_error ? } TileCacheVal val = tiles.value(key); - val.lastAccess = std::chrono::steady_clock::now(); + val.lastAccess = TileCacheVal::clock::now(); tiles.insert(key, val); return val; } @@ -190,7 +190,7 @@ void TileCache::put(uint32_t zoomLevel, uint32_t x, uint32_t y, const QImage &im { removeRequest(zoomLevel, x, y); TileCacheKey key = {zoomLevel, x, y}; - TileCacheVal val = {std::chrono::steady_clock::now(), image, epoch}; + TileCacheVal val = {TileCacheVal::clock::now(), image, epoch}; #ifdef DEBUG_TILE_CACHE qDebug() << this << "inserting tile" << key; @@ -224,10 +224,10 @@ void TileCache::cleanupCache(uint32_t maxRemove, const std::chrono::milliseconds #endif uint32_t removed = 0; - std::chrono::steady_clock::duration oldest; + auto oldest=TileCacheVal::clock::duration::zero(); TileCacheKey key; TileCacheKey oldestKey; - auto now = std::chrono::steady_clock::now(); + auto now = TileCacheVal::clock::now(); QMutableHashIterator it(tiles); while (it.hasNext() && removed < maxRemove){ @@ -242,7 +242,7 @@ void TileCache::cleanupCache(uint32_t maxRemove, const std::chrono::milliseconds oldestKey = key; } - if (elapsed > duration_cast(maximumLifetime)){ + if (elapsed > duration_cast(maximumLifetime)){ #ifdef DEBUG_TILE_CACHE qDebug() << this << "removing" << key; #endif