Fix memory corruption if history is empty.

This commit is contained in:
Christian Speckner 2022-06-08 19:10:43 +00:00
parent a582a64cb6
commit e86bf5df78
1 changed files with 6 additions and 6 deletions

View File

@ -259,16 +259,16 @@ string& FileListWidget::fixPath(string& path)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FileListWidget::addHistory(const FilesystemNode& node)
{
//while(_history.size() > _historyIndex)
while(_currentHistory != std::prev(_history.end(), 1))
_history.pop_back();
if (_history.size() > 0) {
while(_currentHistory != std::prev(_history.end(), 1))
_history.pop_back();
string select = selected().getName();
_currentHistory->selected = fixPath(select);
string select = selected().getName();
_currentHistory->selected = fixPath(select);
}
_history.emplace_back(node, "..");
_currentHistory = std::prev(_history.end(), 1);
//_historyIndex++;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -