diff options
Diffstat (limited to 'indra/newview/llappviewer.cpp')
-rw-r--r-- | indra/newview/llappviewer.cpp | 73 |
1 files changed, 45 insertions, 28 deletions
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 43c8c679c6..8e959993fe 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -3016,41 +3016,59 @@ void LLAppViewer::migrateCacheDirectory() #endif // LL_WINDOWS || LL_DARWIN } +//static +S32 LLAppViewer::getCacheVersion() +{ + static const S32 cache_version = 7; + + return cache_version ; +} + bool LLAppViewer::initCache() { mPurgeCache = false; - // Purge cache if user requested it - if (gSavedSettings.getBOOL("PurgeCacheOnStartup") || - gSavedSettings.getBOOL("PurgeCacheOnNextStartup")) + BOOL disable_texture_cache = FALSE ; + BOOL read_only = mSecondInstance ? TRUE : FALSE; + LLAppViewer::getTextureCache()->setReadOnly(read_only) ; + + if (gSavedSettings.getS32("LocalCacheVersion") != LLAppViewer::getCacheVersion()) { - gSavedSettings.setBOOL("PurgeCacheOnNextStartup", false); - mPurgeCache = true; + if(read_only) + { + disable_texture_cache = TRUE ; //if the cache version of this viewer is different from the running one, this viewer can not use the texture cache. + } + else + { + mPurgeCache = true; // Purge cache if the version number is different. + gSavedSettings.setS32("LocalCacheVersion", LLAppViewer::getCacheVersion()); + } } - // Purge cache if it belongs to an old version - else + + if(!read_only) { - static const S32 cache_version = 6; - if (gSavedSettings.getS32("LocalCacheVersion") != cache_version) + // Purge cache if user requested it + if (gSavedSettings.getBOOL("PurgeCacheOnStartup") || + gSavedSettings.getBOOL("PurgeCacheOnNextStartup")) { + gSavedSettings.setBOOL("PurgeCacheOnNextStartup", false); mPurgeCache = true; - gSavedSettings.setS32("LocalCacheVersion", cache_version); } - } - // We have moved the location of the cache directory over time. - migrateCacheDirectory(); - - // Setup and verify the cache location - std::string cache_location = gSavedSettings.getString("CacheLocation"); - std::string new_cache_location = gSavedSettings.getString("NewCacheLocation"); - if (new_cache_location != cache_location) - { - gDirUtilp->setCacheDir(gSavedSettings.getString("CacheLocation")); - purgeCache(); // purge old cache - gSavedSettings.setString("CacheLocation", new_cache_location); - gSavedSettings.setString("CacheLocationTopFolder", gDirUtilp->getBaseFileName(new_cache_location)); - } + // We have moved the location of the cache directory over time. + migrateCacheDirectory(); + // Setup and verify the cache location + std::string cache_location = gSavedSettings.getString("CacheLocation"); + std::string new_cache_location = gSavedSettings.getString("NewCacheLocation"); + if (new_cache_location != cache_location) + { + gDirUtilp->setCacheDir(gSavedSettings.getString("CacheLocation")); + purgeCache(); // purge old cache + gSavedSettings.setString("CacheLocation", new_cache_location); + gSavedSettings.setString("CacheLocationTopFolder", gDirUtilp->getBaseFileName(new_cache_location)); + } + } + if (!gDirUtilp->setCacheDir(gSavedSettings.getString("CacheLocation"))) { LL_WARNS("AppCache") << "Unable to set cache location" << LL_ENDL; @@ -3058,7 +3076,7 @@ bool LLAppViewer::initCache() gSavedSettings.setString("CacheLocationTopFolder", ""); } - if (mPurgeCache) + if (mPurgeCache && !read_only) { LLSplashScreen::update(LLTrans::getString("StartupClearingCache")); purgeCache(); @@ -3067,14 +3085,13 @@ bool LLAppViewer::initCache() LLSplashScreen::update(LLTrans::getString("StartupInitializingTextureCache")); // Init the texture cache - // Allocate 80% of the cache size for textures - BOOL read_only = mSecondInstance ? TRUE : FALSE; + // Allocate 80% of the cache size for textures const S32 MB = 1024*1024; S64 cache_size = (S64)(gSavedSettings.getU32("CacheSize")) * MB; const S64 MAX_CACHE_SIZE = 1024*MB; cache_size = llmin(cache_size, MAX_CACHE_SIZE); S64 texture_cache_size = ((cache_size * 8)/10); - S64 extra = LLAppViewer::getTextureCache()->initCache(LL_PATH_CACHE, texture_cache_size, read_only); + S64 extra = LLAppViewer::getTextureCache()->initCache(LL_PATH_CACHE, texture_cache_size, disable_texture_cache); texture_cache_size -= extra; LLSplashScreen::update(LLTrans::getString("StartupInitializingVFS")); |