From ee3a8b1b6e54d2f87fbb1df007faea64e69dbda6 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Wed, 8 Jul 2015 18:23:16 -0700 Subject: [PATCH] Clear resource caches instead of restarting --- interface/src/Application.cpp | 6 +++++- libraries/model/src/model/Skybox.cpp | 2 +- libraries/networking/src/ResourceCache.cpp | 10 ++++++++++ libraries/networking/src/ResourceCache.h | 5 +++-- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 522d16981c..78707410ed 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2414,7 +2414,11 @@ void Application::cameraMenuChanged() { void Application::clearCacheAndRestart() { emptyLocalCache(); - exit(RESTART_CODE); + + DependencyManager::get()->refreshAll(); + DependencyManager::get()->refreshAll(); + DependencyManager::get()->refreshAll(); + DependencyManager::get()->refreshAll(); } void Application::rotationModeChanged() { diff --git a/libraries/model/src/model/Skybox.cpp b/libraries/model/src/model/Skybox.cpp index 10199adda3..f403f59e30 100755 --- a/libraries/model/src/model/Skybox.cpp +++ b/libraries/model/src/model/Skybox.cpp @@ -101,7 +101,7 @@ void Skybox::render(gpu::Batch& batch, const ViewFrustum& viewFrustum, const Sky batch.setModelTransform(Transform()); // only for Mac batch.setPipeline(thePipeline); batch.setInputBuffer(gpu::Stream::POSITION, theBuffer, 0, 8); - batch.setUniformBuffer(SKYBOX_CONSTANTS_SLOT, theConstants, 0, theConstants->getSize()); + //batch.setUniformBuffer(SKYBOX_CONSTANTS_SLOT, theConstants, 0, theConstants->getSize()); batch.setInputFormat(theFormat); batch.setUniformTexture(0, skybox.getCubemap()); batch.draw(gpu::TRIANGLE_STRIP, 4); diff --git a/libraries/networking/src/ResourceCache.cpp b/libraries/networking/src/ResourceCache.cpp index 0b6e39b151..cee0dbecf6 100644 --- a/libraries/networking/src/ResourceCache.cpp +++ b/libraries/networking/src/ResourceCache.cpp @@ -44,10 +44,20 @@ ResourceCache::~ResourceCache() { } } +void ResourceCache::refreshAll() { + for (auto it = _resources.begin(); it != _resources.end(); ++it) { + if (!it.value().isNull()) { + it.value().data()->refresh(); + } + } +} + void ResourceCache::refresh(const QUrl& url) { QSharedPointer resource = _resources.value(url); if (!resource.isNull()) { resource->refresh(); + } else { + _resources.remove(url); } } diff --git a/libraries/networking/src/ResourceCache.h b/libraries/networking/src/ResourceCache.h index ebe2c6e684..b4b9f089c5 100644 --- a/libraries/networking/src/ResourceCache.h +++ b/libraries/networking/src/ResourceCache.h @@ -78,7 +78,8 @@ public: ResourceCache(QObject* parent = NULL); virtual ~ResourceCache(); - + + void refreshAll(); void refresh(const QUrl& url); public slots: @@ -110,7 +111,7 @@ protected: private: friend class Resource; - QHash > _resources; + QHash> _resources; int _lastLRUKey = 0; static int _requestLimit;