mirror of https://github.com/OpenRCT2/OpenRCT2.git
Fix assert in debug mode in initialise_list_items
Erasing vector iterators causes the iterator to become invalid, so use an index instead for the loop.
This commit is contained in:
parent
4bfeaf0c72
commit
f00aa15096
|
@ -681,16 +681,16 @@ static void initialise_list_items(rct_window *w)
|
||||||
_listItems.pop_back();
|
_listItems.pop_back();
|
||||||
|
|
||||||
// Remove empty headings
|
// Remove empty headings
|
||||||
for (auto it = _listItems.begin(); it != _listItems.end(); it++)
|
for (size_t i = 0; i < _listItems.size(); i++)
|
||||||
{
|
{
|
||||||
const auto &listItem = *it;
|
const auto &listItem = _listItems[i];
|
||||||
if (listItem.type == LIST_ITEM_TYPE::HEADING)
|
if (listItem.type == LIST_ITEM_TYPE::HEADING)
|
||||||
{
|
{
|
||||||
if ((it + 1) == _listItems.end() ||
|
if (i + 1 == _listItems.size() ||
|
||||||
(it + 1)->type == LIST_ITEM_TYPE::HEADING)
|
_listItems[i + 1].type == LIST_ITEM_TYPE::HEADING)
|
||||||
{
|
{
|
||||||
_listItems.erase(it);
|
_listItems.erase(_listItems.begin() + i);
|
||||||
it--;
|
i--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue