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
11#include <QtCore/QLoggingCategory>11#include <QtCore/QLoggingCategory>
12#include <QtCore/QThread>12#include <QtCore/QThread>
13 13
14#include <shared/QtHelpers.h>
14#include <DependencyManager.h>15#include <DependencyManager.h>
15#include <Trace.h>16#include <Trace.h>
16#include <StatTracker.h>17#include <StatTracker.h>
@@ -57,20 +58,25 @@ void TestScriptingInterface::waitIdle() { · 40 unmodified lines
57}58}
58 59
59bool TestScriptingInterface::loadTestScene(QString scene) {60bool 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
60 static const QString TEST_ROOT = "https://raw.githubusercontent.com/highfidelity/hifi_tests/master/";67 static const QString TEST_ROOT = "https://raw.githubusercontent.com/highfidelity/hifi_tests/master/";
61 static const QString TEST_BINARY_ROOT = "https://hifi-public.s3.amazonaws.com/test_scene_data/";68 static const QString TEST_BINARY_ROOT = "https://hifi-public.s3.amazonaws.com/test_scene_data/";
62 static const QString TEST_SCRIPTS_ROOT = TEST_ROOT + "scripts/";69 static const QString TEST_SCRIPTS_ROOT = TEST_ROOT + "scripts/";
63 static const QString TEST_SCENES_ROOT = TEST_ROOT + "scenes/";70 static const QString TEST_SCENES_ROOT = TEST_ROOT + "scenes/";
64 return DependencyManager::get<OffscreenUi>()->returnFromUiThread([scene]()->QVariant {71
65 DependencyManager::get<ResourceManager>()->setUrlPrefixOverride("atp:/", TEST_BINARY_ROOT + scene + ".atp/");72 DependencyManager::get<ResourceManager>()->setUrlPrefixOverride("atp:/", TEST_BINARY_ROOT + scene + ".atp/");
66 auto tree = qApp->getEntities()->getTree();73 auto tree = qApp->getEntities()->getTree();
67 auto treeIsClient = tree->getIsClient();74 auto treeIsClient = tree->getIsClient();
68 // Force the tree to accept the load regardless of permissions75 // Force the tree to accept the load regardless of permissions
69 tree->setIsClient(false);76 tree->setIsClient(false);
70 auto result = tree->readFromURL(TEST_SCENES_ROOT + scene + ".json");77 auto result = tree->readFromURL(TEST_SCENES_ROOT + scene + ".json");
71 tree->setIsClient(treeIsClient);78 tree->setIsClient(treeIsClient);
72 return result;79 return result;
73 }).toBool();
74}80}
75 81
76bool TestScriptingInterface::startTracing(QString logrules) {82bool TestScriptingInterface::startTracing(QString logrules) {