From d0b58d8f8eba29c25a93e99ca7cebbfa96ed0934 Mon Sep 17 00:00:00 2001 From: howard-stearns Date: Mon, 22 Aug 2016 12:49:51 -0700 Subject: [PATCH 1/2] 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); } From 989974738ac6db0991f4d8253c4249604ae1b7e9 Mon Sep 17 00:00:00 2001 From: howard-stearns Date: Mon, 22 Aug 2016 12:50:51 -0700 Subject: [PATCH 2/2] dead code removal --- scripts/system/html/SnapshotReview.html | 5 ----- scripts/system/snapshot.js | 3 +-- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/scripts/system/html/SnapshotReview.html b/scripts/system/html/SnapshotReview.html index 973ae0642b..01a9f0bd84 100644 --- a/scripts/system/html/SnapshotReview.html +++ b/scripts/system/html/SnapshotReview.html @@ -162,11 +162,6 @@ // this means you may or may not be logged in, but can't share // because you are not in a public place. document.getElementById("sharing").innerHTML = "

Snapshots can be shared when they're taken in shareable places."; - } else if (!shareMsg.isLoggedIn) { - // this means you are in a public place, but can't share because - // you need to login. Soon we will just bring up the share dialog - // in this case (and maybe set a boolean here to inform the html) - document.getElementById("sharing").innerHTML = "

Snapshots can be shared when you're logged in."; } } window.onload = function () { diff --git a/scripts/system/snapshot.js b/scripts/system/snapshot.js index 5f3d363dfc..264b44f49a 100644 --- a/scripts/system/snapshot.js +++ b/scripts/system/snapshot.js @@ -55,7 +55,7 @@ function confirmShare(data) { Settings.setValue('openFeedAfterShare', true) break; default: - dialog.webEventReceived.disconnect(onMessage); // I'm not certain that this is necessary. If it is, what do we do on normal close? + dialog.webEventReceived.disconnect(onMessage); dialog.close(); isLoggedIn = Account.isLoggedIn(); message.forEach(function (submessage) { @@ -139,7 +139,6 @@ function resetButtons(path, notify) { { localPath: path }, { canShare: Boolean(location.placename), - isLoggedIn: true, // Just have the dialog act as though we are. To be removed at both ends later. openFeedAfterShare: shouldOpenFeedAfterShare() } ]);