Skip to content

Commit

Permalink
Fix Frozen upon exiting the apps.
Browse files Browse the repository at this point in the history
  • Loading branch information
EstebanFuentealba committed Apr 1, 2024
1 parent fb7dba8 commit 4ee620f
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,30 +135,35 @@ GBCartridge* gb_cartridge_app_app_alloc() {
void gb_cartridge_app_app_free(GBCartridge* app) {
furi_assert(app);

// View Dispatcher
// Views
view_dispatcher_remove_view(app->view_dispatcher, GBCartridgeViewIdMenu);
view_dispatcher_remove_view(app->view_dispatcher, GBCartridgeViewIdScene1);
view_dispatcher_remove_view(app->view_dispatcher, GBCartridgeViewIdScene2);
view_dispatcher_remove_view(app->view_dispatcher, GBCartridgeViewIdScene3);
view_dispatcher_remove_view(app->view_dispatcher, GBCartridgeViewIdScene4);
view_dispatcher_remove_view(app->view_dispatcher, GBCartridgeViewIdScene5);
view_dispatcher_remove_view(app->view_dispatcher, GBCartridgeViewIdSettings);
variable_item_list_free(app->submenu);
view_dispatcher_remove_view(app->view_dispatcher, GBCartridgeViewIdStartscreen);

// storage_file_free(app->file_path);
variable_item_list_free(app->submenu);

// View Dispatcher
view_dispatcher_free(app->view_dispatcher);
// Scene manager
scene_manager_free(app->scene_manager);

app->gui = NULL;
app->notification = NULL;
app->storage = NULL;

//
uart_free(app->uart);
uart_free(app->lp_uart);
// Close File Browser


furi_record_close(RECORD_DIALOGS);
furi_record_close(RECORD_GUI);
furi_record_close(RECORD_STORAGE);
// furi_string_free(app->file_path);

app->gui = NULL;
app->notification = NULL;
app->storage = NULL;

//Remove whatever is left
free(app);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ static void
Uart* uart = (Uart*)context;
UNUSED(handle);

if(event & (FuriHalSerialRxEventData | FuriHalSerialRxEventIdle)) {
if(event == FuriHalSerialRxEventData) {
uint8_t data = furi_hal_serial_async_rx(handle);
furi_stream_buffer_send(uart->rx_stream, &data, 1, 0);
furi_thread_flags_set(furi_thread_get_id(uart->rx_thread), WorkerEvtRxDone);
Expand Down Expand Up @@ -183,12 +183,13 @@ Uart* lp_uart_init(void* app) {
void uart_free(Uart* uart) {
furi_assert(uart);

furi_hal_serial_async_rx_stop(uart->serial_handle);
furi_hal_serial_deinit(uart->serial_handle);
furi_hal_serial_control_release(uart->serial_handle);

furi_thread_flags_set(furi_thread_get_id(uart->rx_thread), WorkerEvtStop);
furi_thread_join(uart->rx_thread);
furi_thread_free(uart->rx_thread);

furi_hal_serial_deinit(uart->serial_handle);
furi_hal_serial_control_release(uart->serial_handle);

free(uart);
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,27 +70,29 @@ GBACartridge* gba_cartridge_app_app_alloc() {

void gba_cartridge_app_app_free(GBACartridge* app) {
furi_assert(app);
// Scene manager
scene_manager_free(app->scene_manager);

// View Dispatcher
// Views
view_dispatcher_remove_view(app->view_dispatcher, GBACartridgeViewIdMenu);
view_dispatcher_remove_view(app->view_dispatcher, GBACartridgeViewIdScene1);
view_dispatcher_remove_view(app->view_dispatcher, GBACartridgeViewIdStartscreen);
variable_item_list_free(app->submenu);

// View Dispatcher
view_dispatcher_free(app->view_dispatcher);
// Scene manager
scene_manager_free(app->scene_manager);

//
uart_free(app->uart);
uart_free(app->lp_uart);

furi_record_close(RECORD_GUI);
furi_record_close(RECORD_STORAGE);
furi_record_close(RECORD_DIALOGS);

app->gui = NULL;
app->notification = NULL;
app->storage = NULL;

//
uart_free(app->uart);
uart_free(app->lp_uart);
// Close File Browser
furi_record_close(RECORD_DIALOGS);
furi_string_free(app->file_path);

//Remove whatever is left
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ static void
Uart* uart = (Uart*)context;
UNUSED(handle);

if(event & (FuriHalSerialRxEventData | FuriHalSerialRxEventIdle)) {
if(event == FuriHalSerialRxEventData) {
uint8_t data = furi_hal_serial_async_rx(handle);
furi_stream_buffer_send(uart->rx_stream, &data, 1, 0);
furi_thread_flags_set(furi_thread_get_id(uart->rx_thread), WorkerEvtRxDone);
Expand Down Expand Up @@ -183,12 +183,13 @@ Uart* lp_uart_init(void* app) {
void uart_free(Uart* uart) {
furi_assert(uart);

furi_hal_serial_async_rx_stop(uart->serial_handle);
furi_hal_serial_deinit(uart->serial_handle);
furi_hal_serial_control_release(uart->serial_handle);

furi_thread_flags_set(furi_thread_get_id(uart->rx_thread), WorkerEvtStop);
furi_thread_join(uart->rx_thread);
furi_thread_free(uart->rx_thread);

furi_hal_serial_deinit(uart->serial_handle);
furi_hal_serial_control_release(uart->serial_handle);

free(uart);
}

0 comments on commit 4ee620f

Please sign in to comment.