From 501021f7d64ad97a45a6ee5c8f146ff573b6dc83 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Tue, 22 Aug 2017 10:04:53 -0400 Subject: [PATCH] was calling remove() on the value, not the key for the contribs, meaning that nothing was ever removed --- app/src/processing/app/Base.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index 06b01c083..33bf77c3b 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -31,6 +31,7 @@ import java.io.*; import java.lang.reflect.InvocationTargetException; import java.text.SimpleDateFormat; import java.util.*; +import java.util.Map.Entry; import javax.swing.JFileChooser; import javax.swing.JMenu; @@ -489,7 +490,10 @@ public class Base { System.out.println("Attempting to load " + modeClass + " with resources at " + modeResourcePath); ModeContribution mc = ModeContribution.load(this, new File(modeResourcePath), modeClass); contribModes.add(mc); - known.remove(mc); + File key = getFileForContrib(mc, known); + if (key != null) { + known.remove(key); + } } if (known.size() != 0) { for (ModeContribution mc : known.values()) { @@ -499,6 +503,17 @@ public class Base { } + static private File getFileForContrib(ModeContribution contrib, + Map known) { + for (Entry entry : known.entrySet()) { + if (entry.getValue() == contrib) { + return entry.getKey(); + } + } + return null; + } + + /** * Instantiates and adds new contributed modes to the contribModes list. * Checks for duplicates so the same mode isn't instantiates twice. Does not