Merge pull request #6 from Brodan/main

fix basic_scenes tutorial cleanup function and update readme accordingly.
This commit is contained in:
Derek Jamison 2023-04-18 17:57:18 -04:00 committed by GitHub
commit bfd76eac24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

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

View File

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