From 6cff1b80a80a16a7dcdcad64c89a2fefe0627b46 Mon Sep 17 00:00:00 2001 From: Benign X <1341398182@qq.com> Date: Tue, 21 Apr 2026 14:06:08 +0800 Subject: [PATCH] chore(gdb): support pre-6d999331d class names without lv_ prefix in wrap_widget --- scripts/gdb/lvglgdb/lvgl/widgets/__init__.py | 5 ++++- scripts/gdb/scripts/generators/gen_widget_wrappers.py | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/gdb/lvglgdb/lvgl/widgets/__init__.py b/scripts/gdb/lvglgdb/lvgl/widgets/__init__.py index 1320d00c14..c222f03ec8 100644 --- a/scripts/gdb/lvglgdb/lvgl/widgets/__init__.py +++ b/scripts/gdb/lvglgdb/lvgl/widgets/__init__.py @@ -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) diff --git a/scripts/gdb/scripts/generators/gen_widget_wrappers.py b/scripts/gdb/scripts/generators/gen_widget_wrappers.py index e23759a512..7682eba726 100644 --- a/scripts/gdb/scripts/generators/gen_widget_wrappers.py +++ b/scripts/gdb/scripts/generators/gen_widget_wrappers.py @@ -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)")