Wrote possible fix for issue #50 (Composite command tries to remove non-existent element)
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
package mock.model.commandFactory;
|
package mock.model.commandFactory;
|
||||||
|
|
||||||
import java.util.ArrayDeque;
|
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
|
import java.util.concurrent.ConcurrentLinkedDeque;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wraps multiple commands into a composite to execute queued commands during a frame.
|
* Wraps multiple commands into a composite to execute queued commands during a frame.
|
||||||
@@ -10,15 +10,15 @@ public class CompositeCommand implements Command {
|
|||||||
private Queue<Command> commands;
|
private Queue<Command> commands;
|
||||||
|
|
||||||
public CompositeCommand() {
|
public CompositeCommand() {
|
||||||
this.commands = new ArrayDeque<>();
|
this.commands = new ConcurrentLinkedDeque<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addCommand(Command command) {
|
public void addCommand(Command command) {
|
||||||
commands.add(command);
|
commands.offer(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
while(!commands.isEmpty()) commands.remove().execute();
|
while(commands.peek() != null) commands.poll().execute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -246,6 +246,11 @@ public class RaceController extends Controller {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
trackBoat.start();
|
trackBoat.start();
|
||||||
|
|
||||||
|
System.out.println(boat.getCurrentLeg().getEndCompoundMark().toString());
|
||||||
|
boat.legProperty().addListener((o, prev, curr) -> {
|
||||||
|
System.out.println(curr.getEndCompoundMark().toString());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
// Fix initial bird's-eye position
|
// Fix initial bird's-eye position
|
||||||
view3D.updatePivot(new Translate(250, 0, 210));
|
view3D.updatePivot(new Translate(250, 0, 210));
|
||||||
|
|||||||
Reference in New Issue
Block a user