Commit 7b0dc7ca authored by Nico Mack's avatar Nico Mack

Minor stability improvements

parent 117815a9
......@@ -156,7 +156,7 @@ public abstract class TangibleObjectManager {
ensureConsistency();
takenCareOf = true;
} else {
TouchEvent event = new TouchEvent(tangibleObject.getObjectId(), tangibleObject.getPosition());
TouchEvent event = new TouchEvent(tangibleObject.getObjectId(), tangibleObject.getPosition().clone());
for (BaseWidget widget : objectMap.values()) {
if (widget.isTouchable()) {
takenCareOf |= widget.touched(event);
......@@ -177,7 +177,7 @@ public abstract class TangibleObjectManager {
cursorMap.get(tangibleObject.getObjectId()).actionMove(tangibleObject);
takenCareOf = true;
} else {
TouchEvent event = new TouchEvent(tangibleObject.getObjectId(), tangibleObject.getPosition());
TouchEvent event = new TouchEvent(tangibleObject.getObjectId(), tangibleObject.getPosition().clone());
for (BaseWidget widget : objectMap.values()) {
if (widget.isTouchable()) {
takenCareOf |= widget.dragged(event);
......@@ -198,7 +198,7 @@ public abstract class TangibleObjectManager {
cursorMap.remove(tangibleObject.getObjectId()).actionLift(tangibleObject);
takenCareOf = true;
} else {
TouchEvent event = new TouchEvent(tangibleObject.getObjectId(), tangibleObject.getPosition());
TouchEvent event = new TouchEvent(tangibleObject.getObjectId(), tangibleObject.getPosition().clone());
for (BaseWidget widget : objectMap.values()) {
if (widget.isTouchable()) {
takenCareOf |= widget.released(event);
......
......@@ -178,9 +178,11 @@ public class TetherManager {
Point tetherOrigin = this.tetherable.getTetherOrigin().toScreenCoordinates();
double shortest = Double.MAX_VALUE;
for (Tetherable tethered : currentlyTethered) {
Point tetherEnding = tethered.getTetherOrigin().toScreenCoordinates();
shortest = Math.min(this.distance(tetherOrigin, tetherEnding), shortest);
synchronized (currentlyTethered) {
for (Tetherable tethered : currentlyTethered) {
Point tetherEnding = tethered.getTetherOrigin().toScreenCoordinates();
shortest = Math.min(this.distance(tetherOrigin, tetherEnding), shortest);
}
}
return shortest;
}
......
......@@ -214,7 +214,7 @@ public class TouchManager implements ActionListener {
public Point getTouchPosition(int touchId) {
Touch touch = this.touches.get(touchId);
return touch.getPosition();
return (touch != null) ? touch.getPosition().clone() : null;
}
// ---------------------------------------------------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment