From 9da7874f62c690f423309fa48b7e251f9f904ed3 Mon Sep 17 00:00:00 2001 From: Rejean Loyer Date: Thu, 14 Jul 2016 11:23:30 -0400 Subject: [PATCH] ide: workspace: fix making changes in openedFiles list during iteration through same list. --- ide/src/project/Workspace.ec | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/ide/src/project/Workspace.ec b/ide/src/project/Workspace.ec index 73e843d..1c368c3 100644 --- a/ide/src/project/Workspace.ec +++ b/ide/src/project/Workspace.ec @@ -593,28 +593,30 @@ public: void OpenPreviouslyOpenedFiles(bool noParsing) { + Array filePaths {}; holdTracking = true; - for(ofi : openedFiles) + for(ofi : openedFiles; ofi.state != closed) + filePaths.Add(CopyString(ofi.path)); + for(path : filePaths) { - if(ofi.state != closed) + Window file; + char absolutePath[MAX_LOCATION]; + strcpy(absolutePath, workspaceDir); + PathCatSlash(absolutePath, path); + file = ide.OpenFile(absolutePath, false, true, null, no, normal, noParsing); + if(file) { - Window file; - char absolutePath[MAX_LOCATION]; - strcpy(absolutePath, workspaceDir); - PathCatSlash(absolutePath, ofi.path); - file = ide.OpenFile(absolutePath, false, true, null, no, normal, noParsing); - if(file) + for(prj : projects) { - for(prj : projects) - { - ProjectNode node = prj.topNode.FindByFullPath(absolutePath, true); - if(node) - node.EnsureVisible(); - } + ProjectNode node = prj.topNode.FindByFullPath(absolutePath, true); + if(node) + node.EnsureVisible(); } } } holdTracking = false; + filePaths.Free(); + delete filePaths; } OpenedFileInfo FindOpenedFileInfo(const char * relativePath, const char * absolutePath) -- 1.8.3.1