Merge pull request #9683 from jherico/cache_flush

Clear caches on domain switch
This commit is contained in:
Andrew Meadows 2017-03-06 11:05:44 -08:00 committed by GitHub
commit 6ea6477c73
3 changed files with 12 additions and 5 deletions

View file

@ -5192,6 +5192,7 @@ void Application::updateWindowTitle() const {
#endif
_window->setWindowTitle(title);
}
void Application::clearDomainOctreeDetails() {
// if we're about to quit, we really don't need to do any of these things...
@ -5221,6 +5222,12 @@ void Application::clearDomainOctreeDetails() {
skyStage->setBackgroundMode(model::SunSkyStage::SKY_DEFAULT);
_recentlyClearedDomain = true;
DependencyManager::get<AvatarManager>()->clearOtherAvatars();
DependencyManager::get<AnimationCache>()->clearUnusedResources();
DependencyManager::get<ModelCache>()->clearUnusedResources();
DependencyManager::get<SoundCache>()->clearUnusedResources();
DependencyManager::get<TextureCache>()->clearUnusedResources();
}
void Application::domainChanged(const QString& domainHostname) {

View file

@ -221,7 +221,7 @@ ResourceCache::ResourceCache(QObject* parent) : QObject(parent) {
}
ResourceCache::~ResourceCache() {
clearUnusedResource();
clearUnusedResources();
}
void ResourceCache::clearATPAssets() {
@ -265,7 +265,7 @@ void ResourceCache::clearATPAssets() {
void ResourceCache::refreshAll() {
// Clear all unused resources so we don't have to reload them
clearUnusedResource();
clearUnusedResources();
resetResourceCounters();
QHash<QUrl, QWeakPointer<Resource>> resources;
@ -418,7 +418,7 @@ void ResourceCache::reserveUnusedResource(qint64 resourceSize) {
}
}
void ResourceCache::clearUnusedResource() {
void ResourceCache::clearUnusedResources() {
// the unused resources may themselves reference resources that will be added to the unused
// list on destruction, so keep clearing until there are no references left
QWriteLocker locker(&_unusedResourcesLock);

View file

@ -249,6 +249,7 @@ public:
void refreshAll();
void refresh(const QUrl& url);
void clearUnusedResources();
signals:
void dirty();
@ -298,7 +299,7 @@ protected:
void addUnusedResource(const QSharedPointer<Resource>& resource);
void removeUnusedResource(const QSharedPointer<Resource>& resource);
/// Attempt to load a resource if requests are below the limit, otherwise queue the resource for loading
/// \return true if the resource began loading, otherwise false if the resource is in the pending queue
static bool attemptRequest(QSharedPointer<Resource> resource);
@ -309,7 +310,6 @@ private:
friend class Resource;
void reserveUnusedResource(qint64 resourceSize);
void clearUnusedResource();
void resetResourceCounters();
void removeResource(const QUrl& url, qint64 size = 0);