Web lists-archives.com

Signal emission from an object thread


I have an issue related to the use of g_signal_emit called from an object thread.

The object has a 'new-buffer' signal. It receives data in a thread it owns, and emits this signal from this thread. When the object is finalized, it sets a 'stop' gboolean to TRUE, that tells the thread to stop. It then joins the thread, then proceed to ressource deallocation.

The problem is g_signal_emit increases the reference count of the object. That means if the user unref the object from the main thread (thinking he releases the last reference) during the call to g_signal_emit, the object is now owned only by the thread. When g_signal_emit unref the object, the finalization happens on the object thread, which will lead to the thread trying to join itself.

Hence my question: is it possible to emit a signal without increasing the reference count of the object ? I'd really like to avoid adding an explicit 'stop-the-thread' or 'inhibit-signal' function, to be used before g_object_unref.

The code is here:


A fix proposal with an explicit inhibit signal function:




gtk-list mailing list