After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 166217 - connections during emittion affect emittion.
connections during emittion affect emittion.
Status: RESOLVED FIXED
Product: libsigc++
Classification: Bindings
Component: signals
2.0.x
Other opensolaris
: Normal normal
: ---
Assigned To: Martin Schulze
Martin Schulze
Depends on:
Blocks:
 
 
Reported: 2005-02-03 22:30 UTC by Neal E. Coombes
Modified: 2005-05-16 20:34 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Infinite recursion in signal emittion (532 bytes, text/plain)
2005-02-03 22:32 UTC, Neal E. Coombes
  Details
Patch that resolves the infinite emittion (4.68 KB, patch)
2005-02-03 22:37 UTC, Neal E. Coombes
none Details | Review

Description Neal E. Coombes 2005-02-03 22:30:04 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).
Comment 1 Neal E. Coombes 2005-02-03 22:32:11 UTC
Created attachment 36950 [details]
Infinite recursion in signal emittion
Comment 2 Neal E. Coombes 2005-02-03 22:37:04 UTC
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.
Comment 3 Murray Cumming 2005-02-04 07:51:47 UTC
It looks good to me, but I'll wait for Martin to check it as well.
Comment 4 Martin Schulze 2005-02-04 22:36:43 UTC
This really looks like an elegant solution to the problem! Applied to cvs. Thanks!
Comment 5 Neal E. Coombes 2005-02-04 22:45:17 UTC
Thanks for the compliment :)
Comment 6 Murray Cumming 2005-02-06 18:28:06 UTC
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(); }
Comment 7 Neal E. Coombes 2005-02-07 13:11:27 UTC
doah!  Sorry about that.  I must not have done enough cutting and pasting going
from my copy to the CVS copy.
Comment 8 Murray Cumming 2005-05-14 23:18:31 UTC
By the way, this has introduced bug #303896: signal's slot list is empty during
signal emition.
Comment 9 Neal E. Coombes 2005-05-16 20:34:58 UTC
Thanks for bringing this to my attention.