-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
prevent non-init map NPEs #1745
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1022,9 +1022,12 @@ private List<Point> buildBoundingBox() { | |
boundingBox = firstPiece.getShape().getBounds(); | ||
//JY | ||
final ASLMap map = (ASLMap) firstPiece.getMap(); | ||
double pZoom = map.PieceScalerBoardZoom(firstPiece); | ||
if (!(firstPiece instanceof Stack)) { | ||
boundingBox = this.scalePiece(firstPiece.getShape().getBounds(), pZoom); //Centred on 0 0, with min and max corresponding to width | ||
double pZoom; | ||
if (map != null) { | ||
pZoom = map.PieceScalerBoardZoom(firstPiece); | ||
if (!(firstPiece instanceof Stack)) { | ||
boundingBox = this.scalePiece(firstPiece.getShape().getBounds(), pZoom); //Centred on 0 0, with min and max corresponding to width | ||
} | ||
} | ||
//JY | ||
relativePositions.add(new Point(0, 0)); | ||
|
@@ -1148,7 +1151,11 @@ private void drawDragImage(BufferedImage image, Component target, | |
//JY | ||
//final Map map = piece.getMap(); | ||
final ASLMap map = (ASLMap) piece.getMap(); | ||
double pZoom = ((ASLMap)map).PieceScalerBoardZoom(piece); | ||
|
||
double pZoom = 0.0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you sure you want There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think its fine to change it to 1.0 or anything really, it just needs to be initialized to something so it can be built. Outside of the un-initialized "map" at startup on Linux it doesn't matter becuase once "map" is initialized that value is never used. Here is an example of a stack trace I am trying to prevent from happening. With the changes in this PR they go away.
|
||
if (map != null) { | ||
pZoom = ((ASLMap)map).PieceScalerBoardZoom(piece); | ||
} | ||
//JY | ||
|
||
if (piece instanceof Stack) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simpler would be:
and similar below at 1045.