chore(gdb): support pre-6d999331d class names without lv_ prefix in wrap_widget

This commit is contained in:
Benign X
2026-04-21 14:06:08 +08:00
committed by VIFEX
parent 031bae6b2c
commit 6cff1b80a8
2 changed files with 8 additions and 2 deletions
+4 -1
View File
@@ -87,7 +87,10 @@ import gdb
def wrap_widget(obj):
"""Wrap an LVObject into its widget class if known."""
cls = WIDGET_REGISTRY.get(obj.class_name)
name = obj.class_name
# Before 6d999331d (Feb 2025), LVGL class names had no 'lv_' prefix
# (e.g. 'label' instead of 'lv_label'). Try both for compatibility.
cls = WIDGET_REGISTRY.get(name) or WIDGET_REGISTRY.get('lv_' + name)
if cls:
try:
return cls(obj)
@@ -381,7 +381,10 @@ def gen_init(ordered: list[WidgetDef]) -> str:
lines.append("")
lines.append("def wrap_widget(obj):")
lines.append(' """Wrap an LVObject into its widget class if known."""')
lines.append(" cls = WIDGET_REGISTRY.get(obj.class_name)")
lines.append(" name = obj.class_name")
lines.append(" # Before 6d999331d (Feb 2025), LVGL class names had no 'lv_' prefix")
lines.append(" # (e.g. 'label' instead of 'lv_label'). Try both for compatibility.")
lines.append(" cls = WIDGET_REGISTRY.get(name) or WIDGET_REGISTRY.get('lv_' + name)")
lines.append(" if cls:")
lines.append(" try:")
lines.append(" return cls(obj)")