Skip to content

Commit

Permalink
Fix a crash in primitiveBeCursor
Browse files Browse the repository at this point in the history
Closes #151
  • Loading branch information
fniephaus committed Nov 1, 2021
1 parent 115bc7d commit 8cfb5df
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,9 @@ public void setCursor(final int[] cursorWords, final int[] mask, final int width
}
}
}
cursor = TOOLKIT.createCustomCursor(bufferedImage, new Point(offsetX, offsetY), "TruffleSqueak Cursor");
// Ensure hotspot is within cursor bounds.
final Point hotSpot = new Point(Math.min(Math.max(offsetX, 1), width - 1), Math.min(Math.max(offsetY, 1), height - 1));
cursor = TOOLKIT.createCustomCursor(bufferedImage, hotSpot, "TruffleSqueak Cursor");
}
frame.setCursor(cursor);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,16 @@ protected final PointersObject doCursor(final PointersObject receiver, final Poi
final PointersObject offset = receiver.getFormOffset(cursorReadNode);
final int offsetX = Math.abs(offsetReadNode.executeInt(offset, POINT.X));
final int offsetY = Math.abs(offsetReadNode.executeInt(offset, POINT.Y));
final int[] mask;
final int realDepth;
if (depthProfile.profile(depth == 1)) {
final int[] mask = cursorReadNode.executeNative(maskObject, FORM.BITS).getIntStorage();
image.getDisplay().setCursor(words, mask, width, height, 2, offsetX, offsetY);
mask = cursorReadNode.executeNative(maskObject, FORM.BITS).getIntStorage();
realDepth = 2;
} else {
image.getDisplay().setCursor(words, null, width, height, depth, offsetX, offsetY);
mask = null;
realDepth = depth;
}
image.getDisplay().setCursor(words, mask, width, height, realDepth, offsetX, offsetY);
}
return receiver;
}
Expand Down

0 comments on commit 8cfb5df

Please sign in to comment.