mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-07 12:24:58 +10:00
Fixed null pointer exceptions when trying to add components to the layout in some cases
This commit is contained in:
@@ -25,12 +25,13 @@ import java.awt.geom.Point2D;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.diylc.appframework.miscutils.ConfigurationManager;
|
||||
import org.diylc.clipboard.ComponentTransferable;
|
||||
@@ -341,17 +342,17 @@ public class InstantiationManager {
|
||||
*/
|
||||
public String createUniqueName(ComponentType componentType, List<IDIYComponent<?>> components) {
|
||||
boolean exists = true;
|
||||
String[] takenNames = new String[components.size()];
|
||||
for (int j = 0; j < components.size(); j++) {
|
||||
takenNames[j] = components.get(j).getName();
|
||||
}
|
||||
Arrays.sort(takenNames);
|
||||
|
||||
Set<String> takenNames = components.stream()
|
||||
.map(x -> x.getName())
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toSet());
|
||||
int i = 0;
|
||||
while (exists) {
|
||||
i++;
|
||||
String name = componentType.getNamePrefix() + i;
|
||||
exists = false;
|
||||
if (Arrays.binarySearch(takenNames, name) >= 0) {
|
||||
if (takenNames.contains(name)) {
|
||||
exists = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4474,6 +4474,10 @@
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>'Save As' displays the current file name by default</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>Fixed null pointer exceptions when trying to add components to the layout in some cases</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
</changes>
|
||||
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
||||
</org.diylc.appframework.update.Version>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -24,7 +24,6 @@ import java.awt.datatransfer.ClipboardOwner;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.geom.Area;
|
||||
import java.awt.print.PrinterJob;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
@@ -48,8 +47,6 @@ import javax.swing.JOptionPane;
|
||||
import javax.swing.KeyStroke;
|
||||
import javax.swing.filechooser.FileFilter;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.pdfbox.pdmodel.PDDocument;
|
||||
import org.apache.pdfbox.printing.PDFPageable;
|
||||
import org.diylc.appframework.miscutils.ConfigurationManager;
|
||||
import org.diylc.appframework.miscutils.IConfigListener;
|
||||
import org.diylc.appframework.miscutils.InMemoryConfigurationManager;
|
||||
|
||||
Reference in New Issue
Block a user