History

Don't use blocking connections on the main thread

Brad Davis committed 9 years ago

Commit b52dd7b1 parent b22daa945 files · +377 −178Browse files

Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 45 files). Show all

Unified · Split

libraries/script-engine/src/ScriptEngine.cpp+4−3
@@ -36,6 +36,7 @@ · 35 unmodified lines
36 36
37#include <QtScriptTools/QScriptEngineDebugger>37#include <QtScriptTools/QScriptEngineDebugger>
38 38
39#include <shared/QtHelpers.h>
39#include <AudioConstants.h>40#include <AudioConstants.h>
40#include <AudioEffectOptions.h>41#include <AudioEffectOptions.h>
41#include <AvatarData.h>42#include <AvatarData.h>
@@ -436,12 +437,12 @@ void ScriptEngine::loadURL(const QUrl& scriptURL, bool reload) { · 394 unmodified lines
436 _fileNameString = url.toString();437 _fileNameString = url.toString();
437 _isReloading = reload;438 _isReloading = reload;
438 439
439 // Check that script has a supported file extension440 // Check that script has a supported file extension
440 if (!hasValidScriptSuffix(_fileNameString)) {441 if (!hasValidScriptSuffix(_fileNameString)) {
441 scriptErrorMessage("File extension of file: " + _fileNameString + " is not a currently supported script type");442 scriptErrorMessage("File extension of file: " + _fileNameString + " is not a currently supported script type");
442 emit errorLoadingScript(_fileNameString);443 emit errorLoadingScript(_fileNameString);
443 return;444 return;
444 }445 }
445 446
446 const auto maxRetries = 0; // for consistency with previous scriptCache->getScript() behavior447 const auto maxRetries = 0; // for consistency with previous scriptCache->getScript() behavior
447 auto scriptCache = DependencyManager::get<ScriptCache>();448 auto scriptCache = DependencyManager::get<ScriptCache>();
@@ -964,7 +965,7 @@ QScriptValue ScriptEngine::evaluate(const QString& sourceCode, const QString& fi · 516 unmodified lines
964 qCDebug(scriptengine) << "*** WARNING *** ScriptEngine::evaluate() called on wrong thread [" << QThread::currentThread() << "], invoking on correct thread [" << thread() << "] "965 qCDebug(scriptengine) << "*** WARNING *** ScriptEngine::evaluate() called on wrong thread [" << QThread::currentThread() << "], invoking on correct thread [" << thread() << "] "
965 "sourceCode:" << sourceCode << " fileName:" << fileName << "lineNumber:" << lineNumber;966 "sourceCode:" << sourceCode << " fileName:" << fileName << "lineNumber:" << lineNumber;
966#endif967#endif
967 QMetaObject::invokeMethod(this, "evaluate", Qt::BlockingQueuedConnection,968 hifi::qt::blockingInvokeMethod(this, "evaluate",
968 Q_RETURN_ARG(QScriptValue, result),969 Q_RETURN_ARG(QScriptValue, result),
969 Q_ARG(const QString&, sourceCode),970 Q_ARG(const QString&, sourceCode),
970 Q_ARG(const QString&, fileName),971 Q_ARG(const QString&, fileName),