gsignal: Change signal instance ref semantics under static analysis

As with commit 0932f71460, which did this for refs/unrefs of the
object in `g_object_notify()`, we need to do a similar thing for
refs/unrefs of the instance with `g_signal_emit()`, for all the same
reasons.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
This commit is contained in:
Philip Withnall 2022-06-21 12:16:02 +01:00
parent 9a2bedb22c
commit 95d548ab03

View File

@ -3402,7 +3402,16 @@ g_signal_emit_valist (gpointer instance,
if (closure != NULL) if (closure != NULL)
{ {
/*
* Coverity doesnt understand the paired ref/unref here and seems
* to ignore the ref, thus reports every call to g_signal_emit()
* as causing a double-free. Thats incorrect, but I cant get a
* model file to work for avoiding the false positives, so instead
* comment out the ref/unref when doing static analysis.
*/
#ifndef __COVERITY__
g_object_ref (instance); g_object_ref (instance);
#endif
_g_closure_invoke_va (closure, _g_closure_invoke_va (closure,
return_accu, return_accu,
instance, instance,
@ -3452,8 +3461,11 @@ g_signal_emit_valist (gpointer instance,
TRACE(GOBJECT_SIGNAL_EMIT_END(signal_id, detail, instance, instance_type)); TRACE(GOBJECT_SIGNAL_EMIT_END(signal_id, detail, instance, instance_type));
/* See comment above paired ref above */
#ifndef __COVERITY__
if (closure != NULL) if (closure != NULL)
g_object_unref (instance); g_object_unref (instance);
#endif
return; return;
} }