From b672b7e17758bfa0ca8f854d9b1aa4f6312b84bf Mon Sep 17 00:00:00 2001 From: David Rowe Date: Fri, 4 Nov 2016 10:49:16 +1300 Subject: [PATCH] Fix Clara download failing if move mouse after initiating download --- interface/resources/qml/Marketplaces.qml | 4 ++-- interface/resources/qml/hifi/Desktop.qml | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/interface/resources/qml/Marketplaces.qml b/interface/resources/qml/Marketplaces.qml index 573c00c237..9780de04f2 100644 --- a/interface/resources/qml/Marketplaces.qml +++ b/interface/resources/qml/Marketplaces.qml @@ -96,7 +96,7 @@ Rectangle { property string replaceFBXDownload: 'var element = $("a[data-extension=\'fbx\']:first"); element.unbind("click"); element.bind("click", function(event) { - console.log("Initiate Clara.io FBX file download"); + console.log("Initiate Clara.io FBX file download for {uuid}"); window.open("https://clara.io/api/scenes/{uuid}/export/fbx?fbxVersion=7.4&fbxEmbedTextures=true¢erScene=true&alignSceneGound=true"); return false; });' @@ -105,7 +105,7 @@ Rectangle { desktop.currentUrl = hoveredUrl; if (desktop.isClaraFBXZipDownload(desktop.currentUrl)) { - var doReplaceFBXDownload = replaceFBXDownload.replace("{uuid}", desktop.currentUrl.slice(desktop.currentUrl.lastIndexOf("/") + 1, -1)); + var doReplaceFBXDownload = replaceFBXDownload.replace(/{uuid}/g, desktop.currentUrl.slice(desktop.currentUrl.lastIndexOf("/") + 1, -1)); runJavaScript(doReplaceFBXDownload); } diff --git a/interface/resources/qml/hifi/Desktop.qml b/interface/resources/qml/hifi/Desktop.qml index e95b4cd757..e8a3c69d73 100644 --- a/interface/resources/qml/hifi/Desktop.qml +++ b/interface/resources/qml/hifi/Desktop.qml @@ -100,6 +100,7 @@ OriginalDesktop.Desktop { // Accept a download through the webview property bool webViewProfileSetup: false property string currentUrl: "" + property string downloadUrl: "" property string adaptedPath: "" property string tempDir: "" property bool autoAdd: false @@ -111,16 +112,17 @@ OriginalDesktop.Desktop { function initWebviewProfileHandlers(profile) { console.log("The webview url in desktop is: " + currentUrl); + downloadUrl = currentUrl; if (webViewProfileSetup) return; webViewProfileSetup = true; profile.downloadRequested.connect(function(download){ console.log("Download start: " + download.state); - adaptedPath = File.convertUrlToPath(currentUrl); + adaptedPath = File.convertUrlToPath(downloadUrl); tempDir = File.getTempDir(); console.log("Temp dir created: " + tempDir); download.path = tempDir + "/" + adaptedPath; - if (isClaraFBXZipDownload(currentUrl)) { + if (isClaraFBXZipDownload(downloadUrl)) { download.path += "fbx.zip"; } console.log("Path where object should download: " + download.path); @@ -133,7 +135,7 @@ OriginalDesktop.Desktop { profile.downloadFinished.connect(function(download){ if (download.state === WebEngineDownloadItem.DownloadCompleted) { - File.runUnzip(download.path, currentUrl, autoAdd); + File.runUnzip(download.path, downloadUrl, autoAdd); } else { console.log("The download was corrupted, state: " + download.state); }