[gtkmm/gtkmm-4-2] Gtk: Several get_item() methods: Don't try to cast to Glib::Object
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm/gtkmm-4-2] Gtk: Several get_item() methods: Don't try to cast to Glib::Object
- Date: Thu, 29 Jul 2021 10:10:36 +0000 (UTC)
commit 6f8ad02fbece5be040efd7e3e6f35d7ce1a09b03
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date: Mon Jul 26 17:06:39 2021 +0200
Gtk: Several get_item() methods: Don't try to cast to Glib::Object
DropDown::get_selected_item(), ListItem::get_item(),
SingleSelection::get_selected_item(), TreeExpander::get_item(),
TreeListRow::get_item():
These methods return Glib::RefPtr<Glib::ObjectBase>. Don't try to
dynamic_cast to Glib::Object. It would fail if the object has been
constructed as an interface, and e.g. has a Gio::AppInfo wrapper.
See glibmm#93 and glibmm#94.
gtk/src/dropdown.hg | 2 +-
gtk/src/listitem.hg | 5 ++++-
gtk/src/singleselection.hg | 2 +-
gtk/src/treeexpander.hg | 2 +-
gtk/src/treelistrow.hg | 2 +-
5 files changed, 8 insertions(+), 5 deletions(-)
---
diff --git a/gtk/src/dropdown.hg b/gtk/src/dropdown.hg
index 9a679c6b..0a6aff6e 100644
--- a/gtk/src/dropdown.hg
+++ b/gtk/src/dropdown.hg
@@ -73,7 +73,7 @@ public:
_WRAP_METHOD(void set_selected(guint position), gtk_drop_down_set_selected)
_WRAP_METHOD(guint get_selected() const, gtk_drop_down_get_selected)
-#m4 _CONVERSION(`gpointer',`Glib::RefPtr<Glib::ObjectBase>',`Glib::wrap(G_OBJECT($3))')
+#m4
_CONVERSION(`gpointer',`Glib::RefPtr<Glib::ObjectBase>',`Glib::make_refptr_for_instance<Glib::ObjectBase>(Glib::wrap_auto(G_OBJECT($3)))')
_WRAP_METHOD(Glib::RefPtr<Glib::ObjectBase> get_selected_item(),
gtk_drop_down_get_selected_item, refreturn)
_WRAP_METHOD(Glib::RefPtr<const Glib::ObjectBase> get_selected_item() const,
diff --git a/gtk/src/listitem.hg b/gtk/src/listitem.hg
index 0f721ca1..65df5efb 100644
--- a/gtk/src/listitem.hg
+++ b/gtk/src/listitem.hg
@@ -48,7 +48,10 @@ class GTKMM_API ListItem : public Glib::Object
_CLASS_GOBJECT(ListItem, GtkListItem, GTK_LIST_ITEM, Glib::Object, GObject, , , GTKMM_API)
public:
-#m4 _CONVERSION(`gpointer',`Glib::RefPtr<Glib::ObjectBase>',`Glib::wrap(G_OBJECT($3))')
+ // Don't use Glib::RefPtr<Glib::Object> Glib::wrap(GObject* object, bool take_copy).
+ // The object may be an interface object, e.g. Gio::AppInfo. Such an object can't be
+ // cast to Glib::Object. https://gitlab.gnome.org/GNOME/glibmm/-/issues/93
+#m4
_CONVERSION(`gpointer',`Glib::RefPtr<Glib::ObjectBase>',`Glib::make_refptr_for_instance<Glib::ObjectBase>(Glib::wrap_auto(G_OBJECT($3)))')
_WRAP_METHOD(Glib::RefPtr<Glib::ObjectBase> get_item(), gtk_list_item_get_item, refreturn)
_WRAP_METHOD(Glib::RefPtr<const Glib::ObjectBase> get_item() const, gtk_list_item_get_item, refreturn,
constversion)
_WRAP_METHOD(guint get_position() const, gtk_list_item_get_position)
diff --git a/gtk/src/singleselection.hg b/gtk/src/singleselection.hg
index 0e8691ba..488fb2cb 100644
--- a/gtk/src/singleselection.hg
+++ b/gtk/src/singleselection.hg
@@ -61,7 +61,7 @@ public:
_WRAP_METHOD(guint get_selected() const, gtk_single_selection_get_selected)
_WRAP_METHOD(void set_selected(guint position), gtk_single_selection_set_selected)
-#m4 _CONVERSION(`gpointer',`Glib::RefPtr<Glib::ObjectBase>',`Glib::wrap(G_OBJECT($3))')
+#m4
_CONVERSION(`gpointer',`Glib::RefPtr<Glib::ObjectBase>',`Glib::make_refptr_for_instance<Glib::ObjectBase>(Glib::wrap_auto(G_OBJECT($3)))')
_WRAP_METHOD(Glib::RefPtr<Glib::ObjectBase> get_selected_item(),
gtk_single_selection_get_selected_item, refreturn)
_WRAP_METHOD(Glib::RefPtr<const Glib::ObjectBase> get_selected_item() const,
diff --git a/gtk/src/treeexpander.hg b/gtk/src/treeexpander.hg
index 41fa1bed..71116e5c 100644
--- a/gtk/src/treeexpander.hg
+++ b/gtk/src/treeexpander.hg
@@ -62,7 +62,7 @@ public:
*/
void unset_child();
-#m4 _CONVERSION(`gpointer',`Glib::RefPtr<Glib::ObjectBase>',`Glib::wrap(G_OBJECT($3))')
+#m4
_CONVERSION(`gpointer',`Glib::RefPtr<Glib::ObjectBase>',`Glib::make_refptr_for_instance<Glib::ObjectBase>(Glib::wrap_auto(G_OBJECT($3)))')
_WRAP_METHOD(Glib::RefPtr<Glib::ObjectBase> get_item(), gtk_tree_expander_get_item)
_WRAP_METHOD(Glib::RefPtr<const Glib::ObjectBase> get_item() const, gtk_tree_expander_get_item,
constversion)
diff --git a/gtk/src/treelistrow.hg b/gtk/src/treelistrow.hg
index 741b3578..745f841c 100644
--- a/gtk/src/treelistrow.hg
+++ b/gtk/src/treelistrow.hg
@@ -50,7 +50,7 @@ class GTKMM_API TreeListRow : public Glib::Object
_STRUCT_NOT_HIDDEN
public:
-#m4 _CONVERSION(`gpointer',`Glib::RefPtr<Glib::ObjectBase>',`Glib::wrap(G_OBJECT($3))')
+#m4
_CONVERSION(`gpointer',`Glib::RefPtr<Glib::ObjectBase>',`Glib::make_refptr_for_instance<Glib::ObjectBase>(Glib::wrap_auto(G_OBJECT($3)))')
_WRAP_METHOD(Glib::RefPtr<Glib::ObjectBase> get_item(), gtk_tree_list_row_get_item)
_WRAP_METHOD(Glib::RefPtr<const Glib::ObjectBase> get_item() const, gtk_tree_list_row_get_item,
constversion)
_WRAP_METHOD(void set_expanded(bool expanded = true), gtk_tree_list_row_set_expanded)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]