Copy path to avoid it being invalidated by OkayToStartNewFile()

pull/998/head
Tom Sutcliffe 2021-04-04 13:21:14 +01:00 committed by phkahler
parent 2a56ba661e
commit e2bf722fec
1 changed files with 4 additions and 1 deletions

View File

@ -369,8 +369,11 @@ static void PopulateMenuWithPathnames(Platform::MenuRef menu,
void GraphicsWindow::PopulateRecentFiles() {
PopulateMenuWithPathnames(openRecentMenu, SS.recentFiles, [](const Platform::Path &path) {
// OkayToStartNewFile could mutate recentFiles, which will invalidate path (which is a
// refererence into the recentFiles vector), so take a copy of it here.
Platform::Path pathCopy(path);
if(!SS.OkayToStartNewFile()) return;
SS.Load(path);
SS.Load(pathCopy);
});
PopulateMenuWithPathnames(linkRecentMenu, SS.recentFiles, [](const Platform::Path &path) {