diff --git a/src/graphicswin.cpp b/src/graphicswin.cpp index a7d44f12..8427fa1e 100644 --- a/src/graphicswin.cpp +++ b/src/graphicswin.cpp @@ -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) {