From 7bdd7cf9d6dbf679648dadfc901721f8f847acf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Candice=20Bent=C3=A9jac?= Date: Wed, 15 Feb 2023 17:32:22 +0100 Subject: [PATCH 1/2] [ImageGallery] Initialize and use "attribute" properly for the intrinsics table This commit fixes an "Unable to assign QJSValue to QObject*". In IntrinsicDisplayDelegate, initialize the "attribute" variant to null and set it as a parameter during the instantiation in ImageGallery. All references to "model.display" in IntrinsicDisplayDelegate have been replaced with a correct use of "attribute". --- meshroom/ui/qml/ImageGallery/ImageGallery.qml | 2 +- .../ImageGallery/IntrinsicDisplayDelegate.qml | 20 ++++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/meshroom/ui/qml/ImageGallery/ImageGallery.qml b/meshroom/ui/qml/ImageGallery/ImageGallery.qml index 04eab8b982..680df2b9b3 100644 --- a/meshroom/ui/qml/ImageGallery/ImageGallery.qml +++ b/meshroom/ui/qml/ImageGallery/ImageGallery.qml @@ -514,7 +514,7 @@ Panel { model: intrinsicModel - delegate: IntrinsicDisplayDelegate{} + delegate: IntrinsicDisplayDelegate { attribute: model.display } ScrollBar.horizontal: ScrollBar { id: sb } ScrollBar.vertical : ScrollBar { id: sbv } diff --git a/meshroom/ui/qml/ImageGallery/IntrinsicDisplayDelegate.qml b/meshroom/ui/qml/ImageGallery/IntrinsicDisplayDelegate.qml index bcc320abad..657490af12 100644 --- a/meshroom/ui/qml/ImageGallery/IntrinsicDisplayDelegate.qml +++ b/meshroom/ui/qml/ImageGallery/IntrinsicDisplayDelegate.qml @@ -9,12 +9,12 @@ RowLayout { Layout.fillWidth: true - property variant attribute: model.display + property variant attribute: null property int rowIndex: model.row property int columnIndex: model.column property bool readOnly: false property string toolTipText: { - if(!attribute || Object.keys(attribute).length === 0) + if (!attribute || Object.keys(attribute).length === 0) return "" return attribute.fullLabel } @@ -44,11 +44,11 @@ RowLayout { clip: true Loader { id: loaderComponent - active: !!model.display // convert to bool with "!!" + active: !!attribute // convert to bool with "!!" sourceComponent: { - if(!model.display) + if (!attribute) return undefined - switch(model.display.type) + switch (attribute.type) { case "ChoiceParam": return choice_component case "IntParam": return int_component @@ -65,7 +65,7 @@ RowLayout { Component { id: textField_component TextInput{ - text: model.display.value + text: attribute.value width: intrinsicModel.columnWidths[columnIndex] horizontalAlignment: TextInput.AlignRight color: 'white' @@ -155,7 +155,7 @@ RowLayout { Component { id: float_component TextInput{ - readonly property real formattedValue: model.display.value.toFixed(2) + readonly property real formattedValue: attribute.value.toFixed(2) property string displayValue: String(formattedValue) text: displayValue @@ -179,8 +179,10 @@ RowLayout { //while keeping the trick for formatting the text //Timing issues otherwise onActiveFocusChanged: { - if(activeFocus) text = String(model.display.value) - else text = String(formattedValue) + if (activeFocus) + text = String(attribute.value) + else + text = String(formattedValue) cursorPosition = 0 } From 1576bfd43dfb9b7bd54545f9cd26a9394e776438 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Candice=20Bent=C3=A9jac?= Date: Wed, 15 Feb 2023 18:01:40 +0100 Subject: [PATCH 2/2] [ui] Check that viewpoints still exist before accessing their metadata The metadata value of the viewpoint is meant to be a string, but if the viewpoint attribute has already been removed and does not exist anymore, then the metadata value becomes a PySide property. When trying to access that property, an exception is raised. This commit avoids raising exceptions in that case by checking that the viewpoint attribute still exists (the metadata value is a string instance) before accessing the metadata value. This fixes the "Failed to parse Viewpoint metadata: 'the JSON object must be str, bytes or bytearray, not Property'" warning raised by the exception which occurred every single time there was a switch between cameraInit groups that had been cleared. --- meshroom/ui/reconstruction.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/meshroom/ui/reconstruction.py b/meshroom/ui/reconstruction.py index ee87a710bd..9706732fde 100755 --- a/meshroom/ui/reconstruction.py +++ b/meshroom/ui/reconstruction.py @@ -213,7 +213,8 @@ def _updateInitialParams(self): else: self._initialIntrinsics = self._reconstruction.getIntrinsic(self._viewpoint) try: - self._metadata = json.loads(self._viewpoint.metadata.value) if self._viewpoint.metadata.value else None + # When the viewpoint attribute has already been deleted, metadata.value becomes a PySide property (whereas a string is expected) + self._metadata = json.loads(self._viewpoint.metadata.value) if isinstance(self._viewpoint.metadata.value, str) and self._viewpoint.metadata.value else None except Exception as e: logging.warning("Failed to parse Viewpoint metadata: '{}', '{}'".format(str(e), str(self._viewpoint.metadata.value))) self._metadata = {}