You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
i have made a litte test and i got an IllegalArgumentException. First i remove the entity and after this i remove some components from the entity.
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
PooledEngine engine = new PooledEngine();
engine.addSystem((new Issue206SystemTest()).new TestSystemA("A"));
engine.addSystem((new Issue206SystemTest()).new TestSystemAB("AB"));
Entity e = engine.createEntity();
e.add(new TestComponentA());
e.add(new TestComponentB());
engine.addEntity(e);
int d = 0;
engine.update(d++);
System.out.println(d + "=------------------------------------------");
engine.update(d++);
System.out.println(d + "=------------------------------------------");
System.out.println(d + "= deleting " + e);
engine.removeEntity(e);
System.out.println(d + "= removing components from " + e);
e.remove(TestComponentB.class);
e.remove(TestComponentA.class);
engine.update(d++);
System.out.println(d + "=------------------------------------------");
}
public static class TestComponentA extends Component {
}
public static class TestComponentB extends Component {
}
public static class TestComponentC extends Component {
}
class TestSystemA extends IteratingSystem {
private String name;
public TestSystemA(String name) {
super(Family.getFor(TestComponentA.class));
this.name = name;
}
@Override
public void processEntity(Entity e, float d) {
System.out.println("System [" + name + "] processed: " + e);
}
}
class TestSystemAB extends IteratingSystem {
private String name;
public TestSystemAB(String name) {
super(Family.getFor(TestComponentA.class, TestComponentB.class));
this.name = name;
}
@Override
public void processEntity(Entity e, float d) {
System.out.println("System [" + name + "] processed: " + e);
}
}
}
1=------------------------------------------
2=------------------------------------------
2= deleting com.badlogic.ashley.core.PooledEngine$PooledEntity@0
2= removing components from com.badlogic.ashley.core.PooledEngine$PooledEntity@0
Exception in thread "main" java.lang.IllegalArgumentException: object cannot be null.
at com.badlogic.ashley.core.PooledEngine$ComponentPools.free(PooledEngine.java:160)
at com.badlogic.ashley.core.PooledEngine$PooledEntity.remove(PooledEngine.java:113)
at com.krautfactory.tests.ashley.Test.main(Test.java:44)
The text was updated successfully, but these errors were encountered:
chrisapril
changed the title
IllegalArgumentException when removing entity and then components
IllegalArgumentException when removing entity and then removing components
Oct 7, 2014
The exception is simple enough to fix; I've added a null check to the removeInternal function and I'll send in a PR for that.
The reason we even saw the exception seems to be a little more sinister; I'm guessing it's probably related to using a PooledEngine but not using pooled components via createComponent. This is probably related to #78. I'm investigating :)
EDIT: Found it and it's not so bad; when you remove a PooledEntity from an engine, it's reset and all the components attached to the entity are removed. That makes your attempts to remove the components after you've already removed the entity "fail". The really simple null check I added totally solves this but basically
Hi!
i have made a litte test and i got an IllegalArgumentException. First i remove the entity and after this i remove some components from the entity.
1=------------------------------------------
2=------------------------------------------
2= deleting com.badlogic.ashley.core.PooledEngine$PooledEntity@0
2= removing components from com.badlogic.ashley.core.PooledEngine$PooledEntity@0
Exception in thread "main" java.lang.IllegalArgumentException: object cannot be null.
at com.badlogic.ashley.core.PooledEngine$ComponentPools.free(PooledEngine.java:160)
at com.badlogic.ashley.core.PooledEngine$PooledEntity.remove(PooledEngine.java:113)
at com.krautfactory.tests.ashley.Test.main(Test.java:44)
The text was updated successfully, but these errors were encountered: