History

Additional thread safety

Brad Davis committed 9 years ago

Commit 8372d731 parent b52dd7b23 files · +413 −249Browse files

Showing the changes to interface/src/scripting/TestScriptingInterface.cpp (1 of 23 files). Show all

Unified · Split

interface/src/scripting/TestScriptingInterface.cpp+16−10
@@ -11,6 +11,7 @@ · 10 unmodified lines
1111 #include <QtCore/QLoggingCategory>
1212 #include <QtCore/QThread>
1313
14+#include <shared/QtHelpers.h>
1415 #include <DependencyManager.h>
1516 #include <Trace.h>
1617 #include <StatTracker.h>
@@ -57,20 +58,25 @@ void TestScriptingInterface::waitIdle() { · 40 unmodified lines
5758 }
5859
5960 bool TestScriptingInterface::loadTestScene(QString scene) {
61+ if (QThread::currentThread() != thread()) {
62+ bool result;
63+ hifi::qt::blockingInvokeMethod(this, "loadTestScene", Q_RETURN_ARG(bool, result), Q_ARG(QString, scene));
64+ return result;
65+ }
66+
6067 static const QString TEST_ROOT = "https://raw.githubusercontent.com/highfidelity/hifi_tests/master/";
6168 static const QString TEST_BINARY_ROOT = "https://hifi-public.s3.amazonaws.com/test_scene_data/";
6269 static const QString TEST_SCRIPTS_ROOT = TEST_ROOT + "scripts/";
6370 static const QString TEST_SCENES_ROOT = TEST_ROOT + "scenes/";
64− return DependencyManager::get<OffscreenUi>()->returnFromUiThread([scene]()->QVariant {
65− DependencyManager::get<ResourceManager>()->setUrlPrefixOverride("atp:/", TEST_BINARY_ROOT + scene + ".atp/");
66− auto tree = qApp->getEntities()->getTree();
67− auto treeIsClient = tree->getIsClient();
68− // Force the tree to accept the load regardless of permissions
69− tree->setIsClient(false);
70− auto result = tree->readFromURL(TEST_SCENES_ROOT + scene + ".json");
71− tree->setIsClient(treeIsClient);
72− return result;
73− }).toBool();
71+
72+ DependencyManager::get<ResourceManager>()->setUrlPrefixOverride("atp:/", TEST_BINARY_ROOT + scene + ".atp/");
73+ auto tree = qApp->getEntities()->getTree();
74+ auto treeIsClient = tree->getIsClient();
75+ // Force the tree to accept the load regardless of permissions
76+ tree->setIsClient(false);
77+ auto result = tree->readFromURL(TEST_SCENES_ROOT + scene + ".json");
78+ tree->setIsClient(treeIsClient);
79+ return result;
7480 }
7581
7682 bool TestScriptingInterface::startTracing(QString logrules) {