gsignal: Document memory management best practices for signal handlers

It’s quite common to see naked g_signal_connect() calls without a paired
g_signal_handler_disconnect(). This is commonly a bug which could lead
to uses of the callback user data after it’s been freed.

Document the best practices for avoiding this kind of bug by properly
disconnecting all signal handlers.

https://bugzilla.gnome.org/show_bug.cgi?id=741779
This commit is contained in:
Philip Withnall
2014-12-19 15:21:09 +00:00
parent db8455f07d
commit ef1ba452b3
2 changed files with 29 additions and 0 deletions

View File

@@ -465,6 +465,9 @@ void g_signal_chain_from_overridden_handler (gpointer instance,
* Connects a #GCallback function to a signal for a particular object.
*
* The handler will be called before the default handler of the signal.
*
* See [memory management of signal handlers][signal-memory-management] for
* details on how to handle the return value and memory management of @data.
*
* Returns: the handler id (always greater than 0 for successful connections)
*/