Description
Hi team,
When I click on the list, after few clicks it is showing NULL Pointer Error.
What MCU/Processor/Board and compiler are you using?
ARM
What do you experience?
I am using lists(Version 7) for my screen. After few clicks on list buttons, I am getting the following error:
Error: lv_obj_get_ext_attr (lv_obj.c #3174 lv_obj_get_ext_attr())
Error: NULL pointer (0x00000000) (lv_debug.c #127 lv_debug_log_error())
What do you expect?
I want to get the text of that list button whenever I click on that particular one.
Code to reproduce
/*********************
* INCLUDES
*********************/
#include "../../lv_examples.h"
#include <stdio.h>
#if LV_USE_IOTGIZMO
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* STATIC PROTOTYPES
**********************/
static void event_handler(lv_obj_t * obj, lv_event_t event);
/**********************
* STATIC VARIABLES
**********************/
lv_obj_t * button;
#if LV_IOTGIZMO_WALLPAPER
LV_IMG_DECLARE(white_bg)
#endif
/**********************
* MACROS
**********************/
/**********************
* GLOBAL FUNCTIONS
**********************/
void iotgizmo_dimmer_list(void)
{
#if LV_IOTGIZMO_WALLPAPER
lv_obj_t * wp = lv_img_create(lv_scr_act(), NULL);
lv_img_set_src(wp, &white_bg);
lv_obj_set_click(wp, true);
#endif
//line
static lv_point_t line_points[] = {{0,0},{480,0}};
/*Create style*/
static lv_style_t style_line;
lv_style_init(&style_line);
lv_style_set_line_width(&style_line, LV_STATE_DEFAULT, 2);
lv_style_set_line_color(&style_line, LV_STATE_DEFAULT, LV_COLOR_GRAY);
lv_style_set_line_rounded(&style_line, LV_STATE_DEFAULT, true);
lv_obj_t * label1;
label1 = lv_label_create(lv_scr_act(), NULL);
lv_label_set_recolor(label1, true);
lv_label_set_text(label1, "#FFFFFF Device List");
lv_obj_set_width(label1, 150);
lv_obj_align(label1, NULL, LV_ALIGN_IN_TOP_MID, 0, 30);
//line object
lv_obj_t * line1;
line1 = lv_line_create(lv_scr_act(), NULL);
lv_line_set_points(line1, line_points, 2);
lv_obj_add_style(line1, LV_LINE_PART_MAIN, &style_line);
lv_obj_align(line1, label1, LV_ALIGN_OUT_BOTTOM_MID, 0, 20);
//page
lv_obj_t * page = lv_page_create(lv_scr_act(), NULL);
lv_obj_set_size(page, 480, 780);
lv_obj_align(page, NULL, LV_ALIGN_OUT_BOTTOM_MID, 0, 20);
//list
lv_obj_t * list1 = lv_list_create(lv_scr_act(), NULL);
lv_obj_set_size(list1, 480, 780);
lv_list_set_scroll_propagation(list1, true);
lv_obj_set_width(list1, lv_page_get_width_fit(page));
lv_obj_set_height(list1, lv_page_get_height_fit(page));
lv_obj_align(list1, line1, LV_ALIGN_OUT_BOTTOM_MID, 0, 20);
button = lv_list_add_btn(list1, LV_SYMBOL_FILE, "aa4c34");
lv_obj_set_event_cb(button, event_handler);
button = lv_list_add_btn(list1, LV_SYMBOL_DIRECTORY, "22f66c");
lv_obj_set_event_cb(button, event_handler);
button = lv_list_add_btn(list1, LV_SYMBOL_CLOSE, "232cbc");
lv_obj_set_event_cb(button, event_handler);
button = lv_list_add_btn(list1, LV_SYMBOL_EDIT, "22fea0");
lv_obj_set_event_cb(button, event_handler);
button = lv_list_add_btn(list1, LV_SYMBOL_SAVE, "aa4d18");
lv_obj_set_event_cb(button, event_handler);
button = lv_list_add_btn(list1, LV_SYMBOL_BELL, "2408c4");
lv_obj_set_event_cb(button, event_handler);
}
/**********************
* STATIC FUNCTIONS
**********************/
static void event_handler(lv_obj_t * obj, lv_event_t event)
{
if(event == LV_EVENT_CLICKED) {
printf("Clicked: %s\n", lv_list_get_btn_text(obj));
}
}
#endif
Screenshot and/or video
If possible, add screenshots and/or videos about the current issue.