mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-21 06:53:01 +08:00
Merge pull request #811 from amirgon/master
Prevent crash when lv_init is called more than once.
This commit is contained in:
commit
e2c0e58af9
@ -49,6 +49,8 @@ static lv_res_t lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param);
|
|||||||
* STATIC VARIABLES
|
* STATIC VARIABLES
|
||||||
**********************/
|
**********************/
|
||||||
|
|
||||||
|
static bool _lv_initialized = false;
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* MACROS
|
* MACROS
|
||||||
**********************/
|
**********************/
|
||||||
@ -62,6 +64,10 @@ static lv_res_t lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param);
|
|||||||
*/
|
*/
|
||||||
void lv_init(void)
|
void lv_init(void)
|
||||||
{
|
{
|
||||||
|
/* Do nothing if already initialized */
|
||||||
|
if (_lv_initialized)
|
||||||
|
return;
|
||||||
|
|
||||||
LV_GC_ROOT(_lv_def_scr) = NULL;
|
LV_GC_ROOT(_lv_def_scr) = NULL;
|
||||||
LV_GC_ROOT(_lv_act_scr) = NULL;
|
LV_GC_ROOT(_lv_act_scr) = NULL;
|
||||||
LV_GC_ROOT(_lv_top_layer) = NULL;
|
LV_GC_ROOT(_lv_top_layer) = NULL;
|
||||||
@ -111,7 +117,7 @@ void lv_init(void)
|
|||||||
lv_indev_init();
|
lv_indev_init();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
_lv_initialized = true;
|
||||||
LV_LOG_INFO("lv_init ready");
|
LV_LOG_INFO("lv_init ready");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user