Hi,
I am working on an application, in which there is a parent screen on top of that I am creating other popup screens (by taking the parent as “lv_scr_act()” ) on an event. Then I am trying to delete the pop-up screen by a button click event on the pop-up, my application is crashing irregularly at _lv_event_mark_deleted. Can you please help me to figure out what might be the reason for the crashes?
Base screen:
lv_obj_t *g_main_screen;
lv_obj_t* get_main_screen_without_borders(void)
{
g_main_screen = lv_obj_create(lv_scr_act());
lv_obj_center(g_main_screen);
lv_obj_set_size(g_main_screen, DISP_MAX_HORIZONTAL_RESOLUTION, DISP_MAX_VERTICAL_RESOLUTION);
lv_obj_set_style_bg_color(g_main_screen, lv_color_black(), LV_PART_MAIN);
lv_obj_set_style_border_color(g_main_screen, lv_color_hex(0x000000), LV_PART_MAIN);
lv_obj_clear_flag(g_main_screen, LV_OBJ_FLAG_SCROLLABLE);
return g_main_screen;
}
Primary Screen (or Application screen):
lv_obj_t *app_scrn = get_main_screen_without_borders();
lv_obj_clear_flag(app_scrn , LV_OBJ_FLAG_GESTURE_BUBBLE);
lv_obj_add_event_cb(app_scrn , app_scrn_swipe_gesture_cb, LV_EVENT_GESTURE, NULL);
Secondary Screen (Pop-up screen):
static lv_obj_t *pop_up_obj ;
static void message_screen(const char *data);
static void dismiss_event_cb(lv_event_t * e)
{
char *my_data = (char *)e->user_data;
if(code == LV_EVENT_CLICKED)
{
lv_obj_del(pop_up_obj);
message_screen(my_data);
}
}
void pop_up_screen (void)
{
static char u_data[9];
pop_up_obj = lv_obj_create(lv_scr_act());
lv_obj_set_size(pop_up_obj , DISP_MAX_HORIZONTAL_RESOLUTION, DISP_MAX_VERTICAL_RESOLUTION);
lv_obj_align(pop_up_obj , LV_ALIGN_CENTER, 0, 0);
lv_obj_set_style_bg_color(pop_up_obj , lv_color_black(), LV_PART_MAIN);
lv_obj_set_style_bg_opa(pop_up_obj , LV_OPA_100, LV_PART_MAIN);
lv_obj_set_style_radius(pop_up_obj , LV_RADIUS_CIRCLE, 0);
lv_obj_clear_flag(pop_up_obj , LV_OBJ_FLAG_SCROLLABLE);
lv_obj_set_style_border_width(pop_up_obj , 0, LV_PART_MAIN);
lv_obj_t *dismiss_button = lv_label_create(pop_up_obj);
lv_label_set_text(dismiss_button, "Dismiss");
lv_obj_align(dismiss_button, LV_ALIGN_TOP_MID, -60, 284);
lv_obj_set_style_text_color(dismiss_button,lv_color_hex(0x9f9f9f),LV_PART_MAIN);
lv_obj_set_style_text_font(dismiss_button, &barlow_mediumItalic_44, LV_PART_MAIN);
lv_obj_add_flag(dismiss_button, LV_OBJ_FLAG_CLICKABLE);
lv_obj_add_event_cb(dismiss_button, dismiss_event_cb, LV_EVENT_CLICKED, &u_data);
lv_obj_set_ext_click_area(dismiss_button, 20);
}
static void auto_delete_scrn_timer_cb(lv_timer_t *timer)
{
lv_obj_del(pop_up_obj);
}
static void message_screen(const char *data)
{
pop_up_obj = lv_obj_create(lv_scr_act());
lv_obj_set_size(pop_up_obj , DISP_MAX_HORIZONTAL_RESOLUTION, DISP_MAX_VERTICAL_RESOLUTION);
lv_obj_align(pop_up_obj , LV_ALIGN_CENTER, 0, 0);
lv_obj_set_style_bg_color(pop_up_obj , lv_color_black(), LV_PART_MAIN);
lv_obj_set_style_bg_opa(pop_up_obj , LV_OPA_100, LV_PART_MAIN);
lv_obj_set_style_radius(pop_up_obj , LV_RADIUS_CIRCLE, 0);
lv_obj_clear_flag(pop_up_obj , LV_OBJ_FLAG_SCROLLABLE);
lv_obj_set_style_border_width(pop_up_obj , 0, LV_PART_MAIN);
lv_obj_t * message_label= lv_label_create(pop_up_obj);
lv_label_set_text_fmt(message_label,"%s", data);
lv_obj_align(message_label, LV_ALIGN_TOP_MID, 5, 151);
lv_obj_set_style_text_font(message_label, &barlow_bold_58, LV_PART_MAIN);
lv_obj_set_style_text_color(message_label,lv_color_hex(0xffffff),LV_PART_MAIN);
lv_timer_t *auto_delete_scrn_timer = lv_timer_create(auto_delete_scrn_timer_cb, 900, NULL);
lv_timer_set_repeat_count(auto_delete_scrn_timer , 1);
}
Please, look into my above code implementation, and help on the same.
Kind Regards,
Amaresh