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

[FL-1880] Dialogs: fix semaphore lock (#722)

* Dialogs: fix queued message lock
* Dialogs: file select, fix queued message lock
* Dialogs: file select, free context after freeing callback holder
* Dialogs: better lock, separated wait and free

Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
SG
2021-09-25 02:36:53 +10:00
committed by GitHub
parent d3b58f732f
commit acb8508249
6 changed files with 40 additions and 27 deletions

View File

@@ -10,8 +10,8 @@ bool dialog_file_select_show(
char* result,
uint8_t result_size,
const char* preselected_filename) {
osSemaphoreId_t semaphore = API_LOCK_INIT_LOCKED();
furi_check(semaphore != NULL);
FuriApiLock lock = API_LOCK_INIT_LOCKED();
furi_check(lock != NULL);
DialogsAppData data = {
.file_select = {
@@ -24,14 +24,14 @@ bool dialog_file_select_show(
DialogsAppReturn return_data;
DialogsAppMessage message = {
.semaphore = semaphore,
.lock = lock,
.command = DialogsAppCommandFileOpen,
.data = &data,
.return_data = &return_data,
};
furi_check(osMessageQueuePut(context->message_queue, &message, 0, osWaitForever) == osOK);
API_LOCK_WAIT_UNTIL_UNLOCK_AND_FREE(semaphore);
API_LOCK_WAIT_UNTIL_UNLOCK_AND_FREE(lock);
return return_data.bool_value;
}
@@ -39,8 +39,8 @@ bool dialog_file_select_show(
/****************** Message ******************/
DialogMessageButton dialog_message_show(DialogsApp* context, const DialogMessage* dialog_message) {
osSemaphoreId_t semaphore = API_LOCK_INIT_LOCKED();
furi_check(semaphore != NULL);
FuriApiLock lock = API_LOCK_INIT_LOCKED();
furi_check(lock != NULL);
DialogsAppData data = {
.dialog = {
@@ -49,14 +49,14 @@ DialogMessageButton dialog_message_show(DialogsApp* context, const DialogMessage
DialogsAppReturn return_data;
DialogsAppMessage message = {
.semaphore = semaphore,
.lock = lock,
.command = DialogsAppCommandDialog,
.data = &data,
.return_data = &return_data,
};
furi_check(osMessageQueuePut(context->message_queue, &message, 0, osWaitForever) == osOK);
API_LOCK_WAIT_UNTIL_UNLOCK_AND_FREE(semaphore);
API_LOCK_WAIT_UNTIL_UNLOCK_AND_FREE(lock);
return return_data.dialog_value;
}