diff --git a/interface/src/scripting/WindowScriptingInterface.cpp b/interface/src/scripting/WindowScriptingInterface.cpp index 7cfbfb174e..fbeddf41e0 100644 --- a/interface/src/scripting/WindowScriptingInterface.cpp +++ b/interface/src/scripting/WindowScriptingInterface.cpp @@ -253,6 +253,16 @@ int WindowScriptingInterface::createMessageBox(QString title, QString text, int void WindowScriptingInterface::updateMessageBox(int id, QString title, QString text, int buttons, int defaultButton) { auto messageBox = _messageBoxes.value(id); if (messageBox) { + if (QThread::currentThread() != thread()) { + QMetaObject::invokeMethod(this, "updateMessageBox", + Q_ARG(int, id), + Q_ARG(QString, title), + Q_ARG(QString, text), + Q_ARG(int, buttons), + Q_ARG(int, defaultButton)); + return; + } + messageBox->setProperty("title", title); messageBox->setProperty("text", text); messageBox->setProperty("buttons", buttons); @@ -263,6 +273,12 @@ void WindowScriptingInterface::updateMessageBox(int id, QString title, QString t void WindowScriptingInterface::closeMessageBox(int id) { auto messageBox = _messageBoxes.value(id); if (messageBox) { + if (QThread::currentThread() != thread()) { + QMetaObject::invokeMethod(this, "closeMessageBox", + Q_ARG(int, id)); + return; + } + disconnect(messageBox); messageBox->setVisible(false); messageBox->deleteLater(); diff --git a/scripts/system/html/js/marketplacesInject.js b/scripts/system/html/js/marketplacesInject.js index d5f0f4cb06..10970a7749 100644 --- a/scripts/system/html/js/marketplacesInject.js +++ b/scripts/system/html/js/marketplacesInject.js @@ -24,7 +24,7 @@ var canWriteAssets = false; var xmlHttpRequest = null; - var isDownloading = false; // Explicitly track download request status. + var isPreparing = false; // Explicitly track download request status. function injectCommonCode(isDirectoryPage) { @@ -139,7 +139,7 @@ function startAutoDownload() { // One file request at a time. - if (isDownloading) { + if (isPreparing) { console.log("WARNIKNG: Clara.io FBX: Prepare only one download at a time"); return; } @@ -178,7 +178,7 @@ var message = this.responseText.slice(responseTextIndex); var statusMessage = ""; - if (isDownloading) { // Ignore messages in flight after finished/cancelled. + if (isPreparing) { // Ignore messages in flight after finished/cancelled. var lines = message.split(/[\n\r]+/); for (var i = 0, length = lines.length; i < length; i++) { @@ -222,33 +222,30 @@ xmlHttpRequest.onload = function () { var statusMessage = ""; - if (!isDownloading) { + if (!isPreparing) { return; } + isPreparing = false; + var HTTP_OK = 200; if (this.status !== HTTP_OK) { statusMessage = "Zip file request terminated with " + this.status + " " + this.statusText; console.log("ERROR: Clara.io FBX: " + statusMessage); EventBridge.emitWebEvent(CLARA_IO_STATUS + " " + statusMessage); - return; - } - - if (zipFileURL.slice(-4) !== ".zip") { + } else if (zipFileURL.slice(-4) !== ".zip") { statusMessage = "Error creating zip file for download."; console.log("ERROR: Clara.io FBX: " + statusMessage + ": " + zipFileURL); EventBridge.emitWebEvent(CLARA_IO_STATUS + " " + statusMessage); - return; + } else { + EventBridge.emitWebEvent(CLARA_IO_DOWNLOAD + " " + zipFileURL); + console.log("Clara.io FBX: File download initiated for " + zipFileURL); } - EventBridge.emitWebEvent(CLARA_IO_DOWNLOAD + " " + zipFileURL); - console.log("Clara.io FBX: File download initiated for " + zipFileURL); - xmlHttpRequest = null; - isDownloading = false; } - isDownloading = true; + isPreparing = true; console.log("Clara.io FBX: Request zip file for " + uuid); EventBridge.emitWebEvent(CLARA_IO_STATUS + " Initiating download"); @@ -301,7 +298,7 @@ } function cancelClaraDownload() { - isDownloading = false; + isPreparing = false; if (xmlHttpRequest) { xmlHttpRequest.abort();