mirror of
https://github.com/lubosz/overte.git
synced 2025-04-23 20:54:25 +02:00
Merge pull request #8806 from huffman/fix/atp-script-cache
Update ScriptCache to clear ATP assets when disconnected from a domain
This commit is contained in:
commit
90b283f83b
3 changed files with 18 additions and 0 deletions
|
@ -668,6 +668,10 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) :
|
|||
connect(&domainHandler, SIGNAL(disconnectedFromDomain()), SLOT(clearDomainOctreeDetails()));
|
||||
connect(&domainHandler, &DomainHandler::domainConnectionRefused, this, &Application::domainConnectionRefused);
|
||||
|
||||
// We could clear ATP assets only when changing domains, but it's possible that the domain you are connected
|
||||
// to has gone down and switched to a new content set, so when you reconnect the cached ATP assets will no longer be valid.
|
||||
connect(&domainHandler, &DomainHandler::disconnectedFromDomain, DependencyManager::get<ScriptCache>().data(), &ScriptCache::clearATPScriptsFromCache);
|
||||
|
||||
// update our location every 5 seconds in the metaverse server, assuming that we are authenticated with one
|
||||
const qint64 DATA_SERVER_LOCATION_CHANGE_UPDATE_MSECS = 5 * MSECS_PER_SECOND;
|
||||
|
||||
|
|
|
@ -36,6 +36,19 @@ void ScriptCache::clearCache() {
|
|||
_scriptCache.clear();
|
||||
}
|
||||
|
||||
void ScriptCache::clearATPScriptsFromCache() {
|
||||
Lock lock(_containerLock);
|
||||
qCDebug(scriptengine) << "Clearing ATP scripts from ScriptCache";
|
||||
for (auto it = _scriptCache.begin(); it != _scriptCache.end();) {
|
||||
if (it.key().scheme() == "atp") {
|
||||
qCDebug(scriptengine) << "Removing: " << it.key();
|
||||
it = _scriptCache.erase(it);
|
||||
} else {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QString ScriptCache::getScript(const QUrl& unnormalizedURL, ScriptUser* scriptUser, bool& isPending, bool reload) {
|
||||
QUrl url = ResourceManager::normalizeURL(unnormalizedURL);
|
||||
QString scriptContents;
|
||||
|
|
|
@ -39,6 +39,7 @@ class ScriptCache : public QObject, public Dependency {
|
|||
|
||||
public:
|
||||
void clearCache();
|
||||
Q_INVOKABLE void clearATPScriptsFromCache();
|
||||
void getScriptContents(const QString& scriptOrURL, contentAvailableCallback contentAvailable, bool forceDownload = false);
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue