From d0b58d8f8eba29c25a93e99ca7cebbfa96ed0934 Mon Sep 17 00:00:00 2001 From: howard-stearns Date: Mon, 22 Aug 2016 12:49:51 -0700 Subject: [PATCH] move thread safety into Application from caller --- interface/src/Application.cpp | 20 +++++++++++-------- .../scripting/WindowScriptingInterface.cpp | 8 ++------ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index d1b9b952d4..c743b84864 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -5171,19 +5171,23 @@ void Application::toggleLogDialog() { } void Application::takeSnapshot(bool notify, float aspectRatio) { - QMediaPlayer* player = new QMediaPlayer(); - QFileInfo inf = QFileInfo(PathUtils::resourcesPath() + "sounds/snap.wav"); - player->setMedia(QUrl::fromLocalFile(inf.absoluteFilePath())); - player->play(); + postLambdaEvent([notify, aspectRatio, this] { + QMediaPlayer* player = new QMediaPlayer(); + QFileInfo inf = QFileInfo(PathUtils::resourcesPath() + "sounds/snap.wav"); + player->setMedia(QUrl::fromLocalFile(inf.absoluteFilePath())); + player->play(); - QString path = Snapshot::saveSnapshot(getActiveDisplayPlugin()->getScreenshot(aspectRatio)); + QString path = Snapshot::saveSnapshot(getActiveDisplayPlugin()->getScreenshot(aspectRatio)); - emit DependencyManager::get()->snapshotTaken(path, notify); + emit DependencyManager::get()->snapshotTaken(path, notify); + }); } void Application::shareSnapshot(const QString& path) { - // not much to do here, everything is done in snapshot code... - Snapshot::uploadSnapshot(path); + postLambdaEvent([path] { + // not much to do here, everything is done in snapshot code... + Snapshot::uploadSnapshot(path); + }); } float Application::getRenderResolutionScale() const { diff --git a/interface/src/scripting/WindowScriptingInterface.cpp b/interface/src/scripting/WindowScriptingInterface.cpp index 5d5c39222e..4eb8c67250 100644 --- a/interface/src/scripting/WindowScriptingInterface.cpp +++ b/interface/src/scripting/WindowScriptingInterface.cpp @@ -205,13 +205,9 @@ void WindowScriptingInterface::copyToClipboard(const QString& text) { } void WindowScriptingInterface::takeSnapshot(bool notify, float aspectRatio) { - qApp->postLambdaEvent([notify, aspectRatio] { - qApp->takeSnapshot(notify, aspectRatio); - }); + qApp->takeSnapshot(notify, aspectRatio); } void WindowScriptingInterface::shareSnapshot(const QString& path) { - qApp->postLambdaEvent([path] { - qApp->shareSnapshot(path); - }); + qApp->shareSnapshot(path); }