From 0aa8c79f09e407087596158693f3a3098ad6aa5e Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Sun, 9 Apr 2017 12:25:59 +0200 Subject: Value: Only use RefPtr specialization for types that have get_base_type(). For instance, RefPtr to ObjectBase-derived types, or other types that try to have a similar API. Previously, this assumed that any Value> was for a T that had a get_base_type() (wrapping an underlying glib/gtk C type). --- tests/glibmm_value/main.cc | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'tests') diff --git a/tests/glibmm_value/main.cc b/tests/glibmm_value/main.cc index 47da4645..a824f948 100644 --- a/tests/glibmm_value/main.cc +++ b/tests/glibmm_value/main.cc @@ -78,6 +78,10 @@ test() Glib::init(); + // TODO: Put this test, of internal stuff, somewhere else. + static_assert(Glib::Traits::HasGetBaseType::value, + "DerivedObject has no get_base_type()."); + // RefPtr to Glib::ObjectBase-derived type: { GObject* gobject = G_OBJECT(g_object_new(TEST_TYPE_DERIVED, nullptr)); @@ -114,6 +118,29 @@ test() const auto v = value.get(); assert(v); } + + { + auto foo = std::make_shared(); + + // custom pointer + Glib::Value> value; + value.init(Glib::Value>::value_type()); // TODO: Avoid this step? + value.set(foo); + + const auto v = value.get(); + assert(v); + } + + { + auto foo = std::make_shared(); + + Glib::Value> value; + value.init(Glib::Value>::value_type()); // TODO: Avoid this step? + value.set(foo); + + const auto v = value.get(); + assert(v); + } } // Glib::Object RefPtr<> -- cgit v1.2.1