Skip to content

Commit 45c5ff2

Browse files
committed
[ui] GraphEditor: check node is valid
Only count valid nodes
1 parent a91a31e commit 45c5ff2

File tree

1 file changed

+33
-11
lines changed

1 file changed

+33
-11
lines changed

meshroom/ui/qml/GraphEditor/GraphEditor.qml

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -559,11 +559,17 @@ Item {
559559
//canSubmitOrCompute: return int n : 0 >= n <= 3 | n=0 cannot submit or compute | n=1 can compute | n=2 can submit | n=3 can compute & submit
560560
property int canSubmitOrCompute: currentNode != null && uigraph.graph.canSubmitOrCompute(currentNode)
561561
property bool isComputed: {
562+
var count = 0
562563
for (var i = 0; i < uigraph.selectedNodes.count; ++i) {
563-
if (!uigraph.selectedNodes.at(i).isComputed)
564+
var node = uigraph.selectedNodes.at(i)
565+
if(!node) {
566+
continue
567+
}
568+
if (!node.isComputed)
564569
return false
570+
count += 1
565571
}
566-
return uigraph.selectedNodes.count > 0
572+
return count > 0
567573
}
568574
width: 220
569575
onClosed: currentNode = null
@@ -573,27 +579,36 @@ Item {
573579
property bool recompute: false
574580
text: nodeMenu.isComputed ? "Recompute" : "Compute"
575581
visible: {
582+
var count = 0
576583
for (var i = 0; i < uigraph.selectedNodes.count; ++i) {
577-
if (!uigraph.selectedNodes.at(i).isComputable)
584+
var node = uigraph.selectedNodes.at(i)
585+
if(!node) {
586+
continue
587+
}
588+
if (!node.isComputable)
578589
return false
590+
count += 1
579591
}
580-
return uigraph.selectedNodes.count > 0
592+
return count > 0
581593
}
582594
height: visible ? implicitHeight : 0
583595

584596
enabled: {
585597
var canCompute = false
586598
for (var i = 0; i < uigraph.selectedNodes.count; ++i) {
587-
if (uigraph.graph.canComputeTopologically(uigraph.selectedNodes.at(i))) {
599+
var node = uigraph.selectedNodes.at(i)
600+
if(!node) {
601+
continue
602+
}
603+
if (uigraph.graph.canComputeTopologically(node)) {
588604
if (nodeMenu.isComputed) {
589605
canCompute = true
590-
} else if (uigraph.graph.canSubmitOrCompute(uigraph.selectedNodes.at(i)) % 2 == 1) {
606+
} else if (uigraph.graph.canSubmitOrCompute(node) % 2 == 1) {
591607
canCompute = true
592608
}
593609
}
594610
}
595611
return canCompute //canSubmit if canSubmitOrCompute == 1(can compute) or 3(can compute & submit)
596-
597612
}
598613

599614
onTriggered: {
@@ -610,21 +625,28 @@ Item {
610625
property bool resubmit: false
611626
text: nodeMenu.isComputed ? "Re-Submit" : "Submit"
612627
visible: {
628+
var count = 0
613629
for (var i = 0; i < uigraph.selectedNodes.count; ++i) {
614-
if (!uigraph.selectedNodes.at(i).isComputable)
630+
var node = uigraph.selectedNodes.at(i)
631+
if (node && !node.isComputable)
615632
return false
633+
count += 1
616634
}
617-
return uigraph.selectedNodes.count > 0 || uigraph.canSubmit
635+
return count > 0 || uigraph.canSubmit
618636
}
619637
height: visible ? implicitHeight : 0
620638

621639
enabled: {
622640
var canSubmit = false
623641
for (var i = 0; i < uigraph.selectedNodes.count; ++i) {
624-
if (uigraph.graph.canComputeTopologically(uigraph.selectedNodes.at(i))) {
642+
var node = uigraph.selectedNodes.at(i)
643+
if(!node) {
644+
continue
645+
}
646+
if (uigraph.graph.canComputeTopologically(node)) {
625647
if (nodeMenu.isComputed) {
626648
canSubmit = true
627-
} else if (uigraph.graph.canSubmitOrCompute(uigraph.selectedNodes.at(i)) > 1) {
649+
} else if (uigraph.graph.canSubmitOrCompute(node) > 1) {
628650
canSubmit = true
629651
}
630652
}

0 commit comments

Comments
 (0)