From e9859e07f519b6008198d2c29fda1bb1969865e6 Mon Sep 17 00:00:00 2001 From: Ly-sec Date: Sat, 13 Dec 2025 10:03:29 +0100 Subject: [PATCH] NSearchableComboBox: add debouncing and visibility check to prevent CPU spikes --- Widgets/NSearchableComboBox.qml | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Widgets/NSearchableComboBox.qml b/Widgets/NSearchableComboBox.qml index c0c230842..80e0ca096 100644 --- a/Widgets/NSearchableComboBox.qml +++ b/Widgets/NSearchableComboBox.qml @@ -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(); } }