Skip to content

Commit 79cfce0

Browse files
committed
Fix potential crash when deleting files from recently opened
1 parent b53eb6f commit 79cfce0

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

Source/Components/WelcomePanel.h

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -820,20 +820,24 @@ class WelcomePanel : public Component
820820
}
821821

822822
if (recentlyOpenedTree.isValid()) {
823-
// Place favourited patches at the top
824-
for (int i = 0; i < recentlyOpenedTree.getNumChildren(); i++) {
825-
823+
for (int i = recentlyOpenedTree.getNumChildren() - 1; i >= 0 ; i--) {
826824
auto subTree = recentlyOpenedTree.getChild(i);
827825
auto patchFile = File(subTree.getProperty("Path").toString());
828-
829826
if(!File(patchFile).existsAsFile())
830827
{
831828
if(!subTree.hasProperty("Removable"))
832829
{
833-
recentlyOpenedTree.removeChild(subTree, nullptr);
830+
recentlyOpenedTree.removeChild(i, nullptr);
831+
834832
}
835-
continue;
836833
}
834+
}
835+
836+
// Place favourited patches at the top
837+
for (int i = 0; i < recentlyOpenedTree.getNumChildren(); i++) {
838+
839+
auto subTree = recentlyOpenedTree.getChild(i);
840+
auto patchFile = File(subTree.getProperty("Path").toString());
837841

838842
auto patchThumbnailBase = File(patchFile.getParentDirectory().getFullPathName() + "\\" + patchFile.getFileNameWithoutExtension() + "_thumb");
839843

0 commit comments

Comments
 (0)