Package: libsigc++-2.0 Severity: normal Tags: patch sigc::slot can be used as a function pointer with the advantage of being able to add function arguments with sigc::bind, etc. However, disconnecting such slots does not work, because it doesn't do anything if there is no parent to notify.
In my programs it is quite usual that there isn't a parent, because I know what happens to the slot, so I don't need a notification. However, I still need to invalidate the slot sometimes, and even slot = sigc::slot0 <void> (); doesn't work, because that simply calls disconnect (). The attached patch invalidates the slot on disconnect, even if there is no parent. -- System Information: Debian Release: testing/unstable APT prefers unstable APT policy: (500, 'unstable') Architecture: i386 (i686) Shell: /bin/sh linked to /bin/bash Kernel: Linux 2.6.11 Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
--- slot_base.cc 2005-09-02 15:39:48.000000000 +0200 +++ libsigc++-2.0.10/sigc++/functors/slot_base.cc 2005-02-11 11:59:07.000000000 +0100 @@ -40,11 +40,11 @@ void slot_rep::operator delete(void* p) void slot_rep::disconnect() { - call_ = 0; // Invalidate the slot. - // _Must_ be done here because parent_ might defer the actual - // destruction of the slot_rep and try to invoke it before that point. if (parent_) { + call_ = 0; // Invalidate the slot. + // _Must_ be done here because parent_ might defer the actual + // destruction of the slot_rep and try to invoke it before that point. void* data_ = parent_; parent_ = 0; // Just a precaution. (cleanup_)(data_); // Notify the parent (might lead to destruction of this!).