@@ -20,7 +20,9 @@ int32_t nfc_playlist_emulation_task(void* context) {
2020
2121 view_dispatcher_switch_to_view (nfc_playlist -> view_dispatcher , NfcPlaylistView_Popup );
2222
23- if (file_stream_open (stream , furi_string_get_cstr (nfc_playlist -> settings .playlist_path ), FSAM_READ , FSOM_OPEN_EXISTING )) {
23+ if (nfc_playlist -> settings .playlist_length == 0 ) {
24+ popup_set_header (nfc_playlist -> popup , "The playlist you have\nselected is empty" , 64 , 10 , AlignCenter , AlignTop );
25+ } else if (file_stream_open (stream , furi_string_get_cstr (nfc_playlist -> settings .playlist_path ), FSAM_READ , FSOM_OPEN_EXISTING )) {
2426 EmulationState = NfcPlaylistEmulationState_Emulating ;
2527 int file_position = 0 ;
2628
@@ -105,30 +107,27 @@ int32_t nfc_playlist_emulation_task(void* context) {
105107 nfc_playlist_emulation_worker_clear_nfc_data (nfc_playlist -> nfc_playlist_emulation_worker );
106108 }
107109 }
108- popup_reset (nfc_playlist -> popup );
109- if (nfc_playlist -> settings .playlist_length == 0 ) {
110- popup_set_header (nfc_playlist -> popup , "Empty playlist" , 64 , 10 , AlignCenter , AlignTop );
111- } else {
112- popup_set_header (nfc_playlist -> popup , EmulationState == NfcPlaylistEmulationState_Canceled ? "Emulation stopped" : "Emulation finished" , 64 , 10 , AlignCenter , AlignTop );
113- }
114- popup_set_text (nfc_playlist -> popup , "Press back" , 64 , 50 , AlignCenter , AlignTop );
115110 stop_blink (nfc_playlist );
116111
117- EmulationState = NfcPlaylistEmulationState_Stopped ;
118112 furi_string_free (line );
119113 furi_string_free (tmp_header_str );
120114 furi_string_free (tmp_counter_str );
121115 furi_string_free (tmp_file_name );
122116 furi_string_free (tmp_file_ext );
117+ file_stream_close (stream );
118+
119+ popup_reset (nfc_playlist -> popup );
120+ popup_set_header (nfc_playlist -> popup , EmulationState == NfcPlaylistEmulationState_Canceled ? "Emulation stopped" : "Emulation finished" , 64 , 10 , AlignCenter , AlignTop );
123121 } else {
124122 popup_set_header (nfc_playlist -> popup , "Failed to open playlist" , 64 , 10 , AlignCenter , AlignTop );
125- popup_set_text (nfc_playlist -> popup , "Press back" , 64 , 50 , AlignCenter , AlignTop );
126123 }
124+ popup_set_text (nfc_playlist -> popup , "Press back" , 64 , 50 , AlignCenter , AlignTop );
127125
128- file_stream_close (stream );
129126 furi_record_close (RECORD_STORAGE );
130127 stream_free (stream );
131128
129+ EmulationState = NfcPlaylistEmulationState_Stopped ;
130+
132131 return 0 ;
133132}
134133
0 commit comments