summaryrefslogtreecommitdiff
path: root/gio/gtask.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2022-08-27 21:32:46 -0400
committerPhilip Withnall <pwithnall@endlessos.org>2022-11-01 11:48:08 +0000
commit01f2c5aec91d612ed4e9851d5fe0c1b1783b7386 (patch)
treefef7e20feec8cf9b0a40758c4375274ab05a0d70 /gio/gtask.c
parentdebf3e4a87fbffe5e3ee874490e576a593b3b666 (diff)
downloadglib-01f2c5aec91d612ed4e9851d5fe0c1b1783b7386.tar.gz
gtask: Don't overwrite source names
Only set a name in g_task_attach_source if the source does not already have one. Including a new test by Philip Withnall.
Diffstat (limited to 'gio/gtask.c')
-rw-r--r--gio/gtask.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/gio/gtask.c b/gio/gtask.c
index 5e2a20d64..5464a1cb0 100644
--- a/gio/gtask.c
+++ b/gio/gtask.c
@@ -1645,7 +1645,8 @@ g_task_run_in_thread_sync (GTask *task,
* callback to @callback, with @task as the callback's `user_data`.
*
* It will set the @source’s name to the task’s name (as set with
- * g_task_set_name()), if one has been set.
+ * g_task_set_name()), if one has been set on the task and the source doesn’t
+ * yet have a name.
*
* This takes a reference on @task until @source is destroyed.
*
@@ -1661,7 +1662,7 @@ g_task_attach_source (GTask *task,
g_source_set_callback (source, callback,
g_object_ref (task), g_object_unref);
g_source_set_priority (source, task->priority);
- if (task->name != NULL)
+ if (task->name != NULL && g_source_get_name (source) == NULL)
g_source_set_name (source, task->name);
g_source_attach (source, task->context);