Desktop: fix crash caused by unconsumed back button short press (#974)
This commit is contained in:
parent
2b2a798407
commit
3cdb59805e
@ -35,25 +35,26 @@ bool desktop_main_input(InputEvent* event, void* context) {
|
|||||||
furi_assert(context);
|
furi_assert(context);
|
||||||
|
|
||||||
DesktopMainView* main_view = context;
|
DesktopMainView* main_view = context;
|
||||||
bool consumed = false;
|
|
||||||
|
|
||||||
if(event->key == InputKeyOk && event->type == InputTypeShort) {
|
if(event->type == InputTypeShort) {
|
||||||
|
if(event->key == InputKeyOk) {
|
||||||
main_view->callback(DesktopMainEventOpenMenu, main_view->context);
|
main_view->callback(DesktopMainEventOpenMenu, main_view->context);
|
||||||
} else if(event->key == InputKeyDown && event->type == InputTypeLong) {
|
} else if(event->key == InputKeyUp) {
|
||||||
main_view->callback(DesktopMainEventOpenDebug, main_view->context);
|
|
||||||
} else if(event->key == InputKeyUp && event->type == InputTypeShort) {
|
|
||||||
main_view->callback(DesktopMainEventOpenLockMenu, main_view->context);
|
main_view->callback(DesktopMainEventOpenLockMenu, main_view->context);
|
||||||
} else if(event->key == InputKeyDown && event->type == InputTypeShort) {
|
} else if(event->key == InputKeyDown) {
|
||||||
main_view->callback(DesktopMainEventOpenArchive, main_view->context);
|
main_view->callback(DesktopMainEventOpenArchive, main_view->context);
|
||||||
} else if(event->key == InputKeyLeft && event->type == InputTypeShort) {
|
} else if(event->key == InputKeyLeft) {
|
||||||
main_view->callback(DesktopMainEventOpenFavorite, main_view->context);
|
main_view->callback(DesktopMainEventOpenFavorite, main_view->context);
|
||||||
} else if(event->key == InputKeyRight && event->type == InputTypeShort) {
|
} else if(event->key == InputKeyRight) {
|
||||||
main_view->callback(DesktopMainEventRightShort, main_view->context);
|
main_view->callback(DesktopMainEventRightShort, main_view->context);
|
||||||
} else if(event->key == InputKeyBack && event->type == InputTypeShort) {
|
}
|
||||||
consumed = true;
|
} else if(event->type == InputTypeLong) {
|
||||||
|
if(event->key == InputKeyDown) {
|
||||||
|
main_view->callback(DesktopMainEventOpenDebug, main_view->context);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return consumed;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
DesktopMainView* desktop_main_alloc() {
|
DesktopMainView* desktop_main_alloc() {
|
||||||
|
@ -105,13 +105,14 @@ static bool view_stack_input(InputEvent* event, void* context) {
|
|||||||
furi_assert(event);
|
furi_assert(event);
|
||||||
furi_assert(context);
|
furi_assert(context);
|
||||||
|
|
||||||
bool consumed = false;
|
|
||||||
ViewStack* view_stack = context;
|
ViewStack* view_stack = context;
|
||||||
|
|
||||||
|
bool consumed = false;
|
||||||
ViewStackModel* model = view_get_model(view_stack->view);
|
ViewStackModel* model = view_get_model(view_stack->view);
|
||||||
for(int i = MAX_VIEWS - 1; !consumed && (i >= 0); --i) {
|
for(int i = MAX_VIEWS - 1; i >= 0; i--) {
|
||||||
if(model->views[i]) {
|
if(model->views[i] && view_input(model->views[i], event)) {
|
||||||
consumed = view_input(model->views[i], event);
|
consumed = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
view_commit_model(view_stack->view, false);
|
view_commit_model(view_stack->view, false);
|
||||||
|
Loading…
Reference in New Issue
Block a user