Skip to content

Commit bd2b892

Browse files
authored
Merge pull request #2655 from alicevision/fix/crashIntrinsics
[ImageGallery] Intrinsics table: Always fully instantiate the model before populating it
2 parents 1f42ad3 + 7c9a869 commit bd2b892

File tree

2 files changed

+25
-9
lines changed

2 files changed

+25
-9
lines changed

meshroom/ui/qml/ImageGallery/ImageGallery.qml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import QtQuick
22
import QtQuick.Controls
33
import QtQuick.Layouts
44
import QtQml.Models
5-
import Qt.labs.qmlmodels 1.0
5+
import Qt.labs.qmlmodels
66

77
import Controls 1.0
88
import MaterialIcons 2.2
@@ -75,6 +75,11 @@ Panel {
7575
}
7676

7777
function populate_model() {
78+
if (!intrinsicModel.ready) {
79+
// If the TableModel is not done being instantiated, do nothing
80+
return
81+
}
82+
7883
intrinsicModel.clear()
7984
for (var intr in parsedIntrinsic) {
8085
intrinsicModel.appendRow(parsedIntrinsic[intr])
@@ -552,8 +557,10 @@ Panel {
552557
anchors.fill: parent
553558
boundsMovement : Flickable.StopAtBounds
554559

555-
//Provide width for column
556-
//Note no size provided for the last column (bool comp) so it uses its automated size
560+
palette: root.palette
561+
562+
// Provide width for column
563+
// Note no size provided for the last column (bool comp) so it uses its automated size
557564
columnWidthProvider: function (column) { return intrinsicModel.columnWidths[column] }
558565

559566
model: intrinsicModel
@@ -569,6 +576,8 @@ Panel {
569576

570577
TableModel {
571578
id : intrinsicModel
579+
property bool ready: false
580+
572581
// Hardcoded default width per column
573582
property var columnWidths: [105, 75, 75, 75, 60, 60, 60, 60, 200, 60, 60, 60]
574583
property var columnNames: [
@@ -599,6 +608,13 @@ Panel {
599608
TableModelColumn { display: function(modelIndex){return parsedIntrinsic[modelIndex.row][intrinsicModel.columnNames[10]]} }
600609
TableModelColumn { display: function(modelIndex){return parsedIntrinsic[modelIndex.row][intrinsicModel.columnNames[11]]} }
601610
//https://doc.qt.io/qt-5/qml-qt-labs-qmlmodels-tablemodel.html#appendRow-method
611+
612+
Component.onCompleted: {
613+
ready = true
614+
// Triggers "populate_model" in case the intrinsics have been filled while the model was
615+
// being instantiated
616+
root.populate_model()
617+
}
602618
}
603619

604620
//CODE FOR HEADERS

meshroom/ui/qml/ImageGallery/IntrinsicDisplayDelegate.qml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ RowLayout {
6767
width: intrinsicModel.columnWidths[columnIndex]
6868
horizontalAlignment: TextInput.AlignRight
6969
readOnly: root.readOnly
70-
color: 'white'
70+
color: palette.text
7171

7272
padding: 12
7373

7474
selectByMouse: true
75-
selectionColor: 'white'
75+
selectionColor: palette.text
7676
selectedTextColor: Qt.darker(palette.window, 1.1)
7777

7878
onEditingFinished: _reconstruction.setAttribute(attribute, text)
@@ -93,13 +93,13 @@ RowLayout {
9393
text: model.display.value
9494
width: intrinsicModel.columnWidths[columnIndex]
9595
horizontalAlignment: TextInput.AlignRight
96-
color: 'white'
96+
color: palette.text
9797
readOnly: root.readOnly
9898

9999
padding: 12
100100

101101
selectByMouse: true
102-
selectionColor: 'white'
102+
selectionColor: palette.text
103103
selectedTextColor: Qt.darker(palette.window, 1.1)
104104

105105
IntValidator {
@@ -164,11 +164,11 @@ RowLayout {
164164
width: intrinsicModel.columnWidths[columnIndex]
165165
horizontalAlignment: TextInput.AlignRight
166166

167-
color: 'white'
167+
color: palette.text
168168
padding: 12
169169

170170
selectByMouse: true
171-
selectionColor: 'white'
171+
selectionColor: palette.text
172172
selectedTextColor: Qt.darker(palette.window, 1.1)
173173

174174
readOnly: root.readOnly

0 commit comments

Comments
 (0)