Skip to content

Commit

Permalink
Prepared fix for issue #1105.
Browse files Browse the repository at this point in the history
  • Loading branch information
nilsschmidt1337 committed Aug 26, 2024
1 parent ebffb8b commit e70929e
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions src/org/nschmidt/ldparteditor/data/GDataCSG.java
Original file line number Diff line number Diff line change
Expand Up @@ -1194,15 +1194,25 @@ static synchronized Set<GColour> getSelectedColours(DatFile df) {
}

static synchronized void selectAllWithSameColours(DatFile df, Set<GColour> allColours) {
Set<GDataCSG> newSelection = new HashSet<>(registeredData.putIfAbsent(df, new HashSet<>()));
for (Iterator<GDataCSG> it = newSelection.iterator(); it.hasNext();) {
final GDataCSG g = it.next();
if (g != null && g.canSelect() && allColours.contains(g.colour)) {
continue;
clearSelection(df);
GDataCSG.staticLock.lock();
try {
Set<GDataCSG> newSelection = new HashSet<>(registeredData.putIfAbsent(df, new HashSet<>()));
for (Iterator<GDataCSG> it = newSelection.iterator(); it.hasNext();) {
final GDataCSG g = it.next();
if (g != null && g.canSelect() && allColours.contains(g.colour)) {
continue;
}
it.remove();
}
selectedBodyMap.get(df).addAll(newSelection);
for (GDataCSG csg : newSelection) {
csg.drawAndParse(null, df, false);
}
it.remove();
GDataCSG.rebuildSelection(df);
} finally {
GDataCSG.staticLock.unlock();
}
selectedBodyMap.get(df).addAll(newSelection);
}

public static synchronized void clearSelection(DatFile df) {
Expand Down

0 comments on commit e70929e

Please sign in to comment.