From 1f95daf5c1b39f9d525b1d207df520e5d2c148c3 Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Fri, 2 Jun 2017 11:19:43 -0700 Subject: [PATCH] Add dev menu option to wipe KTX cache on next launch --- interface/src/Menu.cpp | 6 ++++++ interface/src/Menu.h | 1 + .../model-networking/src/model-networking/KTXCache.cpp | 4 ++-- libraries/model-networking/src/model-networking/KTXCache.h | 1 + 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 4138798484..463069430d 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -407,6 +407,12 @@ Menu::Menu() { #endif + { + auto action = addActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::RenderClearKtxCache); + connect(action, &QAction::triggered, []{ + Setting::Handle(KTXCache::SETTING_VERSION_NAME, KTXCache::INVALID_VERSION).set(KTXCache::INVALID_VERSION); + }); + } // Developer > Render > LOD Tools addActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::LodTools, 0, diff --git a/interface/src/Menu.h b/interface/src/Menu.h index b6d72f5446..41bf89a20a 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -145,6 +145,7 @@ namespace MenuOption { const QString Quit = "Quit"; const QString ReloadAllScripts = "Reload All Scripts"; const QString ReloadContent = "Reload Content (Clears all caches)"; + const QString RenderClearKtxCache = "Clear KTX Cache (requires restart)"; const QString RenderMaxTextureMemory = "Maximum Texture Memory"; const QString RenderMaxTextureAutomatic = "Automatic Texture Memory"; const QString RenderMaxTexture4MB = "4 MB"; diff --git a/libraries/model-networking/src/model-networking/KTXCache.cpp b/libraries/model-networking/src/model-networking/KTXCache.cpp index e6d6632571..6443748920 100644 --- a/libraries/model-networking/src/model-networking/KTXCache.cpp +++ b/libraries/model-networking/src/model-networking/KTXCache.cpp @@ -21,13 +21,13 @@ using FilePointer = cache::FilePointer; // this value should be incremented. This will force the KTX cache to be wiped const int KTXCache::CURRENT_VERSION = 0x01; const int KTXCache::INVALID_VERSION = 0x00; - +const char* KTXCache::SETTING_VERSION_NAME = "hifi.ktx.cache_version"; KTXCache::KTXCache(const std::string& dir, const std::string& ext) : FileCache(dir, ext) { initialize(); - Setting::Handle cacheVersionHandle("hifi.ktx.cache_version", KTXCache::INVALID_VERSION); + Setting::Handle cacheVersionHandle(SETTING_VERSION_NAME, INVALID_VERSION); auto cacheVersion = cacheVersionHandle.get(); if (cacheVersion != CURRENT_VERSION) { wipe(); diff --git a/libraries/model-networking/src/model-networking/KTXCache.h b/libraries/model-networking/src/model-networking/KTXCache.h index 2a3f191b53..5617019c52 100644 --- a/libraries/model-networking/src/model-networking/KTXCache.h +++ b/libraries/model-networking/src/model-networking/KTXCache.h @@ -31,6 +31,7 @@ public: // this value should be incremented. This will force the KTX cache to be wiped static const int CURRENT_VERSION; static const int INVALID_VERSION; + static const char* SETTING_VERSION_NAME; KTXCache(const std::string& dir, const std::string& ext);