diff --git a/applications/main/archive/archive.c b/applications/main/archive/archive.c index 7746e2dfe..640bd3072 100644 --- a/applications/main/archive/archive.c +++ b/applications/main/archive/archive.c @@ -70,10 +70,15 @@ void archive_free(ArchiveApp* archive) { scene_manager_set_scene_state(archive->scene_manager, ArchiveAppSceneInfo, false); scene_manager_set_scene_state(archive->scene_manager, ArchiveAppSceneSearch, false); - if(archive->thread) { - furi_thread_join(archive->thread); - furi_thread_free(archive->thread); - archive->thread = NULL; + if(archive->info_thread) { + furi_thread_join(archive->info_thread); + furi_thread_free(archive->info_thread); + archive->info_thread = NULL; + } + if(archive->search_thread) { + furi_thread_join(archive->search_thread); + furi_thread_free(archive->search_thread); + archive->search_thread = NULL; } if(archive->browser->disk_image) { diff --git a/applications/main/archive/archive_i.h b/applications/main/archive/archive_i.h index 9b9371f8d..3fdcbe613 100644 --- a/applications/main/archive/archive_i.h +++ b/applications/main/archive/archive_i.h @@ -45,7 +45,8 @@ struct ArchiveApp { WidgetElement* size_element; WidgetElement* count_element; - FuriThread* thread; + FuriThread* info_thread; + FuriThread* search_thread; }; void archive_show_loading_popup(ArchiveApp* context, bool show); diff --git a/applications/main/archive/helpers/archive_browser.c b/applications/main/archive/helpers/archive_browser.c index c3000b178..09e68c82c 100644 --- a/applications/main/archive/helpers/archive_browser.c +++ b/applications/main/archive/helpers/archive_browser.c @@ -534,10 +534,10 @@ void archive_switch_tab(ArchiveBrowserView* browser, InputKey key) { with_view_model( browser->view, ArchiveBrowserViewModel * model, { archive = model->archive; }, false); scene_manager_set_scene_state(archive->scene_manager, ArchiveAppSceneSearch, false); - if(archive->thread) { - furi_thread_join(archive->thread); - furi_thread_free(archive->thread); - archive->thread = NULL; + if(archive->search_thread) { + furi_thread_join(archive->search_thread); + furi_thread_free(archive->search_thread); + archive->search_thread = NULL; } } diff --git a/applications/main/archive/scenes/archive_scene_browser.c b/applications/main/archive/scenes/archive_scene_browser.c index 862dfa306..093132059 100644 --- a/applications/main/archive/scenes/archive_scene_browser.c +++ b/applications/main/archive/scenes/archive_scene_browser.c @@ -425,10 +425,10 @@ bool archive_scene_browser_on_event(void* context, SceneManagerEvent event) { bool open = !scene_manager_get_scene_state(archive->scene_manager, ArchiveAppSceneSearch); scene_manager_set_scene_state(archive->scene_manager, ArchiveAppSceneSearch, false); - if(archive->thread) { - furi_thread_join(archive->thread); - furi_thread_free(archive->thread); - archive->thread = NULL; + if(archive->search_thread) { + furi_thread_join(archive->search_thread); + furi_thread_free(archive->search_thread); + archive->search_thread = NULL; } if(open) scene_manager_next_scene(archive->scene_manager, ArchiveAppSceneSearch); consumed = true; diff --git a/applications/main/archive/scenes/archive_scene_info.c b/applications/main/archive/scenes/archive_scene_info.c index 53b529995..5ed844b2a 100644 --- a/applications/main/archive/scenes/archive_scene_info.c +++ b/applications/main/archive/scenes/archive_scene_info.c @@ -216,12 +216,12 @@ void archive_scene_info_on_enter(void* context) { view_dispatcher_switch_to_view(instance->view_dispatcher, ArchiveViewWidget); scene_manager_set_scene_state(instance->scene_manager, ArchiveAppSceneInfo, true); - instance->thread = furi_thread_alloc_ex( + instance->info_thread = furi_thread_alloc_ex( "ArchiveInfoWorker", 1024, (FuriThreadCallback)(is_dir ? archive_scene_info_dirwalk : archive_scene_info_md5sum), instance); - furi_thread_start(instance->thread); + furi_thread_start(instance->info_thread); } bool archive_scene_info_on_event(void* context, SceneManagerEvent event) { @@ -240,10 +240,10 @@ void archive_scene_info_on_exit(void* context) { ArchiveApp* app = (ArchiveApp*)context; scene_manager_set_scene_state(app->scene_manager, ArchiveAppSceneInfo, false); - if(app->thread) { - furi_thread_join(app->thread); - furi_thread_free(app->thread); - app->thread = NULL; + if(app->info_thread) { + furi_thread_join(app->info_thread); + furi_thread_free(app->info_thread); + app->info_thread = NULL; } widget_reset(app->widget); } diff --git a/applications/main/archive/scenes/archive_scene_search.c b/applications/main/archive/scenes/archive_scene_search.c index 637bee39e..71f528ab1 100644 --- a/applications/main/archive/scenes/archive_scene_search.c +++ b/applications/main/archive/scenes/archive_scene_search.c @@ -98,15 +98,13 @@ bool archive_scene_search_on_event(void* context, SceneManagerEvent event) { archive_add_app_item(archive->browser, "/app:search/Cancel search"); archive_set_item_count(archive->browser, 1); - // Thread here is fine because only the info pane uses it too, - // but only for directories, which are ignored for search scene_manager_set_scene_state(archive->scene_manager, ArchiveAppSceneSearch, true); - archive->thread = furi_thread_alloc_ex( - "ArchiveSearchDirWalk", + archive->search_thread = furi_thread_alloc_ex( + "ArchiveSearchWorker", 1024, (FuriThreadCallback)archive_scene_search_dirwalk, archive); - furi_thread_start(archive->thread); + furi_thread_start(archive->search_thread); scene_manager_previous_scene(archive->scene_manager); consumed = true;