summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorKjell Ahlstedt <kjellahlstedt@gmail.com>2019-12-15 15:43:37 +0100
committerKjell Ahlstedt <kjellahlstedt@gmail.com>2019-12-15 15:43:37 +0100
commitdc92d02f4d50851a1af59e5fbe2a753dcfd2e9df (patch)
tree22c2a978fbd97cdc5ef23dba76eb02fbe641263b /tests
parent2f4a122fa05e9e6514f62112d75d1ee7e4d894f2 (diff)
downloadglibmm-dc92d02f4d50851a1af59e5fbe2a753dcfd2e9df.tar.gz
Glib::Binding: Keep a binding alive even without a RefPtr
A binding between properties can remain even after all RefPtr<Binding>s are gone. This is similar to how Gtk::Widget::set_controller() works in gtkmm4. Fixes #62, see !21
Diffstat (limited to 'tests')
-rw-r--r--tests/glibmm_binding/main.cc13
1 files changed, 9 insertions, 4 deletions
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