Make use of g_clear_signal_handler()
g_clear_signal_handler()
is a new function available in recent GLib versions which we could use to make our code cleaner.
More explanation and example in this blog post: https://tecnocode.co.uk/2019/07/09/g_clear_signal_handler-in-glib-2-61-1/
Official documentation here: https://developer.gnome.org/gobject/stable/gobject-Signals.html#g-clear-signal-handler
In a quick search for "g_signal_handler_disconnect" I found at least 18 places where we can use g_clear_signal_handler()
.
Not all uses of g_signal_handler_disconnect()
are to be replaced, only the simple cases that resemble the example from the blog post.
Actual example from our codebase:
if (bar->selection_handler_id)
{
g_signal_handler_disconnect (bar->view, bar->selection_handler_id);
bar->selection_handler_id = 0;
}
This can be replaced with:
g_clear_signal_handler (&bar->selection_handler_id, bar->view);
This is an easy task. The goal of this issue is to get used to the contribution workflow while following the Newcomers tutorial.
To make things interesting, there is one subtask I didn't mention, but I'll leave that for the review phase.