]> git.tdb.fi Git - libs/gltk.git/commitdiff
Fix a segfault when refreshing an item in a list with MultiColumnItems
authorMikko Rasa <tdb@tdb.fi>
Mon, 25 Nov 2013 07:56:09 +0000 (09:56 +0200)
committerMikko Rasa <tdb@tdb.fi>
Mon, 25 Nov 2013 07:56:09 +0000 (09:56 +0200)
source/list.cpp

index 87b27a4dc641988b5438b9799500264da7d4fbd6..14c779f0f579dc236eae5049e5c4720e94760591 100644 (file)
@@ -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();
 }