Re: Segfault with a combo with 3 columns
- From: muppet <scott asofyet org>
- To: Daniel Kasak <dkasak nusconsulting com au>
- Cc: gtk-perl-list gnome org
- Subject: Re: Segfault with a combo with 3 columns
- Date: Tue, 27 Mar 2007 00:50:49 -0400
On Mar 26, 2007, at 8:59 PM, Daniel Kasak wrote:
I've attached a short script which produces a crash ( segfault )
for me when an item in a combo is selected.
The demo has 2 combos / models.
The 1st, 'good' model, has a Glib::Int column, and 2 Glib::String
columns. This works fine.
The 2nd, 'bad' model, has a 2 Glib::Int columns, and a Glib::String
column.
When an item is selected in the 2nd combo, I get a segfault. This
happens if the user selects an item with the mouse, or if the item
is selected in code, ie:
$widget->set_active_iter( $iter );
Note that I'm ONLY loading numeric data into the 2nd column.
My hunch is that this is a gtk+ bug, and not related to the
bindings. Am I right?
Not so sure.
On one hand, you're telling the ComboBoxEntry to get the text to show
in the entry from column 1, which is a Glib::Int column, and it does
so, blindly trusting you, and crashing. (The crash is in strcmp(),
deep within gtk_entry_set_text() from
gtk_combo_box_entry_active_changed().) It's a fairly trivial patch
to your code to use a real Glib::String column for the text column.
sub create_combo {
my $this_model = shift;
- my $combo = Gtk2::ComboBoxEntry->new( $this_model, 1 );
+ my $combo = Gtk2::ComboBoxEntry->new( $this_model, 2 );
- # Create a renderer for the 3rd column ( the text column )
+ # Create a renderer for the 2nd column ( the number column )
my $renderer = Gtk2::CellRendererText->new;
$combo->pack_start( $renderer, FALSE );
- $combo->set_attributes( $renderer, text => 2 );
+ $combo->set_attributes( $renderer, text => 1 );
return $combo;
}
On the other hand, in perl we're used to type coercion, and when
dealing with GtkTreeViewColumns and GtkCellRendererTexts you get type
coercion from G_TYPE_INT to G_TYPE_STRING. I've opened a gtk+ bug
about it, if you'd like to follow it: http://bugzilla.gnome.org/
show_bug.cgi?id=423201
--
If the monkey could type one keystroke every nanosecond, the expected
waiting time until the monkey types out Hamlet is so long that the
estimated age of the universe is insignificant by comparison ... this
is not a practical method for writing plays.
-- Gian-Carlo Rota
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]