From 708da45ccc6f4f0d320b07d7f121b587b044bd38 Mon Sep 17 00:00:00 2001 From: amer cerkic Date: Wed, 30 Jan 2019 11:47:06 -0800 Subject: [PATCH 01/17] recreated changes due to CLA issue in previous pr. Adding args to intent so that app can parse as comamnd line args. --- .../hifiinterface/InterfaceActivity.java | 16 ++++++++++-- .../hifiinterface/PermissionChecker.java | 11 ++++++++ .../hifiinterface/SplashActivity.java | 26 ++++++++++++++----- interface/CMakeLists.txt | 6 ++++- 4 files changed, 50 insertions(+), 9 deletions(-) diff --git a/android/apps/interface/src/main/java/io/highfidelity/hifiinterface/InterfaceActivity.java b/android/apps/interface/src/main/java/io/highfidelity/hifiinterface/InterfaceActivity.java index b7d2157737..fdc0ec3bd8 100644 --- a/android/apps/interface/src/main/java/io/highfidelity/hifiinterface/InterfaceActivity.java +++ b/android/apps/interface/src/main/java/io/highfidelity/hifiinterface/InterfaceActivity.java @@ -24,6 +24,7 @@ import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.os.Vibrator; +import android.text.TextUtils; import android.util.Log; import android.view.LayoutInflater; import android.view.View; @@ -53,6 +54,7 @@ public class InterfaceActivity extends QtActivity implements WebViewFragment.OnW public static final String DOMAIN_URL = "url"; public static final String EXTRA_GOTO_USERNAME = "gotousername"; private static final String TAG = "Interface"; + public static final String EXTRA_ARGS = "args"; private static final int WEB_DRAWER_RIGHT_MARGIN = 262; private static final int WEB_DRAWER_BOTTOM_MARGIN = 150; private static final int NORMAL_DPI = 160; @@ -77,6 +79,7 @@ public class InterfaceActivity extends QtActivity implements WebViewFragment.OnW private boolean nativeEnterBackgroundCallEnqueued = false; private SlidingDrawer mWebSlidingDrawer; + private boolean mStartInDomain; // private GvrApi gvrApi; // Opaque native pointer to the Application C++ object. // This object is owned by the InterfaceActivity instance and passed to the native methods. @@ -92,8 +95,14 @@ public class InterfaceActivity extends QtActivity implements WebViewFragment.OnW public void onCreate(Bundle savedInstanceState) { super.isLoading = true; Intent intent = getIntent(); - if (intent.hasExtra(DOMAIN_URL) && !intent.getStringExtra(DOMAIN_URL).isEmpty()) { + if (intent.hasExtra(DOMAIN_URL) && !TextUtils.isEmpty(intent.getStringExtra(DOMAIN_URL))) { intent.putExtra("applicationArguments", "--url " + intent.getStringExtra(DOMAIN_URL)); + } else if (intent.hasExtra(EXTRA_ARGS)) { + String args = intent.getStringExtra(EXTRA_ARGS); + if (!TextUtils.isEmpty(args)) { + mStartInDomain = true; + intent.putExtra("applicationArguments", args); + } } super.onCreate(savedInstanceState); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); @@ -124,7 +133,10 @@ public class InterfaceActivity extends QtActivity implements WebViewFragment.OnW getActionBar().hide(); } }); - startActivity(new Intent(this, SplashActivity.class)); + Intent splashIntent = new Intent(this, SplashActivity.class); + splashIntent.putExtra(SplashActivity.EXTRA_START_IN_DOMAIN, mStartInDomain); + startActivity(splashIntent); + mVibrator = (Vibrator) this.getSystemService(VIBRATOR_SERVICE); headsetStateReceiver = new HeadsetStateReceiver(); } diff --git a/android/apps/interface/src/main/java/io/highfidelity/hifiinterface/PermissionChecker.java b/android/apps/interface/src/main/java/io/highfidelity/hifiinterface/PermissionChecker.java index 78a6421746..ef9876c71a 100644 --- a/android/apps/interface/src/main/java/io/highfidelity/hifiinterface/PermissionChecker.java +++ b/android/apps/interface/src/main/java/io/highfidelity/hifiinterface/PermissionChecker.java @@ -9,6 +9,7 @@ import android.content.pm.PackageManager; import android.os.Bundle; import android.util.Log; import android.view.View; +import android.text.TextUtils; import org.json.JSONException; import org.json.JSONObject; @@ -27,9 +28,14 @@ public class PermissionChecker extends Activity { private static final boolean CHOOSE_AVATAR_ON_STARTUP = false; private static final String TAG = "Interface"; + private static final String EXTRA_ARGS = "args"; + private String mArgs; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + mArgs =(getIntent().getStringExtra(EXTRA_ARGS)); + Intent myIntent = new Intent(this, BreakpadUploaderService.class); startService(myIntent); if (CHOOSE_AVATAR_ON_STARTUP) { @@ -76,6 +82,11 @@ public class PermissionChecker extends Activity { private void launchActivityWithPermissions(){ Intent i = new Intent(this, InterfaceActivity.class); + + if (!TextUtils.isEmpty(mArgs)) { + i.putExtra(EXTRA_ARGS, mArgs); + } + startActivity(i); finish(); } diff --git a/android/apps/interface/src/main/java/io/highfidelity/hifiinterface/SplashActivity.java b/android/apps/interface/src/main/java/io/highfidelity/hifiinterface/SplashActivity.java index bb42467ace..9506a6a644 100644 --- a/android/apps/interface/src/main/java/io/highfidelity/hifiinterface/SplashActivity.java +++ b/android/apps/interface/src/main/java/io/highfidelity/hifiinterface/SplashActivity.java @@ -36,13 +36,27 @@ public class SplashActivity extends Activity { } public void onAppLoadedComplete() { - if (HifiUtils.getInstance().isUserLoggedIn()) { - startActivity(new Intent(this, MainActivity.class)); - } else { - Intent menuIntent = new Intent(this, LoginMenuActivity.class); - menuIntent.putExtra(LoginMenuActivity.EXTRA_FINISH_ON_BACK, true); - startActivity(menuIntent); + if (!mStartInDomain) { + if (HifiUtils.getInstance().isUserLoggedIn()) { + startActivity(new Intent(this, MainActivity.class)); + } else { + Intent menuIntent = new Intent(this, LoginMenuActivity.class); + menuIntent.putExtra(LoginMenuActivity.EXTRA_FINISH_ON_BACK, true); + startActivity(menuIntent); + } } SplashActivity.this.finish(); } + + @Override + protected void onSaveInstanceState(Bundle outState) { + super.onSaveInstanceState(outState); + outState.putBoolean(EXTRA_START_IN_DOMAIN, mStartInDomain); + } + + @Override + protected void onRestoreInstanceState(Bundle savedInstanceState) { + super.onRestoreInstanceState(savedInstanceState); + mStartInDomain = savedInstanceState.getBoolean(EXTRA_START_IN_DOMAIN, false); + } } diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index c013cfacd3..019e20c7f7 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -330,7 +330,11 @@ if (APPLE) COMMAND "${CMAKE_COMMAND}" -E copy_directory "${PROJECT_SOURCE_DIR}/resources/fonts" "${RESOURCES_DEV_DIR}/fonts" - # add redirect json to macOS builds. + #copy serverless for android + COMMAND "${CMAKE_COMMAND}" -E copy_directory + "${PROJECT_SOURCE_DIR}/resources/serverless" + "${RESOURCES_DEV_DIR}/serverless" + # add redirect json to macOS builds. COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${PROJECT_SOURCE_DIR}/resources/serverless/redirect.json" "${RESOURCES_DEV_DIR}/serverless/redirect.json" From d089bd5b8feb9200f1592406fa32acaaae1ab9db Mon Sep 17 00:00:00 2001 From: amer cerkic Date: Wed, 30 Jan 2019 12:40:09 -0800 Subject: [PATCH 02/17] missed variable declaration --- .../java/io/highfidelity/hifiinterface/SplashActivity.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/android/apps/interface/src/main/java/io/highfidelity/hifiinterface/SplashActivity.java b/android/apps/interface/src/main/java/io/highfidelity/hifiinterface/SplashActivity.java index 9506a6a644..536bf23603 100644 --- a/android/apps/interface/src/main/java/io/highfidelity/hifiinterface/SplashActivity.java +++ b/android/apps/interface/src/main/java/io/highfidelity/hifiinterface/SplashActivity.java @@ -7,6 +7,9 @@ import android.view.View; public class SplashActivity extends Activity { + public static final String EXTRA_START_IN_DOMAIN = "start-in-domain"; + private boolean mStartInDomain; + private native void registerLoadCompleteListener(); @Override From 5945823606a9fd0494fc96f80edbf851ffe25ff5 Mon Sep 17 00:00:00 2001 From: Clement Date: Tue, 5 Feb 2019 17:02:00 -0800 Subject: [PATCH 03/17] Honor full scene resends --- assignment-client/src/entities/EntityTreeSendThread.cpp | 7 ++++--- assignment-client/src/entities/EntityTreeSendThread.h | 2 +- libraries/entities/src/DiffTraversal.cpp | 5 +++-- libraries/entities/src/DiffTraversal.h | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/assignment-client/src/entities/EntityTreeSendThread.cpp b/assignment-client/src/entities/EntityTreeSendThread.cpp index 8b7c8771e8..a6542689e0 100644 --- a/assignment-client/src/entities/EntityTreeSendThread.cpp +++ b/assignment-client/src/entities/EntityTreeSendThread.cpp @@ -111,7 +111,7 @@ bool EntityTreeSendThread::traverseTreeAndSendContents(SharedNodePointer node, O int32_t lodLevelOffset = nodeData->getBoundaryLevelAdjust() + (viewFrustumChanged ? LOW_RES_MOVING_ADJUST : NO_BOUNDARY_ADJUST); newView.lodScaleFactor = powf(2.0f, lodLevelOffset); - startNewTraversal(newView, root); + startNewTraversal(newView, root, isFullScene); // When the viewFrustum changed the sort order may be incorrect, so we re-sort // and also use the opportunity to cull anything no longer in view @@ -220,9 +220,10 @@ bool EntityTreeSendThread::addDescendantsToExtraFlaggedEntities(const QUuid& fil return hasNewChild || hasNewDescendants; } -void EntityTreeSendThread::startNewTraversal(const DiffTraversal::View& view, EntityTreeElementPointer root) { +void EntityTreeSendThread::startNewTraversal(const DiffTraversal::View& view, EntityTreeElementPointer root, + bool forceFirstPass) { - DiffTraversal::Type type = _traversal.prepareNewTraversal(view, root); + DiffTraversal::Type type = _traversal.prepareNewTraversal(view, root, forceFirstPass); // there are three types of traversal: // // (1) FirstTime = at login --> find everything in view diff --git a/assignment-client/src/entities/EntityTreeSendThread.h b/assignment-client/src/entities/EntityTreeSendThread.h index 199769ca09..7eedc2f1ba 100644 --- a/assignment-client/src/entities/EntityTreeSendThread.h +++ b/assignment-client/src/entities/EntityTreeSendThread.h @@ -42,7 +42,7 @@ private: bool addAncestorsToExtraFlaggedEntities(const QUuid& filteredEntityID, EntityItem& entityItem, EntityNodeData& nodeData); bool addDescendantsToExtraFlaggedEntities(const QUuid& filteredEntityID, EntityItem& entityItem, EntityNodeData& nodeData); - void startNewTraversal(const DiffTraversal::View& viewFrustum, EntityTreeElementPointer root); + void startNewTraversal(const DiffTraversal::View& viewFrustum, EntityTreeElementPointer root, bool forceFirstPass = false); bool traverseTreeAndBuildNextPacketPayload(EncodeBitstreamParams& params, const QJsonObject& jsonFilters) override; void preDistributionProcessing() override; diff --git a/libraries/entities/src/DiffTraversal.cpp b/libraries/entities/src/DiffTraversal.cpp index 36d1f41267..dc32419ed0 100644 --- a/libraries/entities/src/DiffTraversal.cpp +++ b/libraries/entities/src/DiffTraversal.cpp @@ -193,7 +193,8 @@ DiffTraversal::DiffTraversal() { _path.reserve(MIN_PATH_DEPTH); } -DiffTraversal::Type DiffTraversal::prepareNewTraversal(const DiffTraversal::View& view, EntityTreeElementPointer root) { +DiffTraversal::Type DiffTraversal::prepareNewTraversal(const DiffTraversal::View& view, EntityTreeElementPointer root, + bool forceFirstPass) { assert(root); // there are three types of traversal: // @@ -212,7 +213,7 @@ DiffTraversal::Type DiffTraversal::prepareNewTraversal(const DiffTraversal::View Type type; // If usesViewFrustum changes, treat it as a First traversal - if (_completedView.startTime == 0 || _currentView.usesViewFrustums() != _completedView.usesViewFrustums()) { + if (forceFirstPass || _completedView.startTime == 0 || _currentView.usesViewFrustums() != _completedView.usesViewFrustums()) { type = Type::First; _currentView.viewFrustums = view.viewFrustums; _currentView.lodScaleFactor = view.lodScaleFactor; diff --git a/libraries/entities/src/DiffTraversal.h b/libraries/entities/src/DiffTraversal.h index d62c7b8ee1..e1107ec930 100644 --- a/libraries/entities/src/DiffTraversal.h +++ b/libraries/entities/src/DiffTraversal.h @@ -61,7 +61,7 @@ public: DiffTraversal(); - Type prepareNewTraversal(const DiffTraversal::View& view, EntityTreeElementPointer root); + Type prepareNewTraversal(const DiffTraversal::View& view, EntityTreeElementPointer root, bool forceFirstPass = false); const View& getCurrentView() const { return _currentView; } From 8b32a62e2fc251ea9e26ccab2a2490c595052622 Mon Sep 17 00:00:00 2001 From: Clement Date: Tue, 5 Feb 2019 17:02:19 -0800 Subject: [PATCH 04/17] Simplify filter check --- libraries/entities/src/EntityItem.cpp | 11 ++--------- .../src/model-networking/TextureCache.cpp | 1 - 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/libraries/entities/src/EntityItem.cpp b/libraries/entities/src/EntityItem.cpp index 1640e97ff4..79b7eb27a1 100644 --- a/libraries/entities/src/EntityItem.cpp +++ b/libraries/entities/src/EntityItem.cpp @@ -2635,15 +2635,8 @@ bool EntityItem::matchesJSONFilters(const QJsonObject& jsonFilters) const { static const QString SERVER_SCRIPTS_PROPERTY = "serverScripts"; - foreach(const auto& property, jsonFilters.keys()) { - if (property == SERVER_SCRIPTS_PROPERTY && jsonFilters[property] == EntityQueryFilterSymbol::NonDefault) { - // check if this entity has a non-default value for serverScripts - if (_serverScripts != ENTITY_ITEM_DEFAULT_SERVER_SCRIPTS) { - return true; - } else { - return false; - } - } + if (jsonFilters[SERVER_SCRIPTS_PROPERTY] == EntityQueryFilterSymbol::NonDefault) { + return _serverScripts != ENTITY_ITEM_DEFAULT_SERVER_SCRIPTS; } // the json filter syntax did not match what we expected, return a match diff --git a/libraries/model-networking/src/model-networking/TextureCache.cpp b/libraries/model-networking/src/model-networking/TextureCache.cpp index 4c30dc6d93..37e8ad3f56 100644 --- a/libraries/model-networking/src/model-networking/TextureCache.cpp +++ b/libraries/model-networking/src/model-networking/TextureCache.cpp @@ -493,7 +493,6 @@ void NetworkTexture::makeRequest() { } else { qWarning(networking) << "NetworkTexture::makeRequest() called while not in a valid state: " << _ktxResourceState; } - } void NetworkTexture::handleLocalRequestCompleted() { From 5e9b63b352c69309d5835be5ef812c8768a3baef Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Tue, 12 Feb 2019 13:56:56 -0800 Subject: [PATCH 05/17] fix-qml-crash-on-mac --- interface/resources/qml/+webengine/Browser.qml | 2 +- interface/resources/qml/+webengine/InfoView.qml | 2 +- interface/resources/qml/+webengine/QmlWebWindow.qml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/interface/resources/qml/+webengine/Browser.qml b/interface/resources/qml/+webengine/Browser.qml index 52157bdf42..e00549347d 100644 --- a/interface/resources/qml/+webengine/Browser.qml +++ b/interface/resources/qml/+webengine/Browser.qml @@ -4,7 +4,7 @@ import QtWebEngine 1.5 import controlsUit 1.0 import stylesUit 1.0 -import "qrc:////qml//windows" +import "windows" ScrollingWindow { id: root diff --git a/interface/resources/qml/+webengine/InfoView.qml b/interface/resources/qml/+webengine/InfoView.qml index eb190c3c45..8c5900b4c3 100644 --- a/interface/resources/qml/+webengine/InfoView.qml +++ b/interface/resources/qml/+webengine/InfoView.qml @@ -12,7 +12,7 @@ import QtQuick 2.5 import Hifi 1.0 as Hifi import controlsUit 1.0 -import "qrc:////qml//windows" as Windows +import "windows" as Windows Windows.ScrollingWindow { id: root diff --git a/interface/resources/qml/+webengine/QmlWebWindow.qml b/interface/resources/qml/+webengine/QmlWebWindow.qml index 2e3718f6f5..35799d64a9 100644 --- a/interface/resources/qml/+webengine/QmlWebWindow.qml +++ b/interface/resources/qml/+webengine/QmlWebWindow.qml @@ -12,7 +12,7 @@ import QtQuick 2.5 import QtWebEngine 1.1 import QtWebChannel 1.0 -import "qrc:////qml//windows" as Windows +import "../windows" as Windows import controlsUit 1.0 as Controls import stylesUit 1.0 From a111aa1724e828b8a1ef0d46fbc31d5fda62f3b1 Mon Sep 17 00:00:00 2001 From: danteruiz Date: Tue, 12 Feb 2019 16:45:45 -0800 Subject: [PATCH 06/17] fix blocks app --- .../resources/qml/hifi/tablet/+webengine/BlocksWebView.qml | 7 +++++++ interface/resources/qml/hifi/tablet/BlocksWebView.qml | 1 - 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 interface/resources/qml/hifi/tablet/+webengine/BlocksWebView.qml diff --git a/interface/resources/qml/hifi/tablet/+webengine/BlocksWebView.qml b/interface/resources/qml/hifi/tablet/+webengine/BlocksWebView.qml new file mode 100644 index 0000000000..050515da37 --- /dev/null +++ b/interface/resources/qml/hifi/tablet/+webengine/BlocksWebView.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 +import QtWebEngine 1.5 +import "../../controls" as Controls + +Controls.TabletWebView { + profile: WebEngineProfile { httpUserAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36"} +} diff --git a/interface/resources/qml/hifi/tablet/BlocksWebView.qml b/interface/resources/qml/hifi/tablet/BlocksWebView.qml index 03fce0a112..eaed88ba01 100644 --- a/interface/resources/qml/hifi/tablet/BlocksWebView.qml +++ b/interface/resources/qml/hifi/tablet/BlocksWebView.qml @@ -2,7 +2,6 @@ import QtQuick 2.0 import "../../controls" as Controls Controls.TabletWebView { - profile: WebEngineProfile { httpUserAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36"} } From 562e159ab4c775842d14013db44d47943c215f5f Mon Sep 17 00:00:00 2001 From: danteruiz Date: Wed, 13 Feb 2019 10:45:07 -0800 Subject: [PATCH 07/17] the proper fix for browser qml issues --- .../resources/qml/+webengine/Browser.qml | 275 ------------------ .../qml/+webengine/BrowserWebView.qml | 58 ++++ .../resources/qml/+webengine/InfoView.qml | 50 ---- .../resources/qml/+webengine/QmlWebWindow.qml | 108 ------- .../qml/+webengine/QmlWebWindowView.qml | 53 ++++ interface/resources/qml/Browser.qml | 18 +- interface/resources/qml/BrowserWebView.qml | 8 + interface/resources/qml/InfoView.qml | 2 +- interface/resources/qml/QmlWebWindow.qml | 7 +- interface/resources/qml/QmlWebWindowView.qml | 5 + .../qml/controlsUit/ProxyWebView.qml | 1 + 11 files changed, 140 insertions(+), 445 deletions(-) delete mode 100644 interface/resources/qml/+webengine/Browser.qml create mode 100644 interface/resources/qml/+webengine/BrowserWebView.qml delete mode 100644 interface/resources/qml/+webengine/InfoView.qml delete mode 100644 interface/resources/qml/+webengine/QmlWebWindow.qml create mode 100644 interface/resources/qml/+webengine/QmlWebWindowView.qml create mode 100644 interface/resources/qml/BrowserWebView.qml create mode 100644 interface/resources/qml/QmlWebWindowView.qml diff --git a/interface/resources/qml/+webengine/Browser.qml b/interface/resources/qml/+webengine/Browser.qml deleted file mode 100644 index e00549347d..0000000000 --- a/interface/resources/qml/+webengine/Browser.qml +++ /dev/null @@ -1,275 +0,0 @@ -import QtQuick 2.5 -import QtWebChannel 1.0 -import QtWebEngine 1.5 - -import controlsUit 1.0 -import stylesUit 1.0 -import "windows" - -ScrollingWindow { - id: root - HifiConstants { id: hifi } - //HifiStyles.HifiConstants { id: hifistyles } - title: "Browser" - resizable: true - destroyOnHidden: true - width: 800 - height: 600 - property variant permissionsBar: {'securityOrigin':'none','feature':'none'} - property alias url: webview.url - property alias webView: webview - - signal loadingChanged(int status) - - x: 100 - y: 100 - - Component.onCompleted: { - focus = true - shown = true - addressBar.text = webview.url - } - - function setProfile(profile) { - webview.profile = profile; - } - - function showPermissionsBar(){ - permissionsContainer.visible=true; - } - - function hidePermissionsBar(){ - permissionsContainer.visible=false; - } - - function allowPermissions(){ - webview.grantFeaturePermission(permissionsBar.securityOrigin, permissionsBar.feature, true); - hidePermissionsBar(); - } - - function setAutoAdd(auto) { - desktop.setAutoAdd(auto); - } - - Item { - id:item - width: pane.contentWidth - implicitHeight: pane.scrollHeight - - Row { - id: buttons - spacing: 4 - anchors.top: parent.top - anchors.topMargin: 8 - anchors.left: parent.left - anchors.leftMargin: 8 - HiFiGlyphs { - id: back; - enabled: webview.canGoBack; - text: hifi.glyphs.backward - color: enabled ? hifi.colors.text : hifi.colors.disabledText - size: 48 - MouseArea { anchors.fill: parent; onClicked: webview.goBack() } - } - - HiFiGlyphs { - id: forward; - enabled: webview.canGoForward; - text: hifi.glyphs.forward - color: enabled ? hifi.colors.text : hifi.colors.disabledText - size: 48 - MouseArea { anchors.fill: parent; onClicked: webview.goForward() } - } - - HiFiGlyphs { - id: reload; - enabled: webview.canGoForward; - text: webview.loading ? hifi.glyphs.close : hifi.glyphs.reload - color: enabled ? hifi.colors.text : hifi.colors.disabledText - size: 48 - MouseArea { anchors.fill: parent; onClicked: webview.goForward() } - } - - } - - Item { - id: border - height: 48 - anchors.top: parent.top - anchors.topMargin: 8 - anchors.right: parent.right - anchors.rightMargin: 8 - anchors.left: buttons.right - anchors.leftMargin: 8 - - Item { - id: barIcon - width: parent.height - height: parent.height - Image { - source: webview.icon; - x: (parent.height - height) / 2 - y: (parent.width - width) / 2 - sourceSize: Qt.size(width, height); - verticalAlignment: Image.AlignVCenter; - horizontalAlignment: Image.AlignHCenter - } - } - - TextField { - id: addressBar - anchors.right: parent.right - anchors.rightMargin: 8 - anchors.left: barIcon.right - anchors.leftMargin: 0 - anchors.verticalCenter: parent.verticalCenter - focus: true - colorScheme: hifi.colorSchemes.dark - placeholderText: "Enter URL" - Component.onCompleted: ScriptDiscoveryService.scriptsModelFilter.filterRegExp = new RegExp("^.*$", "i") - Keys.onPressed: { - switch(event.key) { - case Qt.Key_Enter: - case Qt.Key_Return: - event.accepted = true - if (text.indexOf("http") != 0) { - text = "http://" + text; - } - root.hidePermissionsBar(); - root.keyboardRaised = false; - webview.url = text; - break; - } - } - } - } - - Rectangle { - id:permissionsContainer - visible:false - color: "#000000" - width: parent.width - anchors.top: buttons.bottom - height:40 - z:100 - gradient: Gradient { - GradientStop { position: 0.0; color: "black" } - GradientStop { position: 1.0; color: "grey" } - } - - RalewayLight { - id: permissionsInfo - anchors.right:permissionsRow.left - anchors.rightMargin: 32 - anchors.topMargin:8 - anchors.top:parent.top - text: "This site wants to use your microphone/camera" - size: 18 - color: hifi.colors.white - } - - Row { - id: permissionsRow - spacing: 4 - anchors.top:parent.top - anchors.topMargin: 8 - anchors.right: parent.right - visible: true - z:101 - - Button { - id:allow - text: "Allow" - color: hifi.buttons.blue - colorScheme: root.colorScheme - width: 120 - enabled: true - onClicked: root.allowPermissions(); - z:101 - } - - Button { - id:block - text: "Block" - color: hifi.buttons.red - colorScheme: root.colorScheme - width: 120 - enabled: true - onClicked: root.hidePermissionsBar(); - z:101 - } - } - } - - WebView { - id: webview - url: "https://highfidelity.com/" - profile: FileTypeProfile; - - // Create a global EventBridge object for raiseAndLowerKeyboard. - WebEngineScript { - id: createGlobalEventBridge - sourceCode: eventBridgeJavaScriptToInject - injectionPoint: WebEngineScript.Deferred - worldId: WebEngineScript.MainWorld - } - - // Detect when may want to raise and lower keyboard. - WebEngineScript { - id: raiseAndLowerKeyboard - injectionPoint: WebEngineScript.Deferred - sourceUrl: resourceDirectoryUrl + "/html/raiseAndLowerKeyboard.js" - worldId: WebEngineScript.MainWorld - } - - userScripts: [ createGlobalEventBridge, raiseAndLowerKeyboard ] - - anchors.top: buttons.bottom - anchors.topMargin: 8 - anchors.bottom: parent.bottom - anchors.left: parent.left - anchors.right: parent.right - - onFeaturePermissionRequested: { - if (feature == 2) { // QWebEnginePage::MediaAudioCapture - grantFeaturePermission(securityOrigin, feature, true); - } else { - permissionsBar.securityOrigin = securityOrigin; - permissionsBar.feature = feature; - root.showPermissionsBar(); - } - } - - onLoadingChanged: { - if (loadRequest.status === WebEngineView.LoadSucceededStatus) { - addressBar.text = loadRequest.url - } - root.loadingChanged(loadRequest.status); - } - - onWindowCloseRequested: { - root.destroy(); - } - - Component.onCompleted: { - webChannel.registerObject("eventBridge", eventBridge); - webChannel.registerObject("eventBridgeWrapper", eventBridgeWrapper); - desktop.initWebviewProfileHandlers(webview.profile); - } - } - - } // item - - - Keys.onPressed: { - switch(event.key) { - case Qt.Key_L: - if (event.modifiers == Qt.ControlModifier) { - event.accepted = true - addressBar.selectAll() - addressBar.forceActiveFocus() - } - break; - } - } -} // dialog diff --git a/interface/resources/qml/+webengine/BrowserWebView.qml b/interface/resources/qml/+webengine/BrowserWebView.qml new file mode 100644 index 0000000000..5c5cf2cfb9 --- /dev/null +++ b/interface/resources/qml/+webengine/BrowserWebView.qml @@ -0,0 +1,58 @@ +import QtQuick 2.5 +import QtWebChannel 1.0 +import QtWebEngine 1.5 + +import controlsUit 1.0 + +WebView { + id: webview + url: "https://highfidelity.com/" + profile: FileTypeProfile; + + property var parentRoot: null + + // Create a global EventBridge object for raiseAndLowerKeyboard. + WebEngineScript { + id: createGlobalEventBridge + sourceCode: eventBridgeJavaScriptToInject + injectionPoint: WebEngineScript.Deferred + worldId: WebEngineScript.MainWorld + } + + // Detect when may want to raise and lower keyboard. + WebEngineScript { + id: raiseAndLowerKeyboard + injectionPoint: WebEngineScript.Deferred + sourceUrl: resourceDirectoryUrl + "/html/raiseAndLowerKeyboard.js" + worldId: WebEngineScript.MainWorld + } + + userScripts: [ createGlobalEventBridge, raiseAndLowerKeyboard ] + + onFeaturePermissionRequested: { + if (feature == 2) { // QWebEnginePage::MediaAudioCapture + grantFeaturePermission(securityOrigin, feature, true); + } else { + permissionsBar.securityOrigin = securityOrigin; + permissionsBar.feature = feature; + parentRoot.showPermissionsBar(); + } + } + + onLoadingChanged: { + if (loadRequest.status === WebEngineView.LoadSucceededStatus) { + addressBar.text = loadRequest.url + } + parentRoot.loadingChanged(loadRequest.status); + } + + onWindowCloseRequested: { + parentRoot.destroy(); + } + + Component.onCompleted: { + webChannel.registerObject("eventBridge", eventBridge); + webChannel.registerObject("eventBridgeWrapper", eventBridgeWrapper); + desktop.initWebviewProfileHandlers(webview.profile); + } +} diff --git a/interface/resources/qml/+webengine/InfoView.qml b/interface/resources/qml/+webengine/InfoView.qml deleted file mode 100644 index 8c5900b4c3..0000000000 --- a/interface/resources/qml/+webengine/InfoView.qml +++ /dev/null @@ -1,50 +0,0 @@ -// -// InfoView.qml -// -// Created by Bradley Austin Davis on 27 Apr 2015 -// Copyright 2015 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -import QtQuick 2.5 -import Hifi 1.0 as Hifi - -import controlsUit 1.0 -import "windows" as Windows - -Windows.ScrollingWindow { - id: root - width: 800 - height: 800 - resizable: true - - Hifi.InfoView { - id: infoView - width: pane.contentWidth - implicitHeight: pane.scrollHeight - - WebView { - id: webview - objectName: "WebView" - anchors.fill: parent - url: infoView.url - } - } - - Component.onCompleted: { - centerWindow(root); - } - - onVisibleChanged: { - if (visible) { - centerWindow(root); - } - } - - function centerWindow() { - desktop.centerOnVisible(root); - } - -} diff --git a/interface/resources/qml/+webengine/QmlWebWindow.qml b/interface/resources/qml/+webengine/QmlWebWindow.qml deleted file mode 100644 index 35799d64a9..0000000000 --- a/interface/resources/qml/+webengine/QmlWebWindow.qml +++ /dev/null @@ -1,108 +0,0 @@ -// -// QmlWebWindow.qml -// -// Created by Bradley Austin Davis on 17 Dec 2015 -// Copyright 2015 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -import QtQuick 2.5 -import QtWebEngine 1.1 -import QtWebChannel 1.0 - -import "../windows" as Windows -import controlsUit 1.0 as Controls -import stylesUit 1.0 - -Windows.ScrollingWindow { - id: root - HifiConstants { id: hifi } - title: "WebWindow" - resizable: true - shown: false - // Don't destroy on close... otherwise the JS/C++ will have a dangling pointer - destroyOnCloseButton: false - property alias source: webview.url - property alias scriptUrl: webview.userScriptUrl - - // This is for JS/QML communication, which is unused in a WebWindow, - // but not having this here results in spurious warnings about a - // missing signal - signal sendToScript(var message); - - signal moved(vector2d position); - signal resized(size size); - - function notifyMoved() { - moved(Qt.vector2d(x, y)); - } - - function notifyResized() { - resized(Qt.size(width, height)); - } - - onXChanged: notifyMoved(); - onYChanged: notifyMoved(); - - onWidthChanged: notifyResized(); - onHeightChanged: notifyResized(); - - onShownChanged: { - keyboardEnabled = HMD.active; - } - - Item { - width: pane.contentWidth - implicitHeight: pane.scrollHeight - - Controls.WebView { - id: webview - url: "about:blank" - anchors.fill: parent - focus: true - profile: HFWebEngineProfile; - - property string userScriptUrl: "" - - // Create a global EventBridge object for raiseAndLowerKeyboard. - WebEngineScript { - id: createGlobalEventBridge - sourceCode: eventBridgeJavaScriptToInject - injectionPoint: WebEngineScript.DocumentCreation - worldId: WebEngineScript.MainWorld - } - - // Detect when may want to raise and lower keyboard. - WebEngineScript { - id: raiseAndLowerKeyboard - injectionPoint: WebEngineScript.Deferred - sourceUrl: resourceDirectoryUrl + "/html/raiseAndLowerKeyboard.js" - worldId: WebEngineScript.MainWorld - } - - // User script. - WebEngineScript { - id: userScript - sourceUrl: webview.userScriptUrl - injectionPoint: WebEngineScript.DocumentReady // DOM ready but page load may not be finished. - worldId: WebEngineScript.MainWorld - } - - userScripts: [ createGlobalEventBridge, raiseAndLowerKeyboard, userScript ] - - function onWebEventReceived(event) { - if (event.slice(0, 17) === "CLARA.IO DOWNLOAD") { - ApplicationInterface.addAssetToWorldFromURL(event.slice(18)); - } - } - - Component.onCompleted: { - webChannel.registerObject("eventBridge", eventBridge); - webChannel.registerObject("eventBridgeWrapper", eventBridgeWrapper); - eventBridge.webEventReceived.connect(onWebEventReceived); - } - } - } -} diff --git a/interface/resources/qml/+webengine/QmlWebWindowView.qml b/interface/resources/qml/+webengine/QmlWebWindowView.qml new file mode 100644 index 0000000000..d2f1820e9a --- /dev/null +++ b/interface/resources/qml/+webengine/QmlWebWindowView.qml @@ -0,0 +1,53 @@ +import QtQuick 2.5 +import QtWebEngine 1.1 +import QtWebChannel 1.0 + +import controlsUit 1.0 as Controls +import stylesUit 1.0 +Controls.WebView { + id: webview + url: "about:blank" + anchors.fill: parent + focus: true + profile: HFWebEngineProfile; + + property string userScriptUrl: "" + + // Create a global EventBridge object for raiseAndLowerKeyboard. + WebEngineScript { + id: createGlobalEventBridge + sourceCode: eventBridgeJavaScriptToInject + injectionPoint: WebEngineScript.DocumentCreation + worldId: WebEngineScript.MainWorld + } + + // Detect when may want to raise and lower keyboard. + WebEngineScript { + id: raiseAndLowerKeyboard + injectionPoint: WebEngineScript.Deferred + sourceUrl: resourceDirectoryUrl + "/html/raiseAndLowerKeyboard.js" + worldId: WebEngineScript.MainWorld + } + + // User script. + WebEngineScript { + id: userScript + sourceUrl: webview.userScriptUrl + injectionPoint: WebEngineScript.DocumentReady // DOM ready but page load may not be finished. + worldId: WebEngineScript.MainWorld + } + + userScripts: [ createGlobalEventBridge, raiseAndLowerKeyboard, userScript ] + + function onWebEventReceived(event) { + if (event.slice(0, 17) === "CLARA.IO DOWNLOAD") { + ApplicationInterface.addAssetToWorldFromURL(event.slice(18)); + } + } + + Component.onCompleted: { + webChannel.registerObject("eventBridge", eventBridge); + webChannel.registerObject("eventBridgeWrapper", eventBridgeWrapper); + eventBridge.webEventReceived.connect(onWebEventReceived); + } +} diff --git a/interface/resources/qml/Browser.qml b/interface/resources/qml/Browser.qml index 78ffb51e67..496209a2a8 100644 --- a/interface/resources/qml/Browser.qml +++ b/interface/resources/qml/Browser.qml @@ -1,14 +1,13 @@ import QtQuick 2.5 - import controlsUit 1.0 import stylesUit 1.0 - import "windows" +import "." ScrollingWindow { id: root HifiConstants { id: hifi } - //HifiStyles.HifiConstants { id: hifistyles } + title: "Browser" resizable: true destroyOnHidden: true @@ -30,6 +29,7 @@ ScrollingWindow { } function setProfile(profile) { + webview.profile = profile; } function showPermissionsBar(){ @@ -41,6 +41,7 @@ ScrollingWindow { } function allowPermissions(){ + webview.grantFeaturePermission(permissionsBar.securityOrigin, permissionsBar.feature, true); hidePermissionsBar(); } @@ -198,10 +199,15 @@ ScrollingWindow { } } - ProxyWebView { + BrowserWebView { id: webview - anchors.centerIn: parent - url: "https://highfidelity.com/" + parentRoot: root + + anchors.top: buttons.bottom + anchors.topMargin: 8 + anchors.bottom: parent.bottom + anchors.left: parent.left + anchors.right: parent.right } } // item diff --git a/interface/resources/qml/BrowserWebView.qml b/interface/resources/qml/BrowserWebView.qml new file mode 100644 index 0000000000..6db016c284 --- /dev/null +++ b/interface/resources/qml/BrowserWebView.qml @@ -0,0 +1,8 @@ +import QtQuick 2.5 +import controlsUit 1.0 + +ProxyWebView { + property var parentRoot: null + + function grantFeaturePermission(origin, feature) {} +} diff --git a/interface/resources/qml/InfoView.qml b/interface/resources/qml/InfoView.qml index 5c2c7fcff9..2fd0ddf925 100644 --- a/interface/resources/qml/InfoView.qml +++ b/interface/resources/qml/InfoView.qml @@ -24,7 +24,7 @@ Windows.ScrollingWindow { width: pane.contentWidth implicitHeight: pane.scrollHeight - ProxyWebView { + BaseWebView { id: webview objectName: "WebView" anchors.fill: parent diff --git a/interface/resources/qml/QmlWebWindow.qml b/interface/resources/qml/QmlWebWindow.qml index a40168039e..7ee4b1c50c 100644 --- a/interface/resources/qml/QmlWebWindow.qml +++ b/interface/resources/qml/QmlWebWindow.qml @@ -11,6 +11,7 @@ import QtQuick 2.5 import "windows" as Windows +import "." import controlsUit 1.0 as Controls import stylesUit 1.0 @@ -55,12 +56,8 @@ Windows.ScrollingWindow { width: pane.contentWidth implicitHeight: pane.scrollHeight - Controls.WebView { + QmlWebWindowView { id: webview - url: "about:blank" - property string userScriptUrl: "" - anchors.fill: parent - focus: true } } } diff --git a/interface/resources/qml/QmlWebWindowView.qml b/interface/resources/qml/QmlWebWindowView.qml new file mode 100644 index 0000000000..9210468ae2 --- /dev/null +++ b/interface/resources/qml/QmlWebWindowView.qml @@ -0,0 +1,5 @@ +import QtQuick 2.5 +import controlsUit 1.0 + +BaseWebView { +} diff --git a/interface/resources/qml/controlsUit/ProxyWebView.qml b/interface/resources/qml/controlsUit/ProxyWebView.qml index adcc472831..2b13760962 100644 --- a/interface/resources/qml/controlsUit/ProxyWebView.qml +++ b/interface/resources/qml/controlsUit/ProxyWebView.qml @@ -18,6 +18,7 @@ Rectangle { property bool safeLoading: false property bool loadingLatched: false + property bool loading: false property var loadingRequest: null From 77b679606f4b168b771b033653e86fde05fc04dd Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Wed, 13 Feb 2019 15:13:55 -0800 Subject: [PATCH 08/17] Corrected bug in zip folder name. --- tools/nitpick/src/TestRunnerDesktop.cpp | 17 +++++++++++------ tools/nitpick/src/TestRunnerDesktop.h | 4 ++-- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/tools/nitpick/src/TestRunnerDesktop.cpp b/tools/nitpick/src/TestRunnerDesktop.cpp index 50cb6f9a07..e45d895886 100644 --- a/tools/nitpick/src/TestRunnerDesktop.cpp +++ b/tools/nitpick/src/TestRunnerDesktop.cpp @@ -554,7 +554,7 @@ void TestRunnerDesktop::evaluateResults() { nitpick->startTestsEvaluation(false, true, _snapshotFolder, _branch, _user); } -void TestRunnerDesktop::automaticTestRunEvaluationComplete(QString zippedFolder, int numberOfFailures) { +void TestRunnerDesktop::automaticTestRunEvaluationComplete(const QString& zippedFolder, int numberOfFailures) { addBuildNumberToResults(zippedFolder); restoreHighFidelityAppDataFolder(); @@ -580,14 +580,19 @@ void TestRunnerDesktop::automaticTestRunEvaluationComplete(QString zippedFolder, _runNow->setEnabled(true); } -void TestRunnerDesktop::addBuildNumberToResults(QString zippedFolderName) { - QString augmentedFilename; +void TestRunnerDesktop::addBuildNumberToResults(const QString& zippedFolderName) { + QString augmentedFilename { zippedFolderName }; if (!_runLatest->isChecked()) { - augmentedFilename = zippedFolderName.replace("local", getPRNumberFromURL(_url->text())); + augmentedFilename.replace("local", getPRNumberFromURL(_url->text())); } else { - augmentedFilename = zippedFolderName.replace("local", _buildInformation.build); + augmentedFilename.replace("local", _buildInformation.build); + } + + if (!QFile::rename(zippedFolderName, augmentedFilename)) { + QMessageBox::critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), "Could not rename '" + zippedFolderName + "' to '" + augmentedFilename); + exit(-1); + } - QFile::rename(zippedFolderName, augmentedFilename); } void TestRunnerDesktop::restoreHighFidelityAppDataFolder() { diff --git a/tools/nitpick/src/TestRunnerDesktop.h b/tools/nitpick/src/TestRunnerDesktop.h index a8f828b9d4..140a81f465 100644 --- a/tools/nitpick/src/TestRunnerDesktop.h +++ b/tools/nitpick/src/TestRunnerDesktop.h @@ -61,8 +61,8 @@ public: void runInterfaceWithTestScript(); void evaluateResults(); - void automaticTestRunEvaluationComplete(QString zippedFolderName, int numberOfFailures); - void addBuildNumberToResults(QString zippedFolderName); + void automaticTestRunEvaluationComplete(const QString& zippedFolderName, int numberOfFailures); + void addBuildNumberToResults(const QString& zippedFolderName); void copyFolder(const QString& source, const QString& destination); From 12c122ce9cf5d55a05ce3c3d1c266f43a41cfbf7 Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Wed, 13 Feb 2019 15:14:36 -0800 Subject: [PATCH 09/17] Bump up version number. --- tools/nitpick/src/Nitpick.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/nitpick/src/Nitpick.cpp b/tools/nitpick/src/Nitpick.cpp index 3a799ce3c2..d5bc6f6e5a 100644 --- a/tools/nitpick/src/Nitpick.cpp +++ b/tools/nitpick/src/Nitpick.cpp @@ -40,7 +40,7 @@ Nitpick::Nitpick(QWidget* parent) : QMainWindow(parent) { _ui.plainTextEdit->setReadOnly(true); - setWindowTitle("Nitpick - v2.1.1"); + setWindowTitle("Nitpick - v2.1.2"); } Nitpick::~Nitpick() { From 86aaba016fb6e425886c3ed8bb274940db0a78c7 Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Wed, 13 Feb 2019 15:15:46 -0800 Subject: [PATCH 10/17] Narrow filter on zip folder selection. --- tools/nitpick/src/Test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/nitpick/src/Test.cpp b/tools/nitpick/src/Test.cpp index f618118289..6647d154af 100644 --- a/tools/nitpick/src/Test.cpp +++ b/tools/nitpick/src/Test.cpp @@ -1091,7 +1091,7 @@ void Test::setTestRailCreateMode(TestRailCreateMode testRailCreateMode) { void Test::createWebPage(QCheckBox* updateAWSCheckBox, QLineEdit* urlLineEdit) { QString testResults = QFileDialog::getOpenFileName(nullptr, "Please select the zipped test results to update from", nullptr, - "Zipped Test Results (*.zip)"); + "Zipped Test Results (TestResults--*.zip)"); if (testResults.isNull()) { return; } From 56483f48849cae173bb6fbf6b266db68d1e959ac Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Wed, 13 Feb 2019 15:18:07 -0800 Subject: [PATCH 11/17] Check that zipped folder name is in correct format. --- tools/nitpick/src/AWSInterface.cpp | 28 +++++++++++++++++++++++----- tools/nitpick/src/AWSInterface.h | 1 + 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/tools/nitpick/src/AWSInterface.cpp b/tools/nitpick/src/AWSInterface.cpp index 59be26c383..8203c41005 100644 --- a/tools/nitpick/src/AWSInterface.cpp +++ b/tools/nitpick/src/AWSInterface.cpp @@ -27,9 +27,29 @@ void AWSInterface::createWebPageFromResults(const QString& testResults, const QString& workingDirectory, QCheckBox* updateAWSCheckBox, QLineEdit* urlLineEdit) { - _testResults = testResults; _workingDirectory = workingDirectory; + // Verify filename is in correct format + // For example `D:/tt/TestResults--2019-02-10_17-30-57(local)[DESKTOP-6BO62Q9].zip` + QStringList parts = testResults.split('/'); + QString zipFilename = parts[parts.length() - 1]; + _zipFolderName = _workingDirectory + "/" + zipFilename.split('.')[0]; + + QStringList zipFolderNameParts = zipFilename.split(QRegExp("[\\(\\)\\[\\]]"), QString::SkipEmptyParts); + bool a = QRegularExpression("TestResults--\\d{4}(-\\d\\d){2}_\\d\\d(-\\d\\d){2}").match(zipFolderNameParts[0]).hasMatch(); + bool b = QRegularExpression("\\w").match(zipFolderNameParts[1]).hasMatch(); + bool c = QRegularExpression("\\w").match(zipFolderNameParts[2]).hasMatch(); + + if (!QRegularExpression("TestResults--\\d{4}(-\\d\\d){2}_\\d\\d(-\\d\\d){2}").match(zipFolderNameParts[0]).hasMatch() || + !QRegularExpression("\\w").match(zipFolderNameParts[1]).hasMatch() || // build (local, build number or PR number) + !QRegularExpression("\\w").match(zipFolderNameParts[2]).hasMatch() // machine name + ) { + QMessageBox::critical(0, "Filename is in wrong format", "'" + zipFilename + "' is not in nitpick format"); + return; + } + + _testResults = testResults; + _urlLineEdit = urlLineEdit; _urlLineEdit->setEnabled(false); @@ -48,10 +68,8 @@ void AWSInterface::extractTestFailuresFromZippedFolder() { // For a test results zip file called `D:/tt/TestResults--2018-10-02_16-54-11(9426)[DESKTOP-PMKNLSQ].zip` // the folder will be called `TestResults--2018-10-02_16-54-11(9426)[DESKTOP-PMKNLSQ]` // and, this folder will be in the working directory - QStringList parts = _testResults.split('/'); - QString zipFolderName = _workingDirectory + "/" + parts[parts.length() - 1].split('.')[0]; - if (QDir(zipFolderName).exists()) { - QDir dir = zipFolderName; + if (QDir(_zipFolderName).exists()) { + QDir dir = _zipFolderName; dir.removeRecursively(); } diff --git a/tools/nitpick/src/AWSInterface.h b/tools/nitpick/src/AWSInterface.h index 63c48580f5..7a06adea41 100644 --- a/tools/nitpick/src/AWSInterface.h +++ b/tools/nitpick/src/AWSInterface.h @@ -49,6 +49,7 @@ public: private: QString _testResults; + QString _zipFolderName; QString _workingDirectory; QString _resultsFolder; QString _htmlFailuresFolder; From 9e002c59d4630510c7c89376519da186b1c8e0b3 Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Wed, 13 Feb 2019 15:24:55 -0800 Subject: [PATCH 12/17] fix pal --- libraries/audio/src/Sound.h | 3 ++- libraries/gpu/src/gpu/Texture.h | 4 ++-- libraries/hfm/src/hfm/HFM.h | 1 + .../src/model-networking/ModelCache.cpp | 2 +- .../src/model-networking/TextureCache.cpp | 9 ++++++++- libraries/networking/src/ResourceCache.cpp | 15 +++++++++------ libraries/networking/src/ResourceCache.h | 3 ++- 7 files changed, 25 insertions(+), 12 deletions(-) diff --git a/libraries/audio/src/Sound.h b/libraries/audio/src/Sound.h index 836e28d582..359b931cd4 100644 --- a/libraries/audio/src/Sound.h +++ b/libraries/audio/src/Sound.h @@ -61,7 +61,8 @@ class Sound : public Resource { public: Sound(const QUrl& url, bool isStereo = false, bool isAmbisonic = false); - + Sound(const Sound& other) : Resource(other), _audioData(other._audioData), _numChannels(other._numChannels) {} + bool isReady() const { return (bool)_audioData; } bool isStereo() const { return _audioData ? _audioData->isStereo() : false; } diff --git a/libraries/gpu/src/gpu/Texture.h b/libraries/gpu/src/gpu/Texture.h index 23bfff6873..517d7158e4 100755 --- a/libraries/gpu/src/gpu/Texture.h +++ b/libraries/gpu/src/gpu/Texture.h @@ -395,8 +395,6 @@ public: bool isDefined() const { return _defined; } Texture(TextureUsageType usageType); - Texture(const Texture& buf); // deep copy of the sysmem texture - Texture& operator=(const Texture& buf); // deep copy of the sysmem texture ~Texture(); Stamp getStamp() const { return _stamp; } @@ -690,8 +688,10 @@ class TextureSource { public: TextureSource(const QUrl& url, int type = 0) : _imageUrl(url), _type(type) {} + void setUrl(const QUrl& url) { _imageUrl = url; } const QUrl& getUrl() const { return _imageUrl; } const gpu::TexturePointer getGPUTexture() const { return _gpuTexture; } + void setType(int type) { _type = type; } int getType() const { return _type; } void resetTexture(gpu::TexturePointer texture); diff --git a/libraries/hfm/src/hfm/HFM.h b/libraries/hfm/src/hfm/HFM.h index cccfaa3f7d..f1b6b4bd68 100644 --- a/libraries/hfm/src/hfm/HFM.h +++ b/libraries/hfm/src/hfm/HFM.h @@ -119,6 +119,7 @@ public: /// A texture map. class Texture { public: + QString id; QString name; QByteArray filename; diff --git a/libraries/model-networking/src/model-networking/ModelCache.cpp b/libraries/model-networking/src/model-networking/ModelCache.cpp index a4eba0c7a9..da4515392b 100644 --- a/libraries/model-networking/src/model-networking/ModelCache.cpp +++ b/libraries/model-networking/src/model-networking/ModelCache.cpp @@ -322,7 +322,7 @@ private: void GeometryDefinitionResource::setExtra(void* extra) { const GeometryExtra* geometryExtra = static_cast(extra); _mapping = geometryExtra ? geometryExtra->mapping : QVariantHash(); - _textureBaseUrl = resolveTextureBaseUrl(_url, geometryExtra ? geometryExtra->textureBaseUrl : QUrl()); + _textureBaseUrl = geometryExtra ? resolveTextureBaseUrl(_url, geometryExtra->textureBaseUrl) : QUrl(); _combineParts = geometryExtra ? geometryExtra->combineParts : true; } diff --git a/libraries/model-networking/src/model-networking/TextureCache.cpp b/libraries/model-networking/src/model-networking/TextureCache.cpp index d4cf7e6ce9..8c075f80fc 100644 --- a/libraries/model-networking/src/model-networking/TextureCache.cpp +++ b/libraries/model-networking/src/model-networking/TextureCache.cpp @@ -335,6 +335,7 @@ int networkTexturePointerMetaTypeId = qRegisterMetaTypetype : image::TextureUsage::DEFAULT_TEXTURE; _maxNumPixels = textureExtra ? textureExtra->maxNumPixels : ABSOLUTE_MAX_TEXTURE_NUM_PIXELS; - _textureSource = std::make_shared(_url, (int)_type); + if (_textureSource) { + _textureSource->setUrl(_url); + _textureSource->setType((int)_type); + } else { + _textureSource = std::make_shared(_url, (int)_type); + } _lowestRequestedMipLevel = 0; auto fileNameLowercase = _url.fileName().toLower(); diff --git a/libraries/networking/src/ResourceCache.cpp b/libraries/networking/src/ResourceCache.cpp index cb7b8c7c82..7345081380 100644 --- a/libraries/networking/src/ResourceCache.cpp +++ b/libraries/networking/src/ResourceCache.cpp @@ -362,7 +362,6 @@ QSharedPointer ResourceCache::getResource(const QUrl& url, const QUrl& resource->moveToThread(qApp->thread()); connect(resource.data(), &Resource::updateSize, this, &ResourceCache::updateTotalSize); resourcesWithExtraHash.insert(extraHash, resource); - removeUnusedResource(resource); resource->ensureLoading(); } } @@ -404,7 +403,7 @@ void ResourceCache::addUnusedResource(const QSharedPointer& resource) // If it doesn't fit or its size is unknown, remove it from the cache. if (resource->getBytes() == 0 || resource->getBytes() > _unusedResourcesMaxSize) { resource->setCache(nullptr); - removeResource(resource->getURL(), resource->getBytes()); + removeResource(resource->getURL(), resource->getExtraHash(), resource->getBytes()); resetTotalResourceCounter(); return; } @@ -443,7 +442,7 @@ void ResourceCache::reserveUnusedResource(qint64 resourceSize) { auto size = it.value()->getBytes(); locker.unlock(); - removeResource(it.value()->getURL(), size); + removeResource(it.value()->getURL(), it.value()->getExtraHash(), size); locker.relock(); _unusedResourcesSize -= size; @@ -489,9 +488,13 @@ void ResourceCache::resetResourceCounters() { emit dirty(); } -void ResourceCache::removeResource(const QUrl& url, qint64 size) { +void ResourceCache::removeResource(const QUrl& url, size_t extraHash, qint64 size) { QWriteLocker locker(&_resourcesLock); - _resources.remove(url); + auto& resources = _resources[url]; + resources.remove(extraHash); + if (resources.size() == 0) { + _resources.remove(url); + } _totalResourcesSize -= size; } @@ -664,7 +667,7 @@ void Resource::allReferencesCleared() { } else { if (_cache) { // remove from the cache - _cache->removeResource(getURL(), getBytes()); + _cache->removeResource(getURL(), getExtraHash(), getBytes()); _cache->resetTotalResourceCounter(); } diff --git a/libraries/networking/src/ResourceCache.h b/libraries/networking/src/ResourceCache.h index 740bdadc48..e47a8836c0 100644 --- a/libraries/networking/src/ResourceCache.h +++ b/libraries/networking/src/ResourceCache.h @@ -271,7 +271,7 @@ private: friend class ScriptableResourceCache; void reserveUnusedResource(qint64 resourceSize); - void removeResource(const QUrl& url, qint64 size = 0); + void removeResource(const QUrl& url, size_t extraHash, qint64 size = 0); void resetTotalResourceCounter(); void resetUnusedResourceCounter(); @@ -418,6 +418,7 @@ public: virtual void setExtra(void* extra) {}; void setExtraHash(size_t extraHash) { _extraHash = extraHash; } + size_t getExtraHash() const { return _extraHash; } signals: /// Fired when the resource begins downloading. From be5f9b211b76b7f43deaa156d1236d629c4a7311 Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Wed, 13 Feb 2019 18:09:06 -0800 Subject: [PATCH 13/17] Add nitpick to production (but not stable) builds --- tools/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 4d7a594d92..b9ae635a4f 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -19,8 +19,8 @@ function(check_test name) endfunction() if (BUILD_TOOLS) - # Allow different tools for production builds - if (RELEASE_TYPE STREQUAL "PRODUCTION") + # Allow different tools for stable builds + if (STABLE_BUILD) set(ALL_TOOLS udt-test vhacd-util From 301b4215e5ece64f8302a548b7be88b76efbc30e Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Wed, 13 Feb 2019 19:13:08 -0800 Subject: [PATCH 14/17] Fixed gcc warning. --- tools/nitpick/src/AWSInterface.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/tools/nitpick/src/AWSInterface.cpp b/tools/nitpick/src/AWSInterface.cpp index 8203c41005..3707bc4a24 100644 --- a/tools/nitpick/src/AWSInterface.cpp +++ b/tools/nitpick/src/AWSInterface.cpp @@ -36,9 +36,6 @@ void AWSInterface::createWebPageFromResults(const QString& testResults, _zipFolderName = _workingDirectory + "/" + zipFilename.split('.')[0]; QStringList zipFolderNameParts = zipFilename.split(QRegExp("[\\(\\)\\[\\]]"), QString::SkipEmptyParts); - bool a = QRegularExpression("TestResults--\\d{4}(-\\d\\d){2}_\\d\\d(-\\d\\d){2}").match(zipFolderNameParts[0]).hasMatch(); - bool b = QRegularExpression("\\w").match(zipFolderNameParts[1]).hasMatch(); - bool c = QRegularExpression("\\w").match(zipFolderNameParts[2]).hasMatch(); if (!QRegularExpression("TestResults--\\d{4}(-\\d\\d){2}_\\d\\d(-\\d\\d){2}").match(zipFolderNameParts[0]).hasMatch() || !QRegularExpression("\\w").match(zipFolderNameParts[1]).hasMatch() || // build (local, build number or PR number) From 58c00781882681453c9fb1756e30734708d68893 Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Wed, 13 Feb 2019 21:07:25 -0800 Subject: [PATCH 15/17] Reversed order of recursive calls. --- tools/nitpick/src/Test.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tools/nitpick/src/Test.cpp b/tools/nitpick/src/Test.cpp index 6647d154af..f80058200e 100644 --- a/tools/nitpick/src/Test.cpp +++ b/tools/nitpick/src/Test.cpp @@ -766,13 +766,19 @@ void Test::createAllRecursiveScripts() { void Test::createAllRecursiveScripts(const QString& directory) { QDirIterator it(directory, QDirIterator::Subdirectories); + QStringList directories; while (it.hasNext()) { QString nextDirectory = it.next(); if (isAValidDirectory(nextDirectory)) { - createAllRecursiveScripts(nextDirectory); - createRecursiveScript(nextDirectory, false); + directories.push_front(nextDirectory); } } + + for (int i = directories.length(); i > 0; --i) { + QString nextDirectory = directories[i]; + createAllRecursiveScripts(nextDirectory); + createRecursiveScript(nextDirectory, false); + } } void Test::createRecursiveScript(const QString& directory, bool interactiveMode) { From 701c18c9eb9d36d9481ab432f4319119646055ec Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Thu, 14 Feb 2019 08:58:09 -0800 Subject: [PATCH 16/17] Correction to recursive scripts. --- tools/nitpick/src/Test.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/tools/nitpick/src/Test.cpp b/tools/nitpick/src/Test.cpp index f80058200e..f1e950db88 100644 --- a/tools/nitpick/src/Test.cpp +++ b/tools/nitpick/src/Test.cpp @@ -766,19 +766,13 @@ void Test::createAllRecursiveScripts() { void Test::createAllRecursiveScripts(const QString& directory) { QDirIterator it(directory, QDirIterator::Subdirectories); - QStringList directories; while (it.hasNext()) { QString nextDirectory = it.next(); if (isAValidDirectory(nextDirectory)) { - directories.push_front(nextDirectory); + createAllRecursiveScripts(nextDirectory); + createRecursiveScript(nextDirectory, false); } } - - for (int i = directories.length(); i > 0; --i) { - QString nextDirectory = directories[i]; - createAllRecursiveScripts(nextDirectory); - createRecursiveScript(nextDirectory, false); - } } void Test::createRecursiveScript(const QString& directory, bool interactiveMode) { @@ -841,11 +835,16 @@ void Test::createRecursiveScript(const QString& directory, bool interactiveMode) << endl; textStream << "Script.include(PATH_TO_THE_REPO_PATH_UTILS_FILE);" << endl << endl; - textStream << "if (typeof nitpick === 'undefined') nitpick = createNitpick(Script.resolvePath(\".\"));" << endl; - textStream << "if (typeof testsRootPath === 'undefined') testsRootPath = nitpick.getTestsRootPath();" << endl << endl; - - textStream << "nitpick.enableRecursive();" << endl; - textStream << "nitpick.enableAuto();" << endl << endl; + // The 'depth' variable is used to signal when to start running the recursive scripts + textStream << "if (typeof depth === 'undefined') {" << endl; + textStream << " depth = 0;" << endl; + textStream << " nitpick = createNitpick(Script.resolvePath(\".\"));" << endl; + textStream << " testsRootPath = nitpick.getTestsRootPath();" << endl << endl; + textStream << " nitpick.enableRecursive();" << endl; + textStream << " nitpick.enableAuto();" << endl; + textStream << "} else {" << endl; + textStream << " depth++" << endl; + textStream << "}" << endl << endl; // Now include the test scripts for (int i = 0; i < directories.length(); ++i) { @@ -853,8 +852,9 @@ void Test::createRecursiveScript(const QString& directory, bool interactiveMode) } textStream << endl; - textStream << "if (typeof runningRecursive === 'undefined') {" << endl; - textStream << " runningRecursive = true;" << endl; + textStream << "if (depth > 0) {" << endl; + textStream << " depth--;" << endl; + textStream << "} else {" << endl; textStream << " nitpick.runRecursive();" << endl; textStream << "}" << endl << endl; From 6752092899d9e407a2ba07b74789d00fd937671d Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Thu, 14 Feb 2019 10:38:19 -0800 Subject: [PATCH 17/17] Removed unnecessary member variable. --- tools/nitpick/src/AWSInterface.cpp | 10 +++++----- tools/nitpick/src/AWSInterface.h | 3 +-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/tools/nitpick/src/AWSInterface.cpp b/tools/nitpick/src/AWSInterface.cpp index 3707bc4a24..63d5af9272 100644 --- a/tools/nitpick/src/AWSInterface.cpp +++ b/tools/nitpick/src/AWSInterface.cpp @@ -33,7 +33,6 @@ void AWSInterface::createWebPageFromResults(const QString& testResults, // For example `D:/tt/TestResults--2019-02-10_17-30-57(local)[DESKTOP-6BO62Q9].zip` QStringList parts = testResults.split('/'); QString zipFilename = parts[parts.length() - 1]; - _zipFolderName = _workingDirectory + "/" + zipFilename.split('.')[0]; QStringList zipFolderNameParts = zipFilename.split(QRegExp("[\\(\\)\\[\\]]"), QString::SkipEmptyParts); @@ -50,7 +49,8 @@ void AWSInterface::createWebPageFromResults(const QString& testResults, _urlLineEdit = urlLineEdit; _urlLineEdit->setEnabled(false); - extractTestFailuresFromZippedFolder(); + QString zipFilenameWithoutExtension = zipFilename.split('.')[0]; + extractTestFailuresFromZippedFolder(_workingDirectory + "/" + zipFilenameWithoutExtension); createHTMLFile(); if (updateAWSCheckBox->isChecked()) { @@ -61,12 +61,12 @@ void AWSInterface::createWebPageFromResults(const QString& testResults, } } -void AWSInterface::extractTestFailuresFromZippedFolder() { +void AWSInterface::extractTestFailuresFromZippedFolder(const QString& folderName) { // For a test results zip file called `D:/tt/TestResults--2018-10-02_16-54-11(9426)[DESKTOP-PMKNLSQ].zip` // the folder will be called `TestResults--2018-10-02_16-54-11(9426)[DESKTOP-PMKNLSQ]` // and, this folder will be in the working directory - if (QDir(_zipFolderName).exists()) { - QDir dir = _zipFolderName; + if (QDir(folderName).exists()) { + QDir dir = folderName; dir.removeRecursively(); } diff --git a/tools/nitpick/src/AWSInterface.h b/tools/nitpick/src/AWSInterface.h index 7a06adea41..d95b8ecf2f 100644 --- a/tools/nitpick/src/AWSInterface.h +++ b/tools/nitpick/src/AWSInterface.h @@ -30,7 +30,7 @@ public: QCheckBox* updateAWSCheckBox, QLineEdit* urlLineEdit); - void extractTestFailuresFromZippedFolder(); + void extractTestFailuresFromZippedFolder(const QString& folderName); void createHTMLFile(); void startHTMLpage(QTextStream& stream); @@ -49,7 +49,6 @@ public: private: QString _testResults; - QString _zipFolderName; QString _workingDirectory; QString _resultsFolder; QString _htmlFailuresFolder;