fix: release background task reference deterministically

This commit is contained in:
grayTerminal-sh 2026-07-20 19:51:56 +02:00
parent ce2a95b4b0
commit ed7011cdc4

View file

@ -216,6 +216,12 @@ static void background_task_on_completed(
GDestroyNotify completion_data_destroy =
NULL;
BackgroundTaskRunContext *run_context =
NULL;
BackgroundTask *internal_task_reference =
NULL;
(void) source_object;
if (task == NULL ||
@ -224,6 +230,11 @@ static void background_task_on_completed(
return;
}
run_context =
g_task_get_task_data(
G_TASK(async_result)
);
worker_result = g_task_propagate_pointer(
G_TASK(async_result),
&worker_error
@ -327,6 +338,26 @@ static void background_task_on_completed(
g_clear_error(
&worker_error
);
/*
* L'exécution est maintenant totalement finalisée.
*
* La référence interne doit être libérée ici, et non attendre la
* destruction ultérieure du GTask. Le pointeur est placé à NULL pour
* empêcher background_task_run_context_free() de refaire un unref.
*/
if (run_context != NULL)
{
internal_task_reference =
run_context->task;
run_context->task =
NULL;
}
background_task_unref(
internal_task_reference
);
}
/**