fix script memory issue

This commit is contained in:
Dante Ruiz 2018-07-24 16:31:12 -07:00
parent 49d9d61425
commit b750a005cf
4 changed files with 4 additions and 12 deletions

View file

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

View file

@ -6525,9 +6525,6 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEnginePointe
entityScriptingInterface->setPacketSender(&_entityEditSender); entityScriptingInterface->setPacketSender(&_entityEditSender);
entityScriptingInterface->setEntityTree(getEntities()->getTree()); 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()) { if (property(hifi::properties::TEST).isValid()) {
scriptEngine->registerGlobalObject("Test", TestScriptingInterface::getInstance()); scriptEngine->registerGlobalObject("Test", TestScriptingInterface::getInstance());
} }

View file

@ -59,7 +59,7 @@ void RecordingScriptingInterface::playClip(NetworkClipLoaderPointer clipLoader,
if (callback.isFunction()) { if (callback.isFunction()) {
QScriptValueList args { true, url }; 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(); auto weakClipLoader = clipLoader.toWeakRef();
// when clip loaded, call the callback with the URL and success boolean // 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 { [this, weakClipLoader, url, callback]() mutable {
if (auto clipLoader = weakClipLoader.toStrongRef()) { 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 // 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; qCDebug(scriptengine) << "Failed to load recording from" << url;
if (callback.isFunction()) { if (callback.isFunction()) {
QScriptValueList args { false, url }; QScriptValueList args { false, url };
callback.call(_scriptEngine->currentContext()->thisObject(), args); callback.call(QScriptValue(), args);
} }
if (auto clipLoader = weakClipLoader.toStrongRef()) { if (auto clipLoader = weakClipLoader.toStrongRef()) {

View file

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