[lvgl] Fix crash when using lvgl.list.add (#19177)

This commit is contained in:
Clyde Stubbs
2026-09-13 06:12:08 +10:00
committed by GitHub
parent ebb9037ea1
commit 533002c41e
2 changed files with 19 additions and 1 deletions
@@ -227,6 +227,7 @@ LIST_ID_SCHEMA = cv.Schema({cv.Required(CONF_ID): cv.use_id(lv_list_t)})
)
async def list_add_text_to_code(config, action_id, template_arg, args):
widgets = await get_widgets(config)
await _wait_list_triggers_completed()
async def do_add_text(w: Widget):
text = await lv_text.process(config[CONF_TEXT])
@@ -370,6 +371,7 @@ async def list_add_to_code(config, action_id, template_arg, args):
_register_lv_uses(w_type_name, w_conf)
_register_dynamic_widget_style_uses(w_conf)
widgets = await get_widgets(config)
await _wait_list_triggers_completed()
async def do_add(w: Widget):
index = None
@@ -503,6 +505,7 @@ LIST_REMOVE_SCHEMA = LIST_ID_SCHEMA.extend(
)
async def list_remove_to_code(config, action_id, template_arg, args):
widgets = await get_widgets(config)
await _wait_list_triggers_completed()
async def do_remove(w: Widget):
index = await lv_int.process(config[CONF_INDEX])
@@ -536,6 +539,7 @@ async def list_remove_to_code(config, action_id, template_arg, args):
)
async def list_clear_to_code(config, action_id, template_arg, args):
widgets = await get_widgets(config)
await _wait_list_triggers_completed()
async def do_clear(w: Widget):
await _wait_list_triggers_completed()
+15 -1
View File
@@ -30,6 +30,18 @@ binary_sensor:
widget: button_button
state: pressed
globals:
- id: counter
type: int
script:
- id: add_row
then:
- lvgl.list.add:
id: test_list_id
label:
text: row
lvgl:
id: lvgl_id
rotation: 90
@@ -1291,7 +1303,7 @@ lvgl:
then:
- logger.log:
format: "table selected row %u col %u"
args: [row, column]
args: [(unsigned)row, (unsigned)column]
on_click:
then:
- lvgl.table.cell.update:
@@ -1347,10 +1359,12 @@ lvgl:
- logger.log:
format: "list entry added at %d"
args: [list_index]
- lambda: "id(counter)++;"
on_remove:
- logger.log:
format: "list entry removed at %d"
args: [list_index]
- lambda: "id(counter)--;"
on_click:
- lvgl.list.add_text:
id: test_list_id