NComboBox: better safe guards

This commit is contained in:
quadbyte 2025-08-13 08:30:52 -04:00
parent a01d730f3d
commit 07b29ee873

View file

@ -69,7 +69,8 @@ ColumnLayout {
font.pointSize: Style.fontSizeMedium * scaling
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
text: (combo.currentIndex < root.optionsLabels.length) ? root.optionsLabels[combo.currentIndex] : "";
text: (combo.currentIndex >= 0
&& combo.currentIndex < root.optionsLabels.length) ? root.optionsLabels[combo.currentIndex] : ""
}
// Drop down indicator
@ -108,7 +109,8 @@ ColumnLayout {
highlighted: combo.highlightedIndex === index
contentItem: NText {
text: (combo.model.indexOf(modelData)< root.optionsLabels.length) ? root.optionsLabels[combo.model.indexOf(modelData)] : ""
text: (combo.model.indexOf(modelData) >= 0 && combo.model.indexOf(
modelData) < root.optionsLabels.length) ? root.optionsLabels[combo.model.indexOf(modelData)] : ""
font.pointSize: Style.fontSizeMedium * scaling
color: highlighted ? Colors.backgroundPrimary : Colors.textPrimary
verticalAlignment: Text.AlignVCenter