From dc92d02f4d50851a1af59e5fbe2a753dcfd2e9df Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Sun, 15 Dec 2019 15:43:37 +0100 Subject: Glib::Binding: Keep a binding alive even without a RefPtr A binding between properties can remain even after all RefPtrs are gone. This is similar to how Gtk::Widget::set_controller() works in gtkmm4. Fixes #62, see !21 --- tests/glibmm_binding/main.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/glibmm_binding/main.cc b/tests/glibmm_binding/main.cc index 9b727e51..4d0bacc7 100644 --- a/tests/glibmm_binding/main.cc +++ b/tests/glibmm_binding/main.cc @@ -80,11 +80,12 @@ test() // Ensure no change when invalid source results in false return source.property_string() = "six six six"; g_assert_cmpint(target.property_int(), ==, 47); - } - // Ensure the binding was released when its RefPtr went out of scope - source.property_string() = "89"; - g_assert_cmpint(target.property_int(), ==, 47); + // Ensure the binding is broken when unbind() is called + binding->unbind(); + source.property_string() = "89"; + g_assert_cmpint(target.property_int(), ==, 47); + } { auto binding = Glib::Binding::bind_property( @@ -94,6 +95,10 @@ test() // With SYNC_CREATE, value of source must sync to target on bind g_assert_cmpint(target.property_int(), ==, 89); } + + // Ensure the binding was not broken when its RefPtr went out of scope + source.property_string() = "90"; + g_assert_cmpint(target.property_int(), ==, 90); } } // namespace -- cgit v1.2.1