GUI: Fix dangling pointer when _headerEntryList was reallocated
As we know the size of the array in advance we can preallocate it.
This commit is contained in:
parent
226ab7d8a0
commit
ebbc0b09e9
1 changed files with 3 additions and 0 deletions
|
@ -470,6 +470,9 @@ void GridWidget::sortGroups() {
|
|||
// No filter -> display everything with group headers
|
||||
Common::sort(_groupHeaders.begin(), _groupHeaders.end());
|
||||
|
||||
// Avoid reallocation during iteration: that would invalidate our _sortedEntryList items
|
||||
_headerEntryList.reserve(_groupHeaders.size());
|
||||
|
||||
for (uint i = 0; i != _groupHeaders.size(); ++i) {
|
||||
Common::U32String header = _groupHeaders[i];
|
||||
Common::U32String displayedHeader;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue