GNOME Bugzilla – Bug 166217
connections during emittion affect emittion.
Last modified: 2005-05-16 20:34:58 UTC
When a connection is made to a signal during the emittion of that signal, it affects that emittion. In other words the new slot is appended to the end of the slot list and called during the same emittion it was connected in. This can cause some interesting behaviour including infinite loops. An extremely simplified example will be attached as well as a patch which guarantees an emittion will be finite (so long as the slots themselves are finite) and maintains any guarantees of order which may have been set (I didn't know whether or not there were any order guarantees).
Created attachment 36950 [details] Infinite recursion in signal emittion
Created attachment 36951 [details] [review] Patch that resolves the infinite emittion All list operations I've used are O(1) and should not affect performance noticeably even with the tiniest of slot lists.
It looks good to me, but I'll wait for Martin to check it as well.
This really looks like an elegant solution to the problem! Applied to cvs. Thanks!
Thanks for the compliment :)
You might want to retest the cvs version, after my changes, because these did not actually return anything: + iterator begin() { temp_slots_.begin(); } + iterator end() { temp_slots_.end(); } + const_iterator begin() const { temp_slots_.begin(); } + const_iterator end() const { temp_slots_.end(); }
doah! Sorry about that. I must not have done enough cutting and pasting going from my copy to the CVS copy.
By the way, this has introduced bug #303896: signal's slot list is empty during signal emition.
Thanks for bringing this to my attention.