Merge pull request #13687 from danteruiz/fix-script-memory-issue

Fix ScriptEngine begin held onto after script stopped runnning
This commit is contained in:
John Conklin II 2018-07-27 12:31:31 -07:00 committed by GitHub
commit 9770331259
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 4 additions and 12 deletions

View file

@ -344,8 +344,6 @@ void Agent::scriptRequestFinished() {
void Agent::executeScript() {
_scriptEngine = scriptEngineFactory(ScriptEngine::AGENT_SCRIPT, _scriptContents, _payload);
DependencyManager::get<RecordingScriptingInterface>()->setScriptEngine(_scriptEngine);
// setup an Avatar for the script to use
auto scriptedAvatar = DependencyManager::get<ScriptableAvatar>();

View file

@ -6533,9 +6533,6 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEnginePointe
entityScriptingInterface->setPacketSender(&_entityEditSender);
entityScriptingInterface->setEntityTree(getEntities()->getTree());
// give the script engine to the RecordingScriptingInterface for its callbacks
DependencyManager::get<RecordingScriptingInterface>()->setScriptEngine(scriptEngine);
if (property(hifi::properties::TEST).isValid()) {
scriptEngine->registerGlobalObject("Test", TestScriptingInterface::getInstance());
}

View file

@ -59,7 +59,7 @@ void RecordingScriptingInterface::playClip(NetworkClipLoaderPointer clipLoader,
if (callback.isFunction()) {
QScriptValueList args { true, url };
callback.call(_scriptEngine->globalObject(), args);
callback.call(QScriptValue(), args);
}
}
@ -78,7 +78,7 @@ void RecordingScriptingInterface::loadRecording(const QString& url, QScriptValue
auto weakClipLoader = clipLoader.toWeakRef();
// when clip loaded, call the callback with the URL and success boolean
connect(clipLoader.data(), &recording::NetworkClipLoader::clipLoaded, this,
connect(clipLoader.data(), &recording::NetworkClipLoader::clipLoaded, callback.engine(),
[this, weakClipLoader, url, callback]() mutable {
if (auto clipLoader = weakClipLoader.toStrongRef()) {
@ -92,12 +92,12 @@ void RecordingScriptingInterface::loadRecording(const QString& url, QScriptValue
});
// when clip load fails, call the callback with the URL and failure boolean
connect(clipLoader.data(), &recording::NetworkClipLoader::failed, this, [this, weakClipLoader, url, callback](QNetworkReply::NetworkError error) mutable {
connect(clipLoader.data(), &recording::NetworkClipLoader::failed, callback.engine(), [this, weakClipLoader, url, callback](QNetworkReply::NetworkError error) mutable {
qCDebug(scriptengine) << "Failed to load recording from" << url;
if (callback.isFunction()) {
QScriptValueList args { false, url };
callback.call(_scriptEngine->currentContext()->thisObject(), args);
callback.call(QScriptValue(), args);
}
if (auto clipLoader = weakClipLoader.toStrongRef()) {

View file

@ -36,8 +36,6 @@ class RecordingScriptingInterface : public QObject, public Dependency {
public:
RecordingScriptingInterface();
void setScriptEngine(QSharedPointer<BaseScriptEngine> scriptEngine) { _scriptEngine = scriptEngine; }
public slots:
/**jsdoc
@ -246,7 +244,6 @@ protected:
Flag _useSkeletonModel { false };
recording::ClipPointer _lastClip;
QSharedPointer<BaseScriptEngine> _scriptEngine;
QSet<recording::NetworkClipLoaderPointer> _clipLoaders;
private: