1
mirror of https://github.com/DarkFlippers/unleashed-firmware.git synced 2025-12-12 12:42:30 +04:00

[FL-3775] Archive: fix condition race on exit (#3659)

* Archive: fix condition race on exit

* Format sources and remove debug logging

---------

Co-authored-by: hedger <hedger@users.noreply.github.com>
This commit is contained in:
あく
2024-05-22 18:35:59 +01:00
committed by GitHub
parent 11070c9e5e
commit 8ba938cec1
3 changed files with 16 additions and 12 deletions

View File

@@ -16,6 +16,7 @@ ArchiveApp* archive_alloc(void) {
ArchiveApp* archive = malloc(sizeof(ArchiveApp));
archive->gui = furi_record_open(RECORD_GUI);
archive->loader = furi_record_open(RECORD_LOADER);
archive->text_input = text_input_alloc();
archive->fav_move_str = furi_string_alloc();
@@ -61,6 +62,8 @@ void archive_free(ArchiveApp* archive) {
text_input_free(archive->text_input);
furi_record_close(RECORD_LOADER);
archive->loader = NULL;
furi_record_close(RECORD_GUI);
archive->gui = NULL;

View File

@@ -22,6 +22,7 @@ typedef enum {
struct ArchiveApp {
Gui* gui;
Loader* loader;
ViewDispatcher* view_dispatcher;
SceneManager* scene_manager;
ArchiveBrowserView* browser;

View File

@@ -86,10 +86,8 @@ void archive_scene_browser_on_enter(void* context) {
archive_update_focus(browser, archive->text_store);
view_dispatcher_switch_to_view(archive->view_dispatcher, ArchiveViewBrowser);
Loader* loader = furi_record_open(RECORD_LOADER);
archive->loader_stop_subscription =
furi_pubsub_subscribe(loader_get_pubsub(loader), archive_loader_callback, archive);
furi_record_close(RECORD_LOADER);
archive->loader_stop_subscription = furi_pubsub_subscribe(
loader_get_pubsub(archive->loader), archive_loader_callback, archive);
uint32_t state = scene_manager_get_scene_state(archive->scene_manager, ArchiveAppSceneBrowser);
@@ -213,10 +211,11 @@ bool archive_scene_browser_on_event(void* context, SceneManagerEvent event) {
if(!archive_is_home(browser)) {
archive_leave_dir(browser);
} else {
Loader* loader = furi_record_open(RECORD_LOADER);
if(archive->loader_stop_subscription) {
furi_pubsub_unsubscribe(
loader_get_pubsub(loader), archive->loader_stop_subscription);
furi_record_close(RECORD_LOADER);
loader_get_pubsub(archive->loader), archive->loader_stop_subscription);
archive->loader_stop_subscription = NULL;
}
view_dispatcher_stop(archive->view_dispatcher);
}
@@ -232,8 +231,9 @@ bool archive_scene_browser_on_event(void* context, SceneManagerEvent event) {
void archive_scene_browser_on_exit(void* context) {
ArchiveApp* archive = (ArchiveApp*)context;
Loader* loader = furi_record_open(RECORD_LOADER);
furi_pubsub_unsubscribe(loader_get_pubsub(loader), archive->loader_stop_subscription);
furi_record_close(RECORD_LOADER);
if(archive->loader_stop_subscription) {
furi_pubsub_unsubscribe(
loader_get_pubsub(archive->loader), archive->loader_stop_subscription);
archive->loader_stop_subscription = NULL;
}
}