Desktop: Unload animations before FAP is loaded

This commit is contained in:
Willy-JL
2024-04-05 01:48:01 +01:00
parent edabaf0607
commit 15e578599e
3 changed files with 14 additions and 2 deletions

View File

@@ -33,12 +33,14 @@ static void desktop_loader_callback(const void* message, void* context) {
Desktop* desktop = context;
const LoaderEvent* event = message;
if(event->type == LoaderEventTypeApplicationStarted) {
if(event->type == LoaderEventTypeApplicationBeforeLoad) {
desktop->animation_lock = api_lock_alloc_locked();
view_dispatcher_send_custom_event(desktop->view_dispatcher, DesktopGlobalBeforeAppStarted);
api_lock_wait_unlock_and_free(desktop->animation_lock);
desktop->animation_lock = NULL;
} else if(event->type == LoaderEventTypeApplicationStopped) {
} else if(
event->type == LoaderEventTypeApplicationLoadFailed ||
event->type == LoaderEventTypeApplicationStopped) {
view_dispatcher_send_custom_event(desktop->view_dispatcher, DesktopGlobalAfterAppFinished);
}
}

View File

@@ -409,6 +409,9 @@ static void loader_start_internal_app(
const FlipperInternalApplication* app,
const char* args) {
FURI_LOG_I(TAG, "Starting %s", app->name);
LoaderEvent event;
event.type = LoaderEventTypeApplicationBeforeLoad;
furi_pubsub_publish(loader->pubsub, &event);
// store args
furi_assert(loader->app.args == NULL);
@@ -464,6 +467,9 @@ static LoaderStatus loader_start_external_app(
FuriString* error_message,
FlipperApplicationFlag flags) {
LoaderStatus status = loader_make_success_status(error_message);
LoaderEvent event;
event.type = LoaderEventTypeApplicationBeforeLoad;
furi_pubsub_publish(loader->pubsub, &event);
do {
loader->app.fap = flipper_application_alloc(storage, firmware_api_interface);
@@ -551,6 +557,8 @@ static LoaderStatus loader_start_external_app(
if(status != LoaderStatusOk) {
flipper_application_free(loader->app.fap);
loader->app.fap = NULL;
event.type = LoaderEventTypeApplicationLoadFailed;
furi_pubsub_publish(loader->pubsub, &event);
}
return status;

View File

@@ -18,6 +18,8 @@ typedef enum {
} LoaderStatus;
typedef enum {
LoaderEventTypeApplicationBeforeLoad,
LoaderEventTypeApplicationLoadFailed,
LoaderEventTypeApplicationStarted,
LoaderEventTypeApplicationStopped
} LoaderEventType;