GNOME Bugzilla – Bug 311057
slot<>::disconnect() does not work.
Last modified: 2005-12-01 11:47:08 UTC
Version details: 2.0.14 Distribution/Version: Windows 2000 SP4 Attempting to overwrite a sigc::slot with a null (default-constructed) slot seems to have no effect. sigc::slot::disconnect() also seems to do nothing, although possibly I'm misunderstanding the docs.
Created attachment 49483 [details] Sample code that tries to copy a null slot Sample code attached. The output I expect is simply: Bar but the output I get is: Foo Foo Bar
Did this work with a previous version?
I know it doesn't work in 2.0.6 either. I haven't tried versions earlier than that.
The problem here seems to be that slot::disconnect() does not work, regardless of the null slot.
I've added the simplified test case to cvs: http://cvs.gnome.org/viewcvs/libsigc%2B%2B2/tests/test_slot_disconnect.cc?view=markup So now I am wondering what constructor or operator= is used to convert the sigc::pointer_functor<void> to a sigc::slot0<void>. I think that the rep_::parent is not set properly when that happens, and that stops disconnect() from working.
I think it's this simple. I've commited it: 2005-12-01 Murray Cumming <murrayc@murrayc.com> + * sigc++/functors/slot_base.cc: + slot_base::disconnect(): Set call_ to 0, + to invalidate the slot, even if parent_ is 0. + I think parent_ is, for instance, a signal, but + disconnect should still work on a slot that is not + connected to a signal, because a slot can be invoked + directly. + Fixes bug #311057 from James Lin. + +2005-12-01 Murray Cumming <murrayc@murrayc.com> + * tests/Makefile.am: * tests/test_slot_disconnect.cc: Added test case from bug #311057. Index: sigc++/functors/slot_base.cc =================================================================== RCS file: /cvs/gnome/libsigc++2/sigc++/functors/slot_base.cc,v retrieving revision 1.9 diff -u -p -r1.9 slot_base.cc --- sigc++/functors/slot_base.cc 1 May 2005 02:00:46 -0000 1.9 +++ sigc++/functors/slot_base.cc 1 Dec 2005 11:38:08 -0000 @@ -49,6 +49,8 @@ void slot_rep::disconnect() parent_ = 0; // Just a precaution. (cleanup_)(data_); // Notify the parent (might lead to destruction of this!). } + else + call_ = 0; } //static