diff options
author | Murray Cumming <murrayc@murrayc.com> | 2011-07-19 11:28:48 +0200 |
---|---|---|
committer | Murray Cumming <murrayc@murrayc.com> | 2011-07-19 11:28:48 +0200 |
commit | a4df86a4e8da9a0310a3c80ba690c0178f1a5250 (patch) | |
tree | cac6786eca124208c532d03f0101bd59414b8728 | |
parent | be04a6c229efb204f96dbf9b50359ffe1b5e7d17 (diff) | |
download | glibmm-a4df86a4e8da9a0310a3c80ba690c0178f1a5250.tar.gz |
Add reftpr_sigc_bind test case.
* tests/glibmm_refptr_sigc_bind/main.cc:
* tests/Makefile.am: Add a new test case from Kjell Ahlstedt, to test a fix
in libsigc++. See bug #564005#c14.
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | tests/Makefile.am | 4 | ||||
-rw-r--r-- | tests/glibmm_refptr_sigc_bind/main.cc | 68 |
3 files changed, 79 insertions, 1 deletions
@@ -1,5 +1,13 @@ 2011-07-19 Murray Cumming <murrayc@murrayc.com> + Add reftpr_sigc_bind test case. + + * tests/glibmm_refptr_sigc_bind/main.cc: + * tests/Makefile.am: Add a new test case from Kjell Ahlstedt, to test a fix + in libsigc++. See bug #564005#c14. + +2011-07-19 Murray Cumming <murrayc@murrayc.com> + Add h2defs.py and docextract_to_xml.py, removed from pygboject. * tools/defs_gen/definitions.py: diff --git a/tests/Makefile.am b/tests/Makefile.am index dc8bcb45..d887868f 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -35,7 +35,8 @@ check_PROGRAMS = \ glibmm_bool_vector/test \ glibmm_bool_arrayhandle/test \ glibmm_null_vectorutils/test \ - glibmm_null_containerhandle/test + glibmm_null_containerhandle/test \ + glibmm_refptr_sigc_bind/test TESTS = $(check_PROGRAMS) @@ -81,3 +82,4 @@ glibmm_null_vectorutils_test_SOURCES = glibmm_null_vectorutils/main.cc glibmm_null_vectorutils_test_LDADD = $(giomm_ldadd) glibmm_null_containerhandle_test_SOURCES = glibmm_null_containerhandle/main.cc glibmm_null_containerhandle_test_LDADD = $(giomm_ldadd) +glibmm_refptr_sigc_bind_test_SOURCES = glibmm_refptr_sigc_bind/main.cc diff --git a/tests/glibmm_refptr_sigc_bind/main.cc b/tests/glibmm_refptr_sigc_bind/main.cc new file mode 100644 index 00000000..27b54e9e --- /dev/null +++ b/tests/glibmm_refptr_sigc_bind/main.cc @@ -0,0 +1,68 @@ +// Bug 564005 - Valgrind errors and crash on exit with Gtk::UIManager +// Bug 154498 - Unnecessary warning on console: signalproxy_connectionnode.cc + +// libsigc++-only test case. (Or almost so. glib_refptr.h is stolen from glibmm.) + +#include <glibmm/refptr.h> +#include <sigc++/sigc++.h> +#include <iostream> +#include <stdlib.h> + +#define ACTIVATE_BUG 1 + +class Action : public sigc::trackable +{ +public: + Action() : ref_count(1) { } + + void reference() { ++ref_count; } + void unreference() { if (--ref_count <= 0) delete this; } + + void emit_sig1(int n) { sig1.emit(n); } + + sigc::signal<void, int>& signal_sig1() { return sig1; } + +private: + sigc::signal<void, int> sig1; + int ref_count; + +}; + +class Test : public sigc::trackable +{ +public: + Test() + : action(new Action) + { + //std::cout << "new Test" << std::endl; +#ifdef ACTIVATE_BUG //See https://bugzilla.gnome.org/show_bug.cgi?id=564005#c15s + action->signal_sig1().connect(sigc::bind(sigc::mem_fun(this, &Test::on_sig1), action)); +#else + Glib::RefPtr<Action> action2(new Action); + action->signal_sig1().connect(sigc::bind(sigc::mem_fun(this, &Test::on_sig1), action2)); +#endif + } + + ~Test() + { + //std::cout << "delete Test" << std::endl; + } + + void on_sig1(int /* n */, Glib::RefPtr<Action> /* action */) + { + //std::cout << "Test::on_sig1, n=" << n << std::endl; + } + + Glib::RefPtr<Action> action; + +}; // end Test + +int main(int, char**) +{ + Test* test = new Test; + + test->action->emit_sig1(23); + delete test; + + return EXIT_SUCCESS; +} |