mirror of
https://gitlab.com/Theopse/fbi-i18n-zh.git
synced 2025-04-26 03:16:36 +08:00
Fix crash when destroying list UI in update function.
This commit is contained in:
parent
4ce326879a
commit
23111ee08d
@ -90,13 +90,17 @@ static void list_update(ui_view* view, void* data, float bx1, float by1, float b
|
|||||||
|
|
||||||
u32 size = linked_list_size(&listData->items);
|
u32 size = linked_list_size(&listData->items);
|
||||||
|
|
||||||
bool selectedTouched = false;
|
|
||||||
if(size > 0) {
|
|
||||||
list_validate(listData, by1, by2);
|
list_validate(listData, by1, by2);
|
||||||
|
|
||||||
|
bool selectedTouched = false;
|
||||||
|
if(size > 0) {
|
||||||
|
bool scrolls = false;
|
||||||
|
if(listData->selectedItem != NULL) {
|
||||||
float itemWidth;
|
float itemWidth;
|
||||||
screen_get_string_size(&itemWidth, NULL, listData->selectedItem->name, 0.5f, 0.5f);
|
screen_get_string_size(&itemWidth, NULL, listData->selectedItem->name, 0.5f, 0.5f);
|
||||||
if(itemWidth > bx2 - bx1) {
|
if(itemWidth > bx2 - bx1) {
|
||||||
|
scrolls = true;
|
||||||
|
|
||||||
if(listData->selectionScroll == 0 || listData->selectionScroll >= itemWidth - (bx2 - bx1)) {
|
if(listData->selectionScroll == 0 || listData->selectionScroll >= itemWidth - (bx2 - bx1)) {
|
||||||
if(listData->nextSelectionScrollResetTime == 0) {
|
if(listData->nextSelectionScrollResetTime == 0) {
|
||||||
listData->nextSelectionScrollResetTime = osGetTime() + 2000;
|
listData->nextSelectionScrollResetTime = osGetTime() + 2000;
|
||||||
@ -107,7 +111,10 @@ static void list_update(ui_view* view, void* data, float bx1, float by1, float b
|
|||||||
} else {
|
} else {
|
||||||
listData->selectionScroll++;
|
listData->selectionScroll++;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!scrolls) {
|
||||||
listData->selectionScroll = 0;
|
listData->selectionScroll = 0;
|
||||||
listData->nextSelectionScrollResetTime = 0;
|
listData->nextSelectionScrollResetTime = 0;
|
||||||
}
|
}
|
||||||
@ -188,8 +195,6 @@ static void list_update(ui_view* view, void* data, float bx1, float by1, float b
|
|||||||
|
|
||||||
if(listData->update != NULL) {
|
if(listData->update != NULL) {
|
||||||
listData->update(view, listData->data, &listData->items, listData->selectedItem, selectedTouched);
|
listData->update(view, listData->data, &listData->items, listData->selectedItem, selectedTouched);
|
||||||
|
|
||||||
list_validate(listData, by1, by2);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user