indev encoder: fix when an object is deleted in the event function
This commit is contained in:
@@ -510,12 +510,21 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data)
|
||||
i->proc.types.keypad.last_state = LV_INDEV_STATE_REL; /*To skip the processing of release*/
|
||||
}
|
||||
|
||||
/* Save the last keys before anything else.
|
||||
* They need to be already saved if the the function returns for any reason*/
|
||||
lv_indev_state_t last_state = i->proc.types.keypad.last_state;
|
||||
uint32_t last_key = i->proc.types.keypad.last_key;
|
||||
i->proc.types.keypad.last_state = data->state;
|
||||
i->proc.types.keypad.last_key = data->key;
|
||||
|
||||
lv_group_t * g = i->group;
|
||||
if(g == NULL) return;
|
||||
|
||||
lv_obj_t * focused = lv_group_get_focused(g);
|
||||
if(focused == NULL) return;
|
||||
|
||||
|
||||
|
||||
/*Process the steps first. They are valid only with released button*/
|
||||
if(data->state == LV_INDEV_STATE_REL) {
|
||||
/*In edit mode send LEFT/RIGHT keys*/
|
||||
@@ -543,7 +552,7 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data)
|
||||
if(focused == NULL) return;
|
||||
|
||||
/*Button press happened*/
|
||||
if(data->state == LV_INDEV_STATE_PR && i->proc.types.keypad.last_state == LV_INDEV_STATE_REL) {
|
||||
if(data->state == LV_INDEV_STATE_PR && last_state == LV_INDEV_STATE_REL) {
|
||||
bool editable = false;
|
||||
focused->signal_cb(focused, LV_SIGNAL_GET_EDITABLE, &editable);
|
||||
|
||||
@@ -558,7 +567,7 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data)
|
||||
}
|
||||
/*Pressing*/
|
||||
else if(data->state == LV_INDEV_STATE_PR &&
|
||||
i->proc.types.keypad.last_state == LV_INDEV_STATE_PR) {
|
||||
last_state == LV_INDEV_STATE_PR) {
|
||||
if(i->proc.long_pr_sent == 0 &&
|
||||
lv_tick_elaps(i->proc.pr_timestamp) > i->driver.long_press_time) {
|
||||
bool editable = false;
|
||||
@@ -585,7 +594,7 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data)
|
||||
}
|
||||
/*Release happened*/
|
||||
else if(data->state == LV_INDEV_STATE_REL &&
|
||||
i->proc.types.keypad.last_state == LV_INDEV_STATE_PR) {
|
||||
last_state == LV_INDEV_STATE_PR) {
|
||||
|
||||
bool editable = false;
|
||||
focused->signal_cb(focused, LV_SIGNAL_GET_EDITABLE, &editable);
|
||||
@@ -633,8 +642,6 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data)
|
||||
i->proc.long_pr_sent = 0;
|
||||
}
|
||||
|
||||
i->proc.types.keypad.last_state = data->state;
|
||||
i->proc.types.keypad.last_key = data->key;
|
||||
#else
|
||||
(void)data; /*Unused*/
|
||||
(void)i; /*Unused*/
|
||||
|
||||
Reference in New Issue
Block a user