[glibmm] Add reftpr_sigc_bind test case.



commit a4df86a4e8da9a0310a3c80ba690c0178f1a5250
Author: Murray Cumming <murrayc murrayc com>
Date:   Tue Jul 19 11:28:48 2011 +0200

    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.

 ChangeLog                             |    8 ++++
 tests/Makefile.am                     |    4 +-
 tests/glibmm_refptr_sigc_bind/main.cc |   68 +++++++++++++++++++++++++++++++++
 3 files changed, 79 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 81813ce..3fed064 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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 dc8bcb4..d887868 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 0000000..27b54e9
--- /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;
+}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]