[glibmm] Gio::ListModel::get_object(): Don't try to cast to Glib::Object
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm] Gio::ListModel::get_object(): Don't try to cast to Glib::Object
- Date: Thu, 15 Jul 2021 16:52:07 +0000 (UTC)
commit 34ed6e739d97ccf03a291527063601ad18704285
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date: Thu Jul 15 18:50:35 2021 +0200
Gio::ListModel::get_object(): Don't try to cast to Glib::Object
Gio::ListModel::get_object() returns Glib::RefPtr<Glib::ObjectBase>.
Don't try to dynamic_cast it to Glib::Object. It would fail if the object
has been constructed as an interface, and e.g. has a Gio::File wrapper.
Fixes #93
gio/src/listmodel.hg | 4 ++++
1 file changed, 4 insertions(+)
---
diff --git a/gio/src/listmodel.hg b/gio/src/listmodel.hg
index 875dece9..32fb183e 100644
--- a/gio/src/listmodel.hg
+++ b/gio/src/listmodel.hg
@@ -90,6 +90,10 @@ public:
//It doesn't do anything differently.
_IGNORE(g_list_model_get_item)
+ // Don't use Glib::RefPtr<Glib::Object> Glib::wrap(GObject* object, bool take_copy).
+ // The object may be an interface object, e.g. Gio::File. Such an object can't be
+ // cast to Glib::Object. https://gitlab.gnome.org/GNOME/glibmm/-/issues/93
+#m4
_CONVERSION(`GObject*',`Glib::RefPtr<Glib::ObjectBase>',`Glib::make_refptr_for_instance<Glib::ObjectBase>(Glib::wrap_auto($3))')
_WRAP_METHOD(Glib::RefPtr<Glib::ObjectBase> get_object(guint position), g_list_model_get_object, newin
"2,50")
_WRAP_METHOD(Glib::RefPtr<const Glib::ObjectBase> get_object(guint position) const,
g_list_model_get_object, constversion, newin "2,50")
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]