Skip to content

gtask: Warn if a GTask is finalised without returning

Philip Withnall requested to merge pwithnall/glib:gtask-must-have-result into main

This typically indicates a bug in the program, where a GTask has been created, but a bug in the control flow has caused it to not return a value.

There is one situation where it might be legitimate to finalise a GTask without returning: if an error happens in your *_async() start function after you’ve created a GTask, but before the async operation returns to the main loop; and you report the error using g_task_report_*error() rather than reporting it using the newly constructed GTask.

Another situation is where you are just using GTask as a convenient way to move some work to another thread, without the complexity of creating and running your own thread pool. GDBus does this with g_dbus_interface_method_dispatch_helper(), for example.

In most other cases, it’s a bug. Emit a debug message about it, but not a full-blown warning, as that would create noise in the legitimate cases.

Signed-off-by: Philip Withnall withnall@endlessm.com

Edited by Philip Withnall

Merge request reports