Browse Source

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

あく 5 years ago
parent
commit
34dbb2ea86
2 changed files with 12 additions and 4 deletions
  1. 9 4
      applications/gui/view.c
  2. 3 0
      applications/gui/view_i.h

+ 9 - 4
applications/gui/view.c

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

+ 3 - 0
applications/gui/view_i.h

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