From: Mikko Rasa Date: Mon, 25 Nov 2013 07:56:09 +0000 (+0200) Subject: Fix a segfault when refreshing an item in a list with MultiColumnItems X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=c2664a6da9ee4a9fc3cb1adb42442412b45c7333;p=libs%2Fgltk.git Fix a segfault when refreshing an item in a list with MultiColumnItems --- diff --git a/source/list.cpp b/source/list.cpp index 87b27a4..14c779f 100644 --- a/source/list.cpp +++ b/source/list.cpp @@ -121,8 +121,9 @@ List::Item *List::create_item(unsigned index) item = item_factory->create_item(index); else item = new BasicItem(data->get_string(index)); - item->signal_autosize_changed.connect(sigc::bind(sigc::mem_fun(this, &List::item_autosize_changed), item)); add(*item); + item->autosize(); + item->signal_autosize_changed.connect(sigc::bind(sigc::mem_fun(this, &List::item_autosize_changed), item)); return item; } @@ -311,6 +312,8 @@ void List::DataObserver::cleared() void List::DataObserver::refresh_item(unsigned i) { delete list.items[i]; + // Avoid stale pointer while create_item is executing + list.items[i] = 0; list.items[i] = list.create_item(i); list.items_changed(); }