From 12f135946144b764e960b6ce3765fb26e68e65f6 Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Fri, 24 Jun 2016 02:52:20 +0200 Subject: [PATCH] LP-32 simplify osgearth cache initialization --- ground/gcs/src/libs/osgearth/osgearth.cpp | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/ground/gcs/src/libs/osgearth/osgearth.cpp b/ground/gcs/src/libs/osgearth/osgearth.cpp index 1515227d9..fbb6c6fb0 100644 --- a/ground/gcs/src/libs/osgearth/osgearth.cpp +++ b/ground/gcs/src/libs/osgearth/osgearth.cpp @@ -128,27 +128,19 @@ void OsgEarth::initializePathes() void OsgEarth::initializeCache() { #ifdef USE_OSGEARTH + QString cachePath = Utils::GetStoragePath() + "osgearth/cache"; - osgEarth::Drivers::FileSystemCacheOptions cacheOptions; + qputenv("OSGEARTH_CACHE_PATH", cachePath.toLatin1()); - cacheOptions.rootPath() = cachePath.toStdString(); + const osgEarth::CachePolicy cachePolicy(osgEarth::CachePolicy::USAGE_READ_WRITE); - osg::ref_ptr cache = osgEarth::CacheFactory::create(cacheOptions); - if (cache->isOK()) { - // set cache - osgEarth::Registry::instance()->setCache(cache.get()); + // The default cache policy used when no policy is set elsewhere + osgEarth::Registry::instance()->setDefaultCachePolicy(cachePolicy); - // set cache policy - const osgEarth::CachePolicy cachePolicy(osgEarth::CachePolicy::USAGE_READ_WRITE); + // The override cache policy (overrides all others if set) + // osgEarth::Registry::instance()->setOverrideCachePolicy(cachePolicy); - // The default cache policy used when no policy is set elsewhere - osgEarth::Registry::instance()->setDefaultCachePolicy(cachePolicy); - // The override cache policy (overrides all others if set) - // osgEarth::Registry::instance()->setOverrideCachePolicy(cachePolicy); - } else { - qWarning() << "OsgEarth::initializeCache - Failed to initialize cache"; - } #endif // ifdef USE_OSGEARTH }