fix: prevent crash when folder name does not contain slashes (#974)

This can happen on Windows when the file is loaded from the root
of drive, eg. "E:/"
This commit is contained in:
Dennis Brakhane
2024-11-02 07:21:40 +01:00
committed by GitHub
parent f64c9f473c
commit e9bb3ebae5
+5 -1
View File
@@ -213,7 +213,11 @@ void ContentBrowserWindow::RefreshContent()
{
folder.pop_back();
}
folder = folder.substr(folder.find_last_of("/\\"));
auto last_slash = folder.find_last_of("/\\");
if (last_slash != folder.npos) {
folder = folder.substr(last_slash);
}
button.Create(folder);
button.SetTooltip(editor->recentFolders[editor->recentFolders.size() - 1 - i]); // full folder name!
button.SetLocalizationEnabled(false);