fixed bug when deleting tiles

This commit is contained in:
Stephan Richter
2020-12-04 15:20:31 +01:00
parent 6ce8fa1693
commit 35c0666ab2
40 changed files with 50 additions and 107 deletions

View File

@@ -104,7 +104,7 @@ public abstract class Bridge extends Tile {
@Override
public void removeChild(BaseClass child) {
if (child == counterpart) counterpart = null;
plan.place(this);
super.removeChild(child);
}
@Override

View File

@@ -190,6 +190,7 @@ public class Contact extends Tile{
@Override
public void removeChild(BaseClass child) {
if (child == actions) actions = null;
super.removeChild(child);
}
public static Select selector(Contact preselect) {

View File

@@ -33,10 +33,11 @@ public class Shadow extends Tile{
@Override
public void removeChild(BaseClass child) {
super.removeChild(child);
if (child == overlay) {
overlay = null;
remove();
}
}
}
@Override

View File

@@ -77,9 +77,9 @@ public abstract class StretchableTile extends Tile {
@Override
public BaseClass remove() {
super.remove();
LOG.debug("Removing stretchable Tile ({}) {}",id(),this);
removeShadows();
return this;
return super.remove();
}
private void removeShadows() {

View File

@@ -376,16 +376,24 @@ public abstract class Tile extends BaseClass implements Comparable<Tile>{
@Override
public BaseClass remove() {
super.remove();
while (!routes.isEmpty()) routes.first().remove();
return this;
while (!routes.isEmpty()) {
routes.first().remove();
}
return super.remove();
}
@Override
public void removeChild(BaseClass child) {
routes.remove(child);
String childAsString = child.toString();
if (childAsString.length()>20) childAsString = childAsString.substring(0, 20)+"";
LOG.debug("Removing {} from {}",childAsString,this);
if (child instanceof Route) {
routes.remove(child);
}
if (child == train) train = null;
if (child == route) route = null;
super.removeChild(child);
plan.place(this);
}