History

Add missing threading checks to Recording API methods

David Rowe committed 7 years ago

Commit 185d6991 parent e708cb91 file · +20 −0Browse files

Showing the changes to libraries/script-engine/src/RecordingScriptingInterface.cpp (1 of 1 file). Show all

Unified · Split

libraries/script-engine/src/RecordingScriptingInterface.cpp+20−0
@@ -64,6 +64,11 @@ void RecordingScriptingInterface::playClip(NetworkClipLoaderPointer clipLoader, · 63 unmodified lines
6464 }
6565
6666 void RecordingScriptingInterface::loadRecording(const QString& url, QScriptValue callback) {
67+ if (QThread::currentThread() != thread()) {
68+ BLOCKING_INVOKE_METHOD(this, "loadRecording", Q_ARG(const QString&, url), Q_ARG(QScriptValue, callback));
69+ return;
70+ }
71+
6772 auto clipLoader = DependencyManager::get<recording::ClipCache>()->getClipLoader(url);
6873
6974 if (clipLoader->isLoaded()) {
@@ -117,6 +122,11 @@ void RecordingScriptingInterface::startPlaying() { · 47 unmodified lines
117122 }
118123
119124 void RecordingScriptingInterface::setPlayerVolume(float volume) {
125+ if (QThread::currentThread() != thread()) {
126+ BLOCKING_INVOKE_METHOD(this, "setPlayerVolume", Q_ARG(float, volume));
127+ return;
128+ }
129+
120130 _player->setVolume(std::min(std::max(volume, 0.0f), 1.0f));
121131 }
122132
@@ -137,6 +147,11 @@ void RecordingScriptingInterface::setPlayFromCurrentLocation(bool playFromCurren · 14 unmodified lines
137147 }
138148
139149 void RecordingScriptingInterface::setPlayerLoop(bool loop) {
150+ if (QThread::currentThread() != thread()) {
151+ BLOCKING_INVOKE_METHOD(this, "setPlayerLoop", Q_ARG(bool, loop));
152+ return;
153+ }
154+
140155 _player->loop(loop);
141156 }
142157
@@ -200,6 +215,11 @@ void RecordingScriptingInterface::stopRecording() { · 57 unmodified lines
200215 return;
201216 }
202217
218+ if (QThread::currentThread() != thread()) {
219+ BLOCKING_INVOKE_METHOD(this, "stopRecording");
220+ return;
221+ }
222+
203223 _recorder->stop();
204224 _lastClip = _recorder->getClip();
205225 _lastClip->seek(0);