GUI: fix issue with gui update on view draw (#301)

This commit is contained in:
あく 2021-01-11 15:20:29 +03:00 committed by GitHub
parent 6126d117a9
commit 34dbb2ea86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 4 deletions

View File

@ -93,14 +93,19 @@ void* view_get_model(View* view) {
}
void view_commit_model(View* view) {
furi_assert(view);
view_unlock_model(view);
if(view->dispatcher) {
view_dispatcher_update(view->dispatcher, view);
}
}
void view_unlock_model(View* view) {
furi_assert(view);
if(view->model_type == ViewModelTypeLocking) {
ViewModelLocking* model = (ViewModelLocking*)(view->model);
furi_check(osMutexRelease(model->mutex) == osOK);
}
if(view->dispatcher) {
view_dispatcher_update(view->dispatcher, view);
}
}
void view_draw(View* view, Canvas* canvas) {
@ -108,7 +113,7 @@ void view_draw(View* view, Canvas* canvas) {
if(view->draw_callback) {
void* data = view_get_model(view);
view->draw_callback(canvas, data);
view_commit_model(view);
view_unlock_model(view);
}
}

View File

@ -23,6 +23,9 @@ struct View {
/* Set View dispatcher */
void view_set_dispatcher(View* view, ViewDispatcher* view_dispatcher);
/* Unlock model */
void view_unlock_model(View* view);
/* Draw Callback for View dispatcher */
void view_draw(View* view, Canvas* canvas);