NSearchableComboBox: add debouncing and visibility check to prevent CPU spikes

This commit is contained in:
Ly-sec
2025-12-13 10:03:29 +01:00
parent 0e3b8d298f
commit e9859e07f5
+13 -3
View File
@@ -93,15 +93,25 @@ RowLayout {
}
}
onSearchTextChanged: filterModel()
onModelChanged: filterModel()
// Debounce timer to prevent excessive filterModel calls
Timer {
id: filterDebouncer
interval: 16 // ~60fps
repeat: false
onTriggered: filterModel()
}
onSearchTextChanged: filterDebouncer.restart()
onModelChanged: filterDebouncer.restart()
Component.onCompleted: filterModel()
// Watch for model content changes (e.g., async font loading)
// Only when component is actually visible to avoid wasting CPU
Connections {
target: root.model
enabled: root.visible && root.opacity > 0
function onCountChanged() {
filterModel();
filterDebouncer.restart();
}
}