Skip Menu |

This queue is for tickets about the Gtk3 CPAN distribution.

Report information
The Basics
Id: 107319
Status: resolved
Priority: 0/
Queue: Gtk3

People
Owner: Nobody in particular
Requestors: asarch [...] hotmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Expected a blessed reference at Glib/Object/Introspection.pm line 58.
Date: Thu, 24 Sep 2015 23:24:45 +0000
To: "bug-Gtk3 [...] rt.cpan.org" <bug-gtk3 [...] rt.cpan.org>
From: Alef Sheridan Ariel Ramírez Chiñas <asarch [...] hotmail.com>
To whom it concern: Given a simple Gtk3::ListStore, if you try to iterate through its elements with the Gtk3::TreeModel::get_iterator_first and Gtk3::TreeModel::iter_next, you get this exception: Processing GTK+ *** unhandled exception in callback: *** expected a blessed reference at /usr/local/lib64/perl5/Glib/Object/Introspection.pm line 58. *** ignoring at /usr/local/share/perl5/Gtk3.pm line 321. This is the code: #!/usr/bin/perl use strict; use warnings; use Glib qw/FALSE TRUE/; use Gtk3 '-init'; #--------------------------------------------------------------------- # Window #--------------------------------------------------------------------- my $window = Gtk3::Window->new('toplevel'); $window->signal_connect(destroy => sub {Gtk3->main_quit}); $window->set_title('GTK+ Perl Template Script'); $window->set_default_size(640, 480); #--------------------------------------------------------------------- # Window Content #--------------------------------------------------------------------- my $content = Gtk3::Box->new('vertical', 0); $window->add($content); #--------------------------------------------------------------------- # Menu Bar #--------------------------------------------------------------------- my $menu_bar = Gtk3::MenuBar->new; $content->pack_start($menu_bar, FALSE, FALSE, 0); my $file_menu_item = Gtk3::MenuItem->new_with_mnemonic("_File"); $menu_bar->add($file_menu_item); my $file_menu = Gtk3::Menu->new; $file_menu_item->set_submenu($file_menu); my $quit_menu_item = Gtk3::MenuItem->new_with_mnemonic("_Quit"); $file_menu->add($quit_menu_item); $quit_menu_item->signal_connect(activate => sub {Gtk3->main_quit}); #--------------------------------------------------------------------- # Tool Bar #--------------------------------------------------------------------- my $toolbar = Gtk3::Toolbar->new; $content->pack_start($toolbar, FALSE, FALSE, 0); my $quit_tool_button = Gtk3::ToolButton->new_from_stock('gtk-quit'); $toolbar->insert($quit_tool_button, -1); $quit_tool_button->set_tooltip_text("Quit Application"); $quit_tool_button->signal_connect(clicked => sub {Gtk3->main_quit}); $toolbar->insert(Gtk3::SeparatorToolItem->new, -1); my $add_tool_button = Gtk3::ToolButton->new_from_stock('gtk-add'); $add_tool_button->set_tooltip_text("Add element"); $toolbar->insert($add_tool_button, -1); my $edit_tool_button = Gtk3::ToolButton->new_from_stock('gtk-edit'); $edit_tool_button->set_tooltip_text("Edit element"); $toolbar->insert($edit_tool_button, -1); my $delete_tool_button = Gtk3::ToolButton->new_from_stock('gtk-delete'); $delete_tool_button->set_tooltip_text("Delete element"); $toolbar->insert($delete_tool_button, -1); $toolbar->insert(Gtk3::SeparatorToolItem->new, -1); my $execute_tool_button = Gtk3::ToolButton->new_from_stock('gtk-execute'); $execute_tool_button->set_tooltip_text("Go!"); $toolbar->insert($execute_tool_button, -1); #--------------------------------------------------------------------- # Scrolled Window #--------------------------------------------------------------------- my $scrolled_window = Gtk3::ScrolledWindow->new; $scrolled_window->set_policy('always', 'always'); $content->pack_start($scrolled_window, TRUE, TRUE, 0); #--------------------------------------------------------------------- # Treeview #--------------------------------------------------------------------- my $store = Gtk3::ListStore->new('Glib::String', 'Glib::String'); my $treeview = Gtk3::TreeView->new_with_model($store); $scrolled_window->add($treeview); $treeview->append_column(Gtk3::TreeViewColumn->new_with_attributes("id", Gtk3::CellRendererText->new, text => 0)); $treeview->append_column(Gtk3::TreeViewColumn->new_with_attributes("url", Gtk3::CellRendererText->new, text => 1)); $treeview->get_column(0)->set_resizable(TRUE); $treeview->get_column(1)->set_resizable(TRUE); $treeview->get_column(0)->set_sort_column_id(0); $treeview->get_column(1)->set_sort_column_id(1); #--------------------------------------------------------------------- # Status Bar #--------------------------------------------------------------------- my $statusbar = Gtk3::Statusbar->new; $content->pack_start($statusbar, FALSE, FALSE, 0); #--------------------------------------------------------------------- # Callbacks #--------------------------------------------------------------------- $store->set($store->append, 0, 1, 1, "GTK+"); $store->set($store->append, 0, 2, 1, "Version 3"); $store->set($store->append, 0, 3, 1, "With"); $store->set($store->append, 0, 4, 1, "Perl"); $store->set($store->append, 0, 5, 1, "Is"); $store->set($store->append, 0, 6, 1, "Awesome!"); $execute_tool_button->signal_connect( 'clicked' => sub { my $iter = $treeview->get_model->get_iter_first; while ($iter) { my $address = $treeview->get_model->get($iter, 1); print STDERR "Processing $address\n"; $iter = $treeview->get_model->iter_next($iter) } } ); $window->show_all; Gtk3->main; I've try this piece of code with several version of Perl (for both x86 and AMD64) and with several version of GTK+ 3. Truly yours, Alef Sheridan Ariel R. Ch.
Subject: Re: [rt.cpan.org #107319] Expected a blessed reference at Glib/Object/Introspection.pm line 58.
Date: Fri, 25 Sep 2015 01:38:31 +0200
To: bug-Gtk3 [...] rt.cpan.org
From: Torsten Schoenfeld <kaffeetisch [...] gmx.de>
On 25.09.2015 01:25, Alef Sheridan Ariel Ramírez Chiñas via RT wrote: Show quoted text
> $iter = $treeview->get_model->iter_next($iter)
As mentioned in <https://metacpan.org/pod/Gtk3#Porting-from-Gtk2-to-Gtk3>, iter_next() now modifies the iter in-place instead of returning a new one. So try: $treeview->get_model->iter_next($iter);
Subject: Re: [rt.cpan.org #107319] Expected a blessed reference at Glib/Object/Introspection.pm line 58.
Date: Thu, 24 Sep 2015 21:21:38 -0500
To: bug-Gtk3 [...] rt.cpan.org
From: Alef Sheridan Ariel Ramírez Chiñas <asarch [...] hotmail.com>
On Thu, 2015-09-24 at 19:38 -0400, Torsten Schoenfeld via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=107319 > > > On 25.09.2015 01:25, Alef Sheridan Ariel Ramírez Chiñas via RT wrote:
> > $iter = $treeview->get_model->iter_next($iter)
> > As mentioned in > <https://metacpan.org/pod/Gtk3#Porting-from-Gtk2-to-Gtk3>, iter_next() > now modifies the iter in-place instead of returning a new one. So try: > > $treeview->get_model->iter_next($iter); >
Thank you, thank you very much!
Subject: Re: [rt.cpan.org #107319] Expected a blessed reference at Glib/Object/Introspection.pm line 58.
Date: Fri, 25 Sep 2015 21:07:21 -0500
To: bug-Gtk3 [...] rt.cpan.org
From: Alef Sheridan Ariel Ramírez Chiñas <asarch [...] hotmail.com>
On Thu, 2015-09-24 at 19:38 -0400, Torsten Schoenfeld via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=107319 > > > On 25.09.2015 01:25, Alef Sheridan Ariel Ramírez Chiñas via RT wrote:
> > $iter = $treeview->get_model->iter_next($iter)
> > As mentioned in > <https://metacpan.org/pod/Gtk3#Porting-from-Gtk2-to-Gtk3>, iter_next() > now modifies the iter in-place instead of returning a new one. So try: > > $treeview->get_model->iter_next($iter); >
So, properly it should be: $execute_tool_button->signal_connect( 'clicked' => sub { my $iter = $treeview->get_model->get_iter_first; my $elements = $treeview->get_model->iter_n_children; while ($elements-- >= 1) { my $address = $treeview->get_model->get($iter, 1); print STDERR "Processing $address\n"; $iter = $treeview->get_model->iter_next($iter) } } ); In order to avoid: (main.pl:6619): Gtk-CRITICAL **: gtk_list_store_get_value: assertion 'iter_is_valid (iter, list_store)' failed *** unhandled exception in callback: *** [gperl_sv_from_value] FIXME: unhandled type - 0 ((null) fundamental for (null)) *** ignoring at /usr/share/perl5/Gtk3.pm line 318.
Subject: Re: [rt.cpan.org #107319] Expected a blessed reference at Glib/Object/Introspection.pm line 58.
Date: Tue, 29 Sep 2015 20:46:18 +0200
To: bug-Gtk3 [...] rt.cpan.org
From: Torsten Schoenfeld <kaffeetisch [...] gmx.de>
On 26.09.2015 04:10, Alef Sheridan Ariel Ramírez Chiñas via RT wrote: Show quoted text
> So, properly it should be: > > $execute_tool_button->signal_connect( > 'clicked' => sub { > my $iter = $treeview->get_model->get_iter_first; > my $elements = $treeview->get_model->iter_n_children; > > while ($elements-- >= 1) { > my $address = $treeview->get_model->get($iter, 1); > > print STDERR "Processing $address\n"; > > $iter = $treeview->get_model->iter_next($iter) > } > } > );
No, don't assign the output of iter_next() to $iter. It's probably easiest to simply use foreach(): $model->foreach (sub { my ($model, $path, $iter) = @_; ... return FALSE; # continue });
Subject: Re: [rt.cpan.org #107319] Expected a blessed reference at Glib/Object/Introspection.pm line 58.
Date: Tue, 29 Sep 2015 13:57:53 -0500
To: bug-Gtk3 [...] rt.cpan.org
From: Alef Sheridan Ariel Ramírez Chiñas <asarch [...] hotmail.com>
On Tue, 2015-09-29 at 14:46 -0400, Torsten Schoenfeld via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=107319 > > > On 26.09.2015 04:10, Alef Sheridan Ariel Ramírez Chiñas via RT wrote:
> > So, properly it should be: > > > > $execute_tool_button->signal_connect( > > 'clicked' => sub { > > my $iter = $treeview->get_model->get_iter_first; > > my $elements = $treeview->get_model->iter_n_children; > > > > while ($elements-- >= 1) { > > my $address = $treeview->get_model->get($iter, 1); > > > > print STDERR "Processing $address\n"; > > > > $iter = $treeview->get_model->iter_next($iter) > > } > > } > > );
> > No, don't assign the output of iter_next() to $iter. > > It's probably easiest to simply use foreach(): > > $model->foreach (sub { > my ($model, $path, $iter) = @_; > ... > return FALSE; # continue > }); >
Ok. Thank you! :-)