mirror of
https://github.com/lvgl/lvgl.git
synced 2026-05-09 20:27:41 +08:00
chore(gdb): support pre-6d999331d class names without lv_ prefix in wrap_widget
This commit is contained in:
@@ -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)")
|
||||
|
||||
Reference in New Issue
Block a user