1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-10 22:31:40 +02:00

fix sort crash

This commit is contained in:
Laserlicht
2025-03-10 18:27:35 +01:00
parent ee5cddb52c
commit ecfecaaa70

View File

@@ -618,7 +618,13 @@ void SelectionTab::sort()
if(!sortModeAscending)
{
if(firstMapIndex)
std::reverse(std::next(curItems.begin(), boost::starts_with(curItems[0]->folderName, "..") ? 1 : 0), std::next(curItems.begin(), firstMapIndex - 1));
{
auto startIt = std::next(curItems.begin(), boost::starts_with(curItems[0]->folderName, "..") ? 1 : 0);
auto endIt = std::next(curItems.begin(), firstMapIndex - 1);
if(startIt > endIt)
std::swap(startIt, endIt);
std::reverse(startIt, endIt);
}
std::reverse(std::next(curItems.begin(), firstMapIndex), curItems.end());
}