Re: Application crash but when I swap lines it works.
- From: Krzesimir Nowak <qdlacz gmail com>
- To: Łukasz Gąsiorek <lukaszgpl gmail com>
- Cc: gtkmm-list gnome org
- Subject: Re: Application crash but when I swap lines it works.
- Date: Mon, 12 Mar 2012 17:58:54 +0100
W dniu 12 marca 2012 16:55 użytkownik Krzesimir Nowak
<qdlacz gmail com> napisał:
> W dniu 12 marca 2012 16:14 użytkownik Łukasz Gąsiorek
> <lukaszgpl gmail com> napisał:
>> Code is here http://pastie.org/3578062
>> Look at the lines 80, 81, 82 and 93.
>> When I swap lines 81 and 82 app works. What is wrong?
> I do wonder if declaring m_cols as 'const Columns' in ContactList is
> not messing some things up. I mean - it probably should be non-const,
> because referring to members of const instance makes the members also
> const, that is - they are of type e.g. 'const
> Gtk::TreeModelColumn<Glib::ustring>' instead of
> 'Gtk::TreeModelColumn<Glib::ustring>'. And this probably doing
> something weird in line with 'row[m_cols.contact] = contact;' where
> operator of row is some kind of templated function.
> This is a wild guess I made after reading the code - I did not try to
> compile it. I suppose that compiling with warning flags (like -Wall
> and -Wextra) gives no clues, eh?
Ok, do not read this obviously morose speculations above.
The reason the code works in that way is because everytime you set a
column, the model is sorted. So first invocation of add_contact
succeeds, because there is nothing to be sorted. Then second call
comes and you are setting alias first - that causes some signals to be
emitted and in effect the model is sorted (sort function is already
set). And that aborts, because the contact column in second row is not
being set, so it holds an empty shared pointer.
In short - the assertion here is wrong. Empty shared_ptr should be
handled gracefully. When the contact column is set then it will be
sorted again, this time correctly.
Also, I would move 'm_tree_store->set_sort_column(m_cols.alias,
Gtk::SORT_ASCENDING);' into ContactList constructor - you do not need
to call it everytime.
>> gtkmm-list mailing list
>> gtkmm-list gnome org
] [Thread Prev