was calling remove() on the value, not the key for the contribs, meaning that nothing was ever removed

This commit is contained in:
Ben Fry
2017-08-22 10:04:53 -04:00
parent f8616cad9f
commit 501021f7d6

View File

@@ -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<File, ModeContribution> known) {
for (Entry<File, ModeContribution> 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