How can I check the status of obj after using lv_obj_del

Important: unclear posts may not receive useful answers.

Before posting

  • Get familiar with Markdown to format and structure your post
  • Be sure to update lvgl from the latest version from the master branch.
  • Be sure you have checked the FAQ and read the relevant part of the documentation.
  • If applicable use the Simulator to eliminate hardware related issues.

Delete this section if you read and applied the mentioned points.

Description

What MCU/Processor/Board and compiler are you using?

STM32

What LVGL version are you using?

8.3.6

What do you want to achieve?

for example
lv_obj_clean(parent of A) ; When using the function that changes the text of A on another screen after use, the error was handled by checking the existence of A by looking at A.class_p.

However, lv_obj_clean(parent of B); After using lv_arc_set_range(B, 0, value) and then using lv_arc_set_value(B, gauge_value), B.class_p automatically creates lv_label_class and no error occurred.

I am asking a question because I wonder if the existence of obj is judged by class_p.

Is there any way to check if obj exists?

What have you tried so far?

I’ve tried lv_obj_del & lv_obj_clean.

Code to reproduce

Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.

The code block(s) should be formatted like:

void create()
{
   parent_B = lv_obj_create(ui_Screen1);
   parent_A = lv_obj_create(ui_Screen1);

    A = lv_label_create(parent_A );
    B= lv_arc_create(parent_B );
}
void clean()
{
   lv_obj_clean(parent_B);
   lv_obj_clean(parent_A);
}
void check()
{
   if(A->class_p != 0) // A.class_p == 0;
   if(B->class_p != 0) // B.class_p == 0x80c5128 <lv_label_class>
}
Briefly, I used the code like this.

Screenshot and/or video

If possible, add screenshots and/or videos about the current state.

If a widget is deleted all lv_obj_t *s pointing to that widget will point to an invalid memory address. So after deleting an object be sure to NULL its lv_obj_t *s.

After that you can use if(A != NULL) {...}

1 Like

Thank you always for your kindness.

It seems that I am using the method you gave me by finding it in another topic.
However, I have found out that my problem occurs elsewhere and am fixing it. :disappointed_relieved: