mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2025-10-30 08:01:01 +00:00
Fix selectionbox crash when out of range
This commit is contained in:
parent
f010caeb4b
commit
2b5dea60b0
2 changed files with 10 additions and 7 deletions
|
|
@ -18,16 +18,15 @@ bool djui_panel_is_active(void) {
|
|||
}
|
||||
|
||||
struct DjuiBase* djui_panel_find_first_interactable(struct DjuiBaseChild* child) {
|
||||
struct DjuiBaseChild *i = child;
|
||||
while (i) {
|
||||
if (i->base->interactable && i->base->interactable->enabled) {
|
||||
return i->base;
|
||||
while (child) {
|
||||
if (child->base->interactable && child->base->interactable->enabled) {
|
||||
return child->base;
|
||||
}
|
||||
struct DjuiBase* check = djui_panel_find_first_interactable(i->base->child);
|
||||
struct DjuiBase* check = djui_panel_find_first_interactable(child->base->child);
|
||||
if (check) { return check; }
|
||||
i = i->next;
|
||||
child = child->next;
|
||||
}
|
||||
|
||||
|
||||
// If we didn't find anything at all. Return NULL.
|
||||
LOG_ERROR("Failed to find a interactable for child %p.", child);
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -76,6 +76,10 @@ struct DjuiSelectionbox* djui_selectionbox_create(struct DjuiBase* parent, const
|
|||
struct DjuiSelectionbox* selectionbox = calloc(1, sizeof(struct DjuiSelectionbox));
|
||||
struct DjuiBase* base = &selectionbox->base;
|
||||
|
||||
if (*value >= choiceCount) {
|
||||
*value = choiceCount - 1;
|
||||
}
|
||||
|
||||
selectionbox->value = value;
|
||||
selectionbox->choices = calloc(choiceCount, sizeof(char*));
|
||||
for (int i = 0; i < choiceCount; i++) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue