diff --git a/libraries/script-engine/src/BatchLoader.cpp b/libraries/script-engine/src/BatchLoader.cpp index 964807894e..d191c89f09 100644 --- a/libraries/script-engine/src/BatchLoader.cpp +++ b/libraries/script-engine/src/BatchLoader.cpp @@ -55,7 +55,8 @@ void BatchLoader::start() { // Use a proxy callback to handle the call and emit the signal in a thread-safe way. // If BatchLoader is deleted before the callback is called, the subsequent "emit" call will not do // anything. - ScriptCacheSignalProxy* proxy = new ScriptCacheSignalProxy(scriptCache.data()); + ScriptCacheSignalProxy* proxy = new ScriptCacheSignalProxy(); + connect(scriptCache.data(), &ScriptCache::destroyed, proxy, &ScriptCacheSignalProxy::deleteLater); connect(proxy, &ScriptCacheSignalProxy::contentAvailable, this, [this](const QString& url, const QString& contents, bool isURL, bool success) { if (isURL && success) { diff --git a/libraries/script-engine/src/BatchLoader.h b/libraries/script-engine/src/BatchLoader.h index a03a8d80c6..046e17ff63 100644 --- a/libraries/script-engine/src/BatchLoader.h +++ b/libraries/script-engine/src/BatchLoader.h @@ -24,7 +24,6 @@ class ScriptCacheSignalProxy : public QObject { Q_OBJECT public: - ScriptCacheSignalProxy(QObject* parent) : QObject(parent) { } void receivedContent(const QString& url, const QString& contents, bool isURL, bool success); signals: diff --git a/libraries/script-engine/src/ScriptCache.cpp b/libraries/script-engine/src/ScriptCache.cpp index 96e3d7e914..025447a5b8 100644 --- a/libraries/script-engine/src/ScriptCache.cpp +++ b/libraries/script-engine/src/ScriptCache.cpp @@ -222,6 +222,9 @@ void ScriptCache::scriptContentAvailable() { }); } else { // Dubious, but retained here because it matches the behavior before fixing the threading + + allCallbacks = scriptRequest.scriptUsers; + scriptContent = _scriptCache[url]; finished = true; qCWarning(scriptengine) << "Error loading script from URL " << url;