mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-23 22:37:55 +02:00
fix segfault edge case in CObjectListWindow
This commit is contained in:
@@ -1535,9 +1535,12 @@ CObjectListWindow::CItem::CItem(CObjectListWindow * _parent, size_t _id, std::st
|
||||
index(_id)
|
||||
{
|
||||
OBJECT_CONSTRUCTION;
|
||||
auto imgIndex = parent->itemsVisible[index].first;
|
||||
if(parent->images.size() > index && parent->images[imgIndex])
|
||||
|
||||
auto it = std::find(parent->items.begin(), parent->items.end(), parent->itemsVisible[index]);
|
||||
int imgIndex = (it != parent->items.end()) ? std::distance(parent->items.begin(), it) : -1;
|
||||
if(imgIndex >= 0 && imgIndex < parent->images.size() && parent->images[imgIndex])
|
||||
icon = std::make_shared<CPicture>(parent->images[imgIndex], Point(1,1));
|
||||
|
||||
border = std::make_shared<CPicture>(ImagePath::builtin("TPGATES"));
|
||||
pos = border->pos;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user