Disable object error

Description

Hi!, I’ve some errors when I try to disable object in tile view

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

ESP32 - ESP32S3

What LVGL version are you using?

9.1

What do you want to achieve?

I’ve a tileview and a floating button that display a menu (like INK in LVGL demo)… In a specific tileview page i need to disable this menu.

Actually I’ve tile index and control if is scrolled, etc… and get the active tile index, but when I add or clear flag LV_OBJ_FLAG_HIDDEN for this object, raise an error object is NULL

This menu is independent of tileview, is floating and parent was mainscreen

What have you tried so far?

I’ve tried with that object, objects inside , etc… with no result

Hello,

Do you have the ability to debug your code? From the error it just seems like you are working with a NULL pointer of some sort, try debugging the function where you set LV_OBJ_FLAG_HIDDEN.

Otherwise please share the relevant code here and I’ll take a look.

Kind regards

Yes, I’ve debugged code and raise NULL pointer error.
I’ll try later again and share the relevant code, Thank you

Basically is this the relevant code, I’ve a definition of the object that I’ll hide (it’s a little button bar with options)

  buttonBar = lv_obj_create(mainScreen);
  lv_obj_remove_style_all(buttonBar);
  lv_obj_set_flex_flow(buttonBar, LV_FLEX_FLOW_ROW);
  lv_obj_set_flex_align(buttonBar, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);
  lv_obj_add_flag(buttonBar, LV_OBJ_FLAG_FLOATING);
  lv_obj_set_style_radius(buttonBar, LV_RADIUS_CIRCLE, 0);
  lv_obj_set_style_border_color(buttonBar, lv_color_white(), 0);
  lv_obj_set_style_border_width(buttonBar, 1, 0);
  lv_obj_set_style_border_opa(buttonBar,LV_OPA_20,0);
  lv_obj_set_style_bg_color(buttonBar, lv_color_black(), 0);
  lv_obj_set_style_bg_opa(buttonBar, 250, 0);
  lv_obj_add_flag(buttonBar, LV_OBJ_FLAG_FLOATING);
  lv_obj_set_size(buttonBar, 50 * scaleBut, 50 * scaleBut);
  lv_obj_align(buttonBar, LV_ALIGN_BOTTOM_RIGHT, 0,  -LV_DPX(14) );

In the main screen I’ve an event that get the active tile (the active tile is another object of the main screen)

 lv_obj_add_event_cb(tilesScreen, getActTile, LV_EVENT_SCROLL_END, NULL);
  lv_obj_t *actTile = lv_tileview_get_tile_act(tilesScreen);
  lv_coord_t tileX = lv_obj_get_x(actTile) / TFT_WIDTH;
  activeTile = tileX;  

activeTile is a enum structure with the name of the active Tile

Later I check the active tile if it’s one I need to hide the button bar

    if (activeTile == MAP)
       lv_obj_add_flag(buttonBar,LV_OBJ_FLAG_HIDDEN);
    else
      lv_obj_clear_flag(buttonBar,LV_OBJ_FLAG_HIDDEN);

All this it’s when tile scroll is finished , of course.

When finish scroll to the tile raise this error

[Error]        (14.915, +14915)         lv_obj_add_flag: Asserted at expression: obj != NULL (The object is NULL) lv_obj.c:116

all objects, buttonBar, tileScreen, and mainScreen are globals variables

Solved!,
buttonBar object was static… now it’s works

1 Like