? Doxyfile
? libsigc.kdevelop
? libsigc.kdevelop.pcs
? libsigc.kdevses
? revert.patch
? show_bad_cast.patch
? stamp-h1
? temp.patch
? temp.txt
? docs/manual/html
? tests/test_bind_ref
? tests/test_custom
Index: sigc++/trackable.cc
===================================================================
RCS file: /cvs/gnome/libsigc++2/sigc++/trackable.cc,v
retrieving revision 1.11
diff -u -p -r1.11 trackable.cc
--- sigc++/trackable.cc	19 Jan 2005 18:40:32 -0000	1.11
+++ sigc++/trackable.cc	27 Apr 2005 07:54:01 -0000
@@ -48,7 +48,9 @@ trackable& trackable::operator=(const tr
 
 trackable::~trackable()
 {
+  std::cout << "~trackable() before notify_callbacks: this=" << this << std::endl;
   notify_callbacks();
+  std::cout << "~trackable() after notify_callbacks: this=" << this << std::endl;
 }
 
 void trackable::add_destroy_notify_callback(void* data, func_destroy_notify func) const
@@ -63,21 +65,26 @@ void trackable::remove_destroy_notify_ca
 
 void trackable::notify_callbacks()
 {
+  std::cout << "trackable::notify_callbacks: this=" << this << std::endl;
   if (callback_list_)
     delete callback_list_; //This invokes all of the callbacks.
 
+  std::cout << "trackable::notify_callbacks: after delete callback_list this=" << this << std::endl;
+
   callback_list_ = 0;
 }
 
 internal::trackable_callback_list* trackable::callback_list() const
 {
+  std::cout << "trackable::callback_list(): this=" << this << std::endl;
+
   if (!callback_list_)
     callback_list_ = new internal::trackable_callback_list;
 
   return callback_list_;
 }
 
-      
+
 namespace internal
 {
 
Index: sigc++/visit_each.h
===================================================================
RCS file: /cvs/gnome/libsigc++2/sigc++/visit_each.h,v
retrieving revision 1.13
diff -u -p -r1.13 visit_each.h
--- sigc++/visit_each.h	27 Apr 2005 06:40:02 -0000	1.13
+++ sigc++/visit_each.h	27 Apr 2005 07:54:01 -0000
@@ -21,6 +21,7 @@
 #define _SIGC_VISIT_EACH_HPP_
 
 #include <sigc++/type_traits.h>
+#include <sigc++/trackable.h>
 
 namespace sigc {
 
@@ -64,12 +65,27 @@ struct limit_derived_target<T_target*, T
 
   template <class T_type> struct with_type<true,T_type>
   { static void execute_(const T_type& _A_type, const T_self& _A_action) 
-     { _A_action.action_(&_A_type); }
+     {
+      std::cout << "limit_derived_target<T_target*, T_action>::execute_(): TESTING CAST:" << std::endl;
+
+      std::cout << "  limit_derived_target<T_target*, T_action>::execute_(): const T_self_A_type=" << &_A_type << std::endl;
+
+      //_A_action.action_() actually takes a trackable (at least in the case we care about).
+      //But the cast to trackable* sometimes go completely wrong, producing a strange pointer.
+      const sigc::trackable* trackable = &_A_type; //dynamic_cast<const sigc::trackable*>(&_A_type);
+      std::cout << "  limit_derived_target<T_target*, T_action>::execute_(): trackable* _A_type=" << trackable << std::endl;
+
+       _A_action.action_(&_A_type);
+     }
   };
 
   template <class T_type>
   void operator()(const T_type& _A_type) const
-  { with_type<is_base_and_derived<T_target, T_type>::value,T_type>::execute_(_A_type, *this); }
+  {
+    std::cout << "limit_derived_target<T_target*, T_action>::operator(): T_type* _A_type=" << &_A_type << std::endl;
+
+    with_type<is_base_and_derived<T_target, T_type>::value,T_type>::execute_(_A_type, *this);
+  }
 
   limit_derived_target(const T_action& _A_action): action_(_A_action) {}
 
@@ -110,7 +126,15 @@ struct limit_derived_target<T_target*, T
  */
 template <class T_action, class T_functor>
 void visit_each(const T_action& _A_action, const T_functor& _A_functor)
-{ _A_action(_A_functor); }
+{
+  std::cout << "visit_each<>(): const T_functor* _A_functor = " << &_A_functor << std::endl;
+
+  //_A_functor is sometimes a sigc::trackable, but sometimes not.
+  //const sigc::trackable* trackable = &_A_functor;
+  //std::cout << "  visit_each<>:(): trackable* _A_functor=" << trackable << std::endl;
+
+ _A_action(_A_functor);
+}
 
 /** This function performs a functor on each of the targets
  * of a functor limited to a restricted type.
Index: sigc++/functors/slot_base.h
===================================================================
RCS file: /cvs/gnome/libsigc++2/sigc++/functors/slot_base.h,v
retrieving revision 1.11
diff -u -p -r1.11 slot_base.h
--- sigc++/functors/slot_base.h	23 Feb 2005 14:37:11 -0000	1.11
+++ sigc++/functors/slot_base.h	27 Apr 2005 07:54:01 -0000
@@ -22,6 +22,7 @@
 #include <sigc++config.h>
 #include <sigc++/trackable.h>
 #include <sigc++/functors/functor_trait.h>
+#include <iostream>
 
 namespace sigc
 {
@@ -163,7 +164,10 @@ struct SIGC_API slot_do_unbind
    * @param t The trackable object to remove the callback from.
    */
   inline void operator()(const trackable* t) const
-    { t->remove_destroy_notify_callback(rep_); }
+    {
+       std::cout << "slot_do_unbind::operator(): trackable t=" << t << std::endl;
+       t->remove_destroy_notify_callback(rep_);
+    }
 };
 
 } //namespace internal
Index: tests/Makefile.am
===================================================================
RCS file: /cvs/gnome/libsigc++2/tests/Makefile.am,v
retrieving revision 1.17
diff -u -p -r1.17 Makefile.am
--- tests/Makefile.am	27 Apr 2005 06:40:03 -0000	1.17
+++ tests/Makefile.am	27 Apr 2005 07:54:01 -0000
@@ -25,7 +25,8 @@ noinst_PROGRAMS= \
   test_bind \
   test_bind_ref \
   test_functor_trait \
-  test_compatibility
+  test_compatibility \
+  test_custom
 
 #Disabled:
 #   test_lambda - The Tru64 compiler can't build this when not using -std strict_ansi -model ansi, so let's not worry about it.
@@ -56,8 +57,9 @@ test_hide_SOURCES = test_hide.cc
 test_retype_SOURCES = test_retype.cc
 test_compose_SOURCES = test_compose.cc
 test_exception_catch_SOURCES = test_exception_catch.cc
-
+test_exception_catch_SOURCES = test_exception_catch.cc
 # test_lambda_SOURCES = test_lambda.cc
 
 test_size_SOURCES = test_size.cc
 test_compatibility_SOURCES = test_compatibility.cc
+test_custom_SOURCES = test_custom.cc
Index: tests/test_custom.cc
===================================================================
RCS file: tests/test_custom.cc
diff -N tests/test_custom.cc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/test_custom.cc	27 Apr 2005 07:54:01 -0000
@@ -0,0 +1,76 @@
+#include <sigc++/sigc++.h>
+#include <iostream>
+#include <string>
+#include <sigc++/sigc++.h>
+
+class Foo
+{
+public:
+	virtual ~Foo()
+        {
+          std::cout << "~Foo this=" << this << std::endl;
+        }
+};
+
+class BaseDialog : virtual public sigc::trackable
+{
+public:
+	BaseDialog()
+        {}
+
+	virtual ~BaseDialog()
+        {
+          std::cout << "~BaseDialog this=" << this << std::endl;
+          sigc::trackable* trackable = this;
+          std::cout << "~BaseDialog (trackable*)this=" << trackable << std::endl;
+        }
+
+	sigc::signal<void> clicked;
+};
+
+class SpecificDialog
+	: virtual public BaseDialog,
+	  public Foo
+{
+public:
+	SpecificDialog()
+        : sigc::trackable()
+	{
+          std::cout << "SpecificDialog::SpecificDialog this=" << this << std::endl;
+          sigc::trackable* trackable = this;
+          std::cout << "SpecificDialog::SpecificDialog (trackable*)this=" << trackable << std::endl;
+
+          clicked.connect(sigc::mem_fun(this, &SpecificDialog::OnClicked));
+	}
+
+	virtual ~SpecificDialog()
+	{
+          std::cout << "~SpecificDialog this=" << this << std::endl;
+          sigc::trackable* trackable = this;
+          std::cout << "~SpecificDialog (trackable*)this=" << trackable << std::endl;
+		// This would fix the crash:
+		// notify_callbacks();
+	}
+
+private:
+	void OnClicked()
+	{
+                std::cout << "OnClicked 1" << std::endl;
+		delete this;
+                std::cout << "OnClicked 2" << std::endl;
+	}
+};
+
+
+int
+main(int argc, char **argv)
+{
+	SpecificDialog *dlg = new SpecificDialog();
+
+        std::cout << "main 1" << std::endl;
+	dlg->clicked.emit();
+        std::cout << "main 2" << std::endl;
+
+	return 0;
+}
+
