mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-06 06:32:56 +01:00
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:
@@ -681,16 +681,16 @@ static void initialise_list_items(rct_window *w)
|
||||
_listItems.pop_back();
|
||||
|
||||
// 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 ((it + 1) == _listItems.end() ||
|
||||
(it + 1)->type == LIST_ITEM_TYPE::HEADING)
|
||||
if (i + 1 == _listItems.size() ||
|
||||
_listItems[i + 1].type == LIST_ITEM_TYPE::HEADING)
|
||||
{
|
||||
_listItems.erase(it);
|
||||
it--;
|
||||
_listItems.erase(_listItems.begin() + i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user