summaryrefslogtreecommitdiff
path: root/tests/test_custom.cc
diff options
context:
space:
mode:
authorMurray Cumming <murrayc@murrayc.com>2005-04-27 14:07:19 +0000
committerMurray Cumming <murrayc@src.gnome.org>2005-04-27 14:07:19 +0000
commit91e489d518881556bc0dd7007e7b236da2a686bb (patch)
tree808db2a68b6ae0f44590568c2eed5a2f69e5a4dd /tests/test_custom.cc
parent50b2f065db0567d37a65d4b46bbd5248e907b93d (diff)
downloadsigc++-91e489d518881556bc0dd7007e7b236da2a686bb.tar.gz
Added a place to put extra test code, so I don't have to keep installing
2005-04-27 Murray Cumming <murrayc@murrayc.com> * tests/Makefile.am: * tests/test_custom.cc: Added a place to put extra test code, so I don't have to keep installing my crazy libsigc++ versions.
Diffstat (limited to 'tests/test_custom.cc')
-rw-r--r--tests/test_custom.cc92
1 files changed, 92 insertions, 0 deletions
diff --git a/tests/test_custom.cc b/tests/test_custom.cc
new file mode 100644
index 0000000..f454927
--- /dev/null
+++ b/tests/test_custom.cc
@@ -0,0 +1,92 @@
+#include <sigc++/sigc++.h>
+#include <iostream>
+#include <string>
+#include <sigc++/sigc++.h>
+
+class BaseDialog;
+
+void test_cast_basedialog(BaseDialog* base);
+
+template <class T_Derived>
+void test_cast(T_Derived* base)
+{
+ std::cout << " test_cast() base=" << base << std::endl;
+ sigc::trackable* trackable = base;
+ std::cout << " test_cast() (trackable*)base=" << trackable << std::endl;
+}
+
+class Foo
+{
+public:
+ virtual ~Foo()
+ {
+ std::cout << "~Foo this=" << this << std::endl;
+ }
+
+ //int i;
+};
+
+class BaseDialog : virtual public sigc::trackable
+{
+public:
+ BaseDialog()
+ {
+ std::cout << "BaseDialog::BaseDialog this=" << this << std::endl;
+ test_cast(this);
+ }
+
+ virtual ~BaseDialog()
+ {
+ std::cout << "~BaseDialog this=" << this << std::endl;
+ test_cast(this);
+ }
+
+ sigc::signal<void> clicked;
+};
+
+class SpecificDialog
+ : virtual public BaseDialog,
+ /* virtual */ public Foo
+{
+public:
+ SpecificDialog()
+ : sigc::trackable()
+ {
+ std::cout << "SpecificDialog::SpecificDialog this=" << this << std::endl;
+ test_cast(this);
+
+ clicked.connect(sigc::mem_fun(this, &SpecificDialog::OnClicked));
+ }
+
+ virtual ~SpecificDialog()
+ {
+ std::cout << "~SpecificDialog this=" << this << std::endl;
+ test_cast(this);
+
+ // 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();
+ //delete dlg;
+
+ std::cout << "main 1" << std::endl;
+ dlg->clicked.emit();
+ std::cout << "main 2" << std::endl;
+
+ return 0;
+}
+