Unload script when replaced with empty URL

This commit is contained in:
Atlante45 2017-04-24 15:56:37 -07:00
parent d292451f91
commit 24f4107c92

View file

@ -1027,11 +1027,11 @@ void EntityTreeRenderer::checkAndCallPreload(const EntityItemID& entityID, bool
}
bool shouldLoad = entity->shouldPreloadScript() && _entitiesScriptEngine;
QString scriptUrl = entity->getScript();
if (shouldLoad && (unloadFirst || scriptUrl.isEmpty())) {
if ((shouldLoad && unloadFirst) || scriptUrl.isEmpty()) {
_entitiesScriptEngine->unloadEntityScript(entityID);
entity->scriptHasUnloaded();
}
if (shouldLoad && !scriptUrl.isEmpty()) {
if (shouldLoad) {
scriptUrl = ResourceManager::normalizeURL(scriptUrl);
_entitiesScriptEngine->loadEntityScript(entityID, scriptUrl, reload);
entity->scriptHasPreloaded();