Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ui] Intrinsics: Fix warnings and exceptions #1898

Merged
merged 2 commits into from
Feb 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion meshroom/ui/qml/ImageGallery/ImageGallery.qml
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ Panel {

model: intrinsicModel

delegate: IntrinsicDisplayDelegate{}
delegate: IntrinsicDisplayDelegate { attribute: model.display }

ScrollBar.horizontal: ScrollBar { id: sb }
ScrollBar.vertical : ScrollBar { id: sbv }
Expand Down
20 changes: 11 additions & 9 deletions meshroom/ui/qml/ImageGallery/IntrinsicDisplayDelegate.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand All @@ -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'
Expand Down Expand Up @@ -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
Expand All @@ -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
}

Expand Down
3 changes: 2 additions & 1 deletion meshroom/ui/reconstruction.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand Down