Переглянути джерело

Fix Frozen upon exiting the apps.

Esteban Fuentealba 1 рік тому
батько
коміт
6c30d17499
2 змінених файлів з 19 додано та 13 видалено
  1. 14 9
      gb_cartridge_app.c
  2. 5 4
      uart.c

+ 14 - 9
gb_cartridge_app.c

@@ -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);

+ 5 - 4
uart.c

@@ -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);
@@ -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);
 }