Skip to content

Commit bfd76ea

Browse files
authored
Merge pull request #6 from Brodan/main
fix basic_scenes tutorial cleanup function and update readme accordingly.
2 parents d71c9ee + f500d4b commit bfd76ea

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

plugins/basic_scenes/README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -451,13 +451,16 @@ In the future, you can add more views to the view dispatcher and allocate memory
451451

452452
## Step 21. Create an app_free function.
453453

454-
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.
454+
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.
455455

456456
Add the following lines after the app_alloc function in the basic_scenes.c file:
457457

458458
```c
459459
static void app_free(App* app) {
460460
furi_assert(app);
461+
view_dispatcher_remove_view(app->view_dispatcher, BasicScenesSubmenuView);
462+
view_dispatcher_remove_view(app->view_dispatcher, BasicScenesWidgetView);
463+
view_dispatcher_remove_view(app->view_dispatcher, BasicScenesTextInputView);
461464
scene_manager_free(app->scene_manager);
462465
view_dispatcher_free(app->view_dispatcher);
463466
submenu_free(app->submenu);

plugins/basic_scenes/basic_scenes.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,9 @@ static App* app_alloc() {
240240

241241
static void app_free(App* app) {
242242
furi_assert(app);
243+
view_dispatcher_remove_view(app->view_dispatcher, BasicScenesSubmenuView);
244+
view_dispatcher_remove_view(app->view_dispatcher, BasicScenesWidgetView);
245+
view_dispatcher_remove_view(app->view_dispatcher, BasicScenesTextInputView);
243246
scene_manager_free(app->scene_manager);
244247
view_dispatcher_free(app->view_dispatcher);
245248
submenu_free(app->submenu);
@@ -259,4 +262,4 @@ int32_t basic_scenes_app(void* p) {
259262

260263
app_free(app);
261264
return 0;
262-
}
265+
}

0 commit comments

Comments
 (0)