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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user