Re: Warning when setting a combo's model




On Apr 30, 2008, at 10:19 PM, Daniel Kasak wrote:

Hi all.

I'm cleaning up warnings in various places, and one that I can't figure
out happens when switching a combo's model. When I build a model that
has no data ( ie when I base the model on stuff from a database, and
there's no data returned ), I get:

Gtk-CRITICAL **: gtk_combo_box_entry_set_text_column: assertion
`entry_box->priv->text_column == -1'

... when I do:

my $model = Gtk2::ListStore->new( 'Glib::Int', 'Glib::String' );
$combo->set_model( $model ); # <== error happens at this point
$combo->set_text_column( 1 ); #  ... not at this point

... and then repeat the above. That is, it *doesn't* happen the first
time, but happens all subsequent times.


Looking at the code, and seeing the message, i find it very hard to believe the warning does not come from the set_text_column() line. The only g_return_if_fail() in gtk+ with that test is in that function, and the message is constructed with __func__.

Now, what is clear from the source, but not from the docs, is that you can call gtk_combo_box_entry_set_text_column() exactly once on a given ComboBoxEntry instance. The first assertion is that text_column >= 0 and < model's n columns. Then it asserts that the current value is -1, meaning you haven't set it before.

So, i suggest that you only call set_text_column() when creating the ComboBoxEntry, and not each time you set the model. The program attached to your message does not call set_text_column() each time.

Another suggestion: try

  my $combo = Gtk2::ComboBoxEntry->new ($model, $text_column);

instead of the three-line version.


--
One, two, free, four, five, six, sebben, eight, nine, ten, elebben, twull, fourteen, sickteen, sebbenteen, eightteen, elebbenteen, fiffeen, elebbenteen!
  -- Zella, aged three, counting to twenty.





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]