From f500d4b577ca78997512654d664564c17f900a3a Mon Sep 17 00:00:00 2001 From: brodan Date: Tue, 18 Apr 2023 17:27:50 -0400 Subject: [PATCH] fix basic_scenes tutorial cleanup function and update readme accordingly --- plugins/basic_scenes/README.md | 5 ++++- plugins/basic_scenes/basic_scenes.c | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/basic_scenes/README.md b/plugins/basic_scenes/README.md index b680d0b..7fd78d5 100644 --- a/plugins/basic_scenes/README.md +++ b/plugins/basic_scenes/README.md @@ -451,13 +451,16 @@ In the future, you can add more views to the view dispatcher and allocate memory ## Step 21. Create an app_free function. -We will create an app_free function to free memory allocated for our application. This function will free memory allocated for the scene manager, view dispatcher, submenu, widget and text input. +We will create an app_free function to free memory allocated for our application. This function will remove all of the views from the view dispatcher, and then free the memory allocated for the scene manager, view dispatcher, submenu, widget and text input. Add the following lines after the app_alloc function in the basic_scenes.c file: ```c static void app_free(App* app) { furi_assert(app); + view_dispatcher_remove_view(app->view_dispatcher, BasicScenesSubmenuView); + view_dispatcher_remove_view(app->view_dispatcher, BasicScenesWidgetView); + view_dispatcher_remove_view(app->view_dispatcher, BasicScenesTextInputView); scene_manager_free(app->scene_manager); view_dispatcher_free(app->view_dispatcher); submenu_free(app->submenu); diff --git a/plugins/basic_scenes/basic_scenes.c b/plugins/basic_scenes/basic_scenes.c index 504a5be..3ddbf6c 100644 --- a/plugins/basic_scenes/basic_scenes.c +++ b/plugins/basic_scenes/basic_scenes.c @@ -240,6 +240,9 @@ static App* app_alloc() { static void app_free(App* app) { furi_assert(app); + view_dispatcher_remove_view(app->view_dispatcher, BasicScenesSubmenuView); + view_dispatcher_remove_view(app->view_dispatcher, BasicScenesWidgetView); + view_dispatcher_remove_view(app->view_dispatcher, BasicScenesTextInputView); scene_manager_free(app->scene_manager); view_dispatcher_free(app->view_dispatcher); submenu_free(app->submenu); @@ -259,4 +262,4 @@ int32_t basic_scenes_app(void* p) { app_free(app); return 0; -} \ No newline at end of file +}