Desktop: fix crash caused by unconsumed back button short press (#974)

This commit is contained in:
あく 2022-01-30 19:45:08 +03:00 committed by GitHub
parent 2b2a798407
commit 3cdb59805e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 20 deletions

View File

@ -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) {
main_view->callback(DesktopMainEventOpenMenu, main_view->context); if(event->key == InputKeyOk) {
} else if(event->key == InputKeyDown && event->type == InputTypeLong) { main_view->callback(DesktopMainEventOpenMenu, main_view->context);
main_view->callback(DesktopMainEventOpenDebug, main_view->context); } else if(event->key == InputKeyUp) {
} 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) {
} else if(event->key == InputKeyDown && event->type == InputTypeShort) { main_view->callback(DesktopMainEventOpenArchive, main_view->context);
main_view->callback(DesktopMainEventOpenArchive, main_view->context); } else if(event->key == InputKeyLeft) {
} else if(event->key == InputKeyLeft && event->type == InputTypeShort) { main_view->callback(DesktopMainEventOpenFavorite, main_view->context);
main_view->callback(DesktopMainEventOpenFavorite, main_view->context); } else if(event->key == InputKeyRight) {
} else if(event->key == InputKeyRight && event->type == InputTypeShort) { main_view->callback(DesktopMainEventRightShort, main_view->context);
main_view->callback(DesktopMainEventRightShort, main_view->context); }
} else if(event->key == InputKeyBack && event->type == InputTypeShort) { } else if(event->type == InputTypeLong) {
consumed = true; if(event->key == InputKeyDown) {
main_view->callback(DesktopMainEventOpenDebug, main_view->context);
}
} }
return consumed; return true;
} }
DesktopMainView* desktop_main_alloc() { DesktopMainView* desktop_main_alloc() {

View File

@ -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);