@@ -90,6 +90,10 @@ static ret_t combo_box_on_destroy(widget_t* widget) {
9090 idle_remove (combo_box -> init_popup_button_idle_id );
9191 }
9292
93+ if (combo_box -> index_to_value_idle_id != TK_INVALID_ID ) {
94+ idle_remove (combo_box -> index_to_value_idle_id );
95+ }
96+
9397 str_reset (& (combo_box -> text ));
9498 combo_box_reset_options (widget );
9599 TKMEM_FREE (combo_box -> open_window );
@@ -311,14 +315,38 @@ ret_t combo_box_parse_options(widget_t* widget, const char* str) {
311315 return RET_OK ;
312316}
313317
318+ static ret_t combo_box_on_idle_sync_index_to_value (const idle_info_t * idle ) {
319+ widget_t * widget = NULL ;
320+ combo_box_t * combo_box = NULL ;
321+ return_value_if_fail (idle != NULL , RET_BAD_PARAMS );
322+
323+ widget = WIDGET (idle -> ctx );
324+ combo_box = COMBO_BOX (widget );
325+ ENSURE (combo_box );
326+
327+ combo_box_sync_index_to_value (widget , combo_box -> selected_index , FALSE);
328+ combo_box -> index_to_value_idle_id = TK_INVALID_ID ;
329+
330+ return RET_OK ;
331+ }
332+
333+ static ret_t combo_box_idle_sync_index_to_value (widget_t * widget ) {
334+ combo_box_t * combo_box = COMBO_BOX (widget );
335+ ENSURE (combo_box );
336+ if (!combo_box -> index_to_value_idle_id ) {
337+ combo_box -> index_to_value_idle_id = idle_add (combo_box_on_idle_sync_index_to_value , widget );
338+ }
339+ return RET_OK ;
340+ }
341+
314342ret_t combo_box_set_options (widget_t * widget , const char * options ) {
315343 ret_t ret = RET_FAIL ;
316344 combo_box_t * combo_box = COMBO_BOX (widget );
317345 return_value_if_fail (combo_box != NULL , RET_BAD_PARAMS );
318346
319347 ret = combo_box_parse_options (widget , options );
320348 if (!widget -> loading ) {
321- ret = combo_box_sync_index_to_value (widget , combo_box -> selected_index , FALSE );
349+ combo_box_idle_sync_index_to_value (widget );
322350 }
323351
324352 return ret ;
0 commit comments