summaryrefslogtreecommitdiff
path: root/tests/test_custom.cc
diff options
context:
space:
mode:
authorMurray Cumming <murrayc@murrayc.com>2005-04-28 08:11:09 +0000
committerMurray Cumming <murrayc@src.gnome.org>2005-04-28 08:11:09 +0000
commit705766bc4236e86bb899d2e5fbb67fe912c1dbe5 (patch)
treec540ae25fd676e8c348e1a5c1288e8f48ac6dfc3 /tests/test_custom.cc
parent91e489d518881556bc0dd7007e7b236da2a686bb (diff)
downloadsigc++-705766bc4236e86bb899d2e5fbb67fe912c1dbe5.tar.gz
Added simplified test case from bug #169225. We have a patch to make this
2005-04-28 Murray Cumming <murrayc@murrayc.com> * tests/Makefile.am: * tests/test_virtualbase_delete.cc: Added simplified test case from bug #169225. We have a patch to make this succeed but I am not ready to commit it just yet.
Diffstat (limited to 'tests/test_custom.cc')
-rw-r--r--tests/test_custom.cc90
1 files changed, 18 insertions, 72 deletions
diff --git a/tests/test_custom.cc b/tests/test_custom.cc
index f454927..9d6e280 100644
--- a/tests/test_custom.cc
+++ b/tests/test_custom.cc
@@ -1,92 +1,38 @@
#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
+class Base : virtual public sigc::trackable
{
public:
- virtual ~Foo()
- {
- std::cout << "~Foo this=" << this << std::endl;
- }
-
- //int i;
+ sigc::signal<void> signal_something;
};
-class BaseDialog : virtual public sigc::trackable
+class Base2
{
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;
+ virtual ~Base2()
+ {}
};
-class SpecificDialog
- : virtual public BaseDialog,
- /* virtual */ public Foo
+class Derived
+ : virtual public Base,
+ public Base2
{
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();
- }
+ Derived()
+ {
+ signal_something.connect(sigc::mem_fun(this, &Derived::handler));
+ }
private:
- void OnClicked()
- {
- std::cout << "OnClicked 1" << std::endl;
- delete this;
- std::cout << "OnClicked 2" << std::endl;
- }
+ void handler()
+ {}
};
-
-int
-main(int argc, char **argv)
+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;
+ Derived* instance = new Derived();
+ delete instance;
- return 0;
+ return 0;
}
-