From e4f8d39041fb38f653270f87d9d0a0a2ad9cd348 Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Sat, 1 Jul 2023 16:12:49 +0200 Subject: [PATCH] Shared code for loader gui error --- applications/services/loader/loader.c | 30 +++++++-------------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/applications/services/loader/loader.c b/applications/services/loader/loader.c index 35809c104..f8fe9f699 100644 --- a/applications/services/loader/loader.c +++ b/applications/services/loader/loader.c @@ -32,10 +32,7 @@ LoaderStatus return result.value; } -LoaderStatus loader_start_with_gui_error(Loader* loader, const char* name, const char* args) { - FuriString* error_message = furi_string_alloc(); - LoaderStatus status = loader_start(loader, name, args, error_message); - +static void loader_show_gui_error(LoaderStatus status, FuriString* error_message) { // TODO: we have many places where we can emit a double start, ex: desktop, menu // so i prefer to not show LoaderStatusErrorAppStarted error message for now if(status == LoaderStatusErrorUnknownApp || status == LoaderStatusErrorInternal) { @@ -52,7 +49,12 @@ LoaderStatus loader_start_with_gui_error(Loader* loader, const char* name, const dialog_message_free(message); furi_record_close(RECORD_DIALOGS); } +} +LoaderStatus loader_start_with_gui_error(Loader* loader, const char* name, const char* args) { + FuriString* error_message = furi_string_alloc(); + LoaderStatus status = loader_start(loader, name, args, error_message); + loader_show_gui_error(status, error_message); furi_string_free(error_message); return status; } @@ -582,25 +584,7 @@ int32_t loader_srv(void* p) { FuriString* error_message = furi_string_alloc(); LoaderStatus status = loader_do_start_by_name( loader, message.start.name, message.start.args, error_message); - if(status == LoaderStatusErrorUnknownApp || status == LoaderStatusErrorInternal) { - DialogsApp* dialogs = furi_record_open(RECORD_DIALOGS); - DialogMessage* message = dialog_message_alloc(); - dialog_message_set_header(message, "Error", 64, 0, AlignCenter, AlignTop); - dialog_message_set_buttons(message, NULL, NULL, NULL); - - furi_string_replace(error_message, ":", "\n"); - dialog_message_set_text( - message, - furi_string_get_cstr(error_message), - 64, - 32, - AlignCenter, - AlignCenter); - - dialog_message_show(dialogs, message); - dialog_message_free(message); - furi_record_close(RECORD_DIALOGS); - } + loader_show_gui_error(status, error_message); furi_string_free(error_message); break; }