Not use the lv_obj_is_valid() in ui_theme_manager.c

What do you want to achieve?


this API is not safe, see:

lv_obj_is_valid is not safe to use this way. It can happen that a widgget wwas freed and on it’s exact memory address an other
widget was allocateed.
lv_obj_is_valid will say that it’s valid, but it’s still not the widget thit you wanted.

and Alternative solutions for the implementation of lv_obj_is_valid() · Issue #6395 · lvgl/lvgl · GitHub

this API is very easy lead to crash, so I manually deleted this, like:
image

What have you tried so far?

Screenshot or video

Others

  • SquareLine Studio version:
  • Operating system:
  • Target hardware:

We know about the post you linked, the current limitation of LVGL about checking validity of objects, and the possibility that a new object very rarely (according to LVGL authors) takes the memory-location of the old one. That’s why we use NULL-checking beside lv_obj_is_valid(). By removing lv_obj_is_valid() you just lose an extra check I think. But thanks for pointing it out that there’s a new pointer auto-nullifying function just added to LVGL which is to circumvent this object-validity check discrepancy in the future.

Discussion on the replacement of this API

1 Like

Find my latest thoughts about this here: