Skip to content

Commit

Permalink
chore: bump up and remove several deprecated functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex4386 committed Nov 29, 2024
1 parent 0e05046 commit ccf67e5
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
dist/*
.vscode
.clang-format
.clangd
.editorconfig
.env
.ufbt
4 changes: 2 additions & 2 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ int main() {

view_dispatcher_run(app->view_dispatcher);

FURI_LOG_I("DemoApp", "Exiting application.");
FURI_LOG_I(APP_NAME, "Exiting application.");
free_scenes(app);

FURI_LOG_I("DemoApp", "Freed app.");
FURI_LOG_I(APP_NAME, "Freed app.");

return 0;
}
Expand Down
2 changes: 2 additions & 0 deletions src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include <gui/view_dispatcher.h>
#include "scenes/import.h"

#define APP_NAME "DemoApp"

typedef struct App {
SceneManager* scene_manager;
ViewDispatcher* view_dispatcher;
Expand Down
21 changes: 12 additions & 9 deletions src/scenes/register.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ void register_scenes(App* app) {
app->allocated_scenes = (void**)malloc(sizeof(void*) * AppSceneNum);
}

view_dispatcher_enable_queue(app->view_dispatcher);
// No longer required:
// - see https://developer.flipper.net/flipperzero/doxygen/deprecated.html
//
// view_dispatcher_enable_queue(app->view_dispatcher);

view_dispatcher_set_event_callback_context(app->view_dispatcher, app);
view_dispatcher_set_custom_event_callback(app->view_dispatcher, scene_handler_event_forwarder);
Expand All @@ -66,36 +69,36 @@ void register_scenes(App* app) {
* Free all scenes.
*/
void free_scenes(App* app) {
FURI_LOG_I("DemoApp", "Freeing scenes.");
FURI_LOG_I(APP_NAME, "Freeing scenes.");
furi_assert(app != NULL, "App is NULL.");
void* tmp;
#define SCENE_ACTION(scene) \
if(app->allocated_scenes != NULL) { \
tmp = app->allocated_scenes[scene]; \
app->allocated_scenes[scene] = NULL; \
FURI_LOG_I("DemoApp", "Freeing scene " STRINGIFY(scene) "."); \
FURI_LOG_I(APP_NAME, "Freeing scene " STRINGIFY(scene) "."); \
if(tmp != NULL) scene##_free(tmp); \
FURI_LOG_I("DemoApp", "Free'd scene " STRINGIFY(scene) "."); \
FURI_LOG_I(APP_NAME, "Free'd scene " STRINGIFY(scene) "."); \
} \
if(app->view_dispatcher != NULL) view_dispatcher_remove_view(app->view_dispatcher, scene); \
FURI_LOG_I("DemoApp", "Removed from dispatcher " STRINGIFY(scene) ".");
FURI_LOG_I(APP_NAME, "Removed from dispatcher " STRINGIFY(scene) ".");

#include "list.h"
#undef SCENE_ACTION

FURI_LOG_I("DemoApp", "Freeing allocated scenes.");
FURI_LOG_I(APP_NAME, "Freeing allocated scenes.");
furi_assert(app->allocated_scenes != NULL, "Allocated scenes is NULL.");
free(app->allocated_scenes);
app->allocated_scenes = NULL;

FURI_LOG_I("DemoApp", "Freeing View dispatcher.");
FURI_LOG_I(APP_NAME, "Freeing View dispatcher.");
furi_assert(app->view_dispatcher != NULL, "View dispatcher is NULL.");
view_dispatcher_free(app->view_dispatcher);

FURI_LOG_I("DemoApp", "Freeing SceneManager");
FURI_LOG_I(APP_NAME, "Freeing SceneManager");
furi_assert(app->scene_manager != NULL, "Scene manager is NULL.");
scene_manager_free(app->scene_manager);

FURI_LOG_I("DemoApp", "Freeing App");
FURI_LOG_I(APP_NAME, "Freeing App");
free(app);
}

0 comments on commit ccf67e5

Please sign in to comment.