What do you want to achieve?
I have a message box that pops up when a warning needs to be shown to the user. The vast majority of the time when I click the Okay button it closes but sometime I get the following error:
[Warn] (8274.980, +180) lv_obj_get_disp: No screen found (in lv_obj_tree.c line #286)
The message box does not close and if I keep clicking on the Okay button, I keep getting this error.
My message box code looks like:
/**
* @brief Displays a warning popup to the user.
*
* @param msg The warning message to be displayed.
*/
void ShowWarningMessageBox( const char *msg )
{
static const char * btns[] ={ "Okay", "" };
_warningMessageBox = lv_msgbox_create( NULL, "Warning", msg, btns, false );
lv_obj_add_event_cb( _warningMessageBox, OnWarningMessageBoxCloseEventHandler, LV_EVENT_VALUE_CHANGED, NULL );
lv_obj_set_style_bg_color( _warningMessageBox, lv_palette_main( LV_PALETTE_BLUE_GREY ), LV_PART_MAIN );
lv_obj_set_style_text_font( _warningMessageBox, &ui_font_Robinson32, LV_PART_MAIN );
lv_obj_t *btn = lv_msgbox_get_btns( _warningMessageBox );
const lv_font_t *font = lv_obj_get_style_text_font( btn, LV_PART_ITEMS );
lv_coord_t btn_h = lv_font_get_line_height( font ) + 130 / 10;
lv_obj_set_size( btn, 2/*2 buttons*/ * ( 2 * 130 / 3 ), btn_h );
lv_obj_set_width( _warningMessageBox, 500 );
lv_obj_set_height( _warningMessageBox, 200 );
lv_obj_center( _warningMessageBox );
}
/**
* @brief The callback when the user clicks Okay on the message box.
*
* This event handler is used to clear the message box from the screen.
*
* @param e The button that was clicked on the message box.
*/
static void OnWarningMessageBoxCloseEventHandler( lv_event_t * e )
{
lv_obj_t * obj = lv_event_get_current_target( e );
lv_msgbox_close( _warningMessageBox );
}
Any thoughts on what I might be doing wrong?
What have you tried so far?
N/A
Screenshot or video
N/A
Others
-
SquareLine Studio version:
1.0.5 -
Operating system:
Windows 10 x64 -
Target hardware:
Raspberry Pi 4