mirror of
https://github.com/lvgl/lvgl.git
synced 2026-05-31 07:56:23 +08:00
fix(group): in lv_group_remove() fix if the object to focus is deleted
If in the defocus event of the currently focused object the the next object to focus is deleted there was a crash
This commit is contained in:
+6
-8
@@ -373,6 +373,12 @@ static void focus_next_core(lv_group_t * group, void * (*begin)(const lv_ll_t *)
|
|||||||
bool can_move = true;
|
bool can_move = true;
|
||||||
bool can_begin = true;
|
bool can_begin = true;
|
||||||
|
|
||||||
|
if(group->obj_focus) {
|
||||||
|
lv_res_t res = lv_event_send(*group->obj_focus, LV_EVENT_DEFOCUSED, get_indev(group));
|
||||||
|
if(res != LV_RES_OK) return;
|
||||||
|
lv_obj_invalidate(*group->obj_focus);
|
||||||
|
}
|
||||||
|
|
||||||
for(;;) {
|
for(;;) {
|
||||||
if(obj_next == NULL) {
|
if(obj_next == NULL) {
|
||||||
if(group->wrap || obj_sentinel == NULL) {
|
if(group->wrap || obj_sentinel == NULL) {
|
||||||
@@ -418,14 +424,6 @@ static void focus_next_core(lv_group_t * group, void * (*begin)(const lv_ll_t *)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(obj_next == group->obj_focus) return; /*There's only one visible object and it's already focused*/
|
|
||||||
|
|
||||||
if(group->obj_focus) {
|
|
||||||
lv_res_t res = lv_event_send(*group->obj_focus, LV_EVENT_DEFOCUSED, get_indev(group));
|
|
||||||
if(res != LV_RES_OK) return;
|
|
||||||
lv_obj_invalidate(*group->obj_focus);
|
|
||||||
}
|
|
||||||
|
|
||||||
group->obj_focus = obj_next;
|
group->obj_focus = obj_next;
|
||||||
|
|
||||||
lv_res_t res = lv_event_send(*group->obj_focus, LV_EVENT_FOCUSED, get_indev(group));
|
lv_res_t res = lv_event_send(*group->obj_focus, LV_EVENT_FOCUSED, get_indev(group));
|
||||||
|
|||||||
+22
-5
@@ -417,6 +417,7 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data)
|
|||||||
if(data->key == LV_KEY_ENTER) {
|
if(data->key == LV_KEY_ENTER) {
|
||||||
/*Send the ENTER as a normal KEY*/
|
/*Send the ENTER as a normal KEY*/
|
||||||
lv_group_send_data(g, LV_KEY_ENTER);
|
lv_group_send_data(g, LV_KEY_ENTER);
|
||||||
|
if(indev_reset_check(&i->proc)) return;
|
||||||
|
|
||||||
lv_event_send(indev_obj_act, LV_EVENT_PRESSED, indev_act);
|
lv_event_send(indev_obj_act, LV_EVENT_PRESSED, indev_act);
|
||||||
if(indev_reset_check(&i->proc)) return;
|
if(indev_reset_check(&i->proc)) return;
|
||||||
@@ -424,6 +425,7 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data)
|
|||||||
else if(data->key == LV_KEY_ESC) {
|
else if(data->key == LV_KEY_ESC) {
|
||||||
/*Send the ESC as a normal KEY*/
|
/*Send the ESC as a normal KEY*/
|
||||||
lv_group_send_data(g, LV_KEY_ESC);
|
lv_group_send_data(g, LV_KEY_ESC);
|
||||||
|
if(indev_reset_check(&i->proc)) return;
|
||||||
|
|
||||||
lv_event_send(indev_obj_act, LV_EVENT_CANCEL, indev_act);
|
lv_event_send(indev_obj_act, LV_EVENT_CANCEL, indev_act);
|
||||||
if(indev_reset_check(&i->proc)) return;
|
if(indev_reset_check(&i->proc)) return;
|
||||||
@@ -443,6 +445,7 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data)
|
|||||||
/*Just send other keys to the object (e.g. 'A' or `LV_GROUP_KEY_RIGHT`)*/
|
/*Just send other keys to the object (e.g. 'A' or `LV_GROUP_KEY_RIGHT`)*/
|
||||||
else {
|
else {
|
||||||
lv_group_send_data(g, data->key);
|
lv_group_send_data(g, data->key);
|
||||||
|
if(indev_reset_check(&i->proc)) return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*Pressing*/
|
/*Pressing*/
|
||||||
@@ -579,6 +582,7 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data)
|
|||||||
else if(data->key == LV_KEY_ESC) {
|
else if(data->key == LV_KEY_ESC) {
|
||||||
/*Send the ESC as a normal KEY*/
|
/*Send the ESC as a normal KEY*/
|
||||||
lv_group_send_data(g, LV_KEY_ESC);
|
lv_group_send_data(g, LV_KEY_ESC);
|
||||||
|
if(indev_reset_check(&i->proc)) return;
|
||||||
|
|
||||||
lv_event_send(indev_obj_act, LV_EVENT_CANCEL, indev_act);
|
lv_event_send(indev_obj_act, LV_EVENT_CANCEL, indev_act);
|
||||||
if(indev_reset_check(&i->proc)) return;
|
if(indev_reset_check(&i->proc)) return;
|
||||||
@@ -586,6 +590,7 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data)
|
|||||||
/*Just send other keys to the object (e.g. 'A' or `LV_GROUP_KEY_RIGHT`)*/
|
/*Just send other keys to the object (e.g. 'A' or `LV_GROUP_KEY_RIGHT`)*/
|
||||||
else {
|
else {
|
||||||
lv_group_send_data(g, data->key);
|
lv_group_send_data(g, data->key);
|
||||||
|
if(indev_reset_check(&i->proc)) return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*Pressing*/
|
/*Pressing*/
|
||||||
@@ -676,8 +681,8 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data)
|
|||||||
lv_event_send(indev_obj_act, LV_EVENT_CLICKED, indev_act);
|
lv_event_send(indev_obj_act, LV_EVENT_CLICKED, indev_act);
|
||||||
if(indev_reset_check(&i->proc)) return;
|
if(indev_reset_check(&i->proc)) return;
|
||||||
|
|
||||||
|
|
||||||
lv_group_send_data(g, LV_KEY_ENTER);
|
lv_group_send_data(g, LV_KEY_ENTER);
|
||||||
|
if(indev_reset_check(&i->proc)) return;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
lv_obj_clear_state(indev_obj_act, LV_STATE_PRESSED); /*Remove the pressed state manually*/
|
lv_obj_clear_state(indev_obj_act, LV_STATE_PRESSED); /*Remove the pressed state manually*/
|
||||||
@@ -703,10 +708,16 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data)
|
|||||||
LV_LOG_INFO("rotated by %+d (edit)", data->enc_diff);
|
LV_LOG_INFO("rotated by %+d (edit)", data->enc_diff);
|
||||||
int32_t s;
|
int32_t s;
|
||||||
if(data->enc_diff < 0) {
|
if(data->enc_diff < 0) {
|
||||||
for(s = 0; s < -data->enc_diff; s++) lv_group_send_data(g, LV_KEY_LEFT);
|
for(s = 0; s < -data->enc_diff; s++) {
|
||||||
|
lv_group_send_data(g, LV_KEY_LEFT);
|
||||||
|
if(indev_reset_check(&i->proc)) return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if(data->enc_diff > 0) {
|
else if(data->enc_diff > 0) {
|
||||||
for(s = 0; s < data->enc_diff; s++) lv_group_send_data(g, LV_KEY_RIGHT);
|
for(s = 0; s < data->enc_diff; s++) {
|
||||||
|
lv_group_send_data(g, LV_KEY_RIGHT);
|
||||||
|
if(indev_reset_check(&i->proc)) return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*In navigate mode focus on the next/prev objects*/
|
/*In navigate mode focus on the next/prev objects*/
|
||||||
@@ -714,10 +725,16 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data)
|
|||||||
LV_LOG_INFO("rotated by %+d (nav)", data->enc_diff);
|
LV_LOG_INFO("rotated by %+d (nav)", data->enc_diff);
|
||||||
int32_t s;
|
int32_t s;
|
||||||
if(data->enc_diff < 0) {
|
if(data->enc_diff < 0) {
|
||||||
for(s = 0; s < -data->enc_diff; s++) lv_group_focus_prev(g);
|
for(s = 0; s < -data->enc_diff; s++) {
|
||||||
|
lv_group_focus_prev(g);
|
||||||
|
if(indev_reset_check(&i->proc)) return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if(data->enc_diff > 0) {
|
else if(data->enc_diff > 0) {
|
||||||
for(s = 0; s < data->enc_diff; s++) lv_group_focus_next(g);
|
for(s = 0; s < data->enc_diff; s++) {
|
||||||
|
lv_group_focus_next(g);
|
||||||
|
if(indev_reset_check(&i->proc)) return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user