minor bugfix: simulation speed was not restored correctly

This commit is contained in:
Fredrik Osterlind 2013-08-14 12:54:30 +02:00
parent 9cb2fd8465
commit 0b09084b92

View file

@ -659,7 +659,10 @@ public class Simulation extends Observable implements Runnable {
availableMoteTypes,
moteTypeClassName
);
if (newClass != null && !newClass.equals(moteTypeClassName)) {
if (newClass == null) {
throw new MoteType.MoteTypeCreationException("No mote type class selected");
}
if (!newClass.equals(moteTypeClassName)) {
logger.warn("Changing mote type class: " + moteTypeClassName + " -> " + newClass);
moteTypeClassName = newClass;
}
@ -989,7 +992,7 @@ public class Simulation extends Observable implements Runnable {
* @param newSpeedLimit
*/
public void setSpeedLimit(final Double newSpeedLimit) {
invokeSimulationThread(new Runnable() {
Runnable r = new Runnable() {
public void run() {
if (newSpeedLimit == null) {
speedLimitNone = true;
@ -1008,7 +1011,14 @@ public class Simulation extends Observable implements Runnable {
Simulation.this.setChanged();
Simulation.this.notifyObservers(this);
}
});
};
if (!isRunning()) {
/* Simulation is stopped, change speed immediately */
r.run();
} else {
/* Change speed from simulation thread */
invokeSimulationThread(r);
}
}
/**