Repository navigation
Marker: no hit test without a bitmap - #1814
Merged
devemux86 merged 1 commit intoAug 23, 2026
Merged
Conversation
Marker#contains dereferences the bitmap, unlike Marker#draw, which returns early for a
null or destroyed one. A Marker created with a null bitmap - the constructor documents it
as allowed - therefore throws a NullPointerException as soon as it is hit tested:
java.lang.NullPointerException: Cannot invoke "org.mapsforge.core.graphics.Bitmap.getWidth()" because "this.bitmap" is null
at org.mapsforge.map.layer.overlay.Marker.contains(Marker.java:58)
Since such a marker draws nothing, it cannot be hit either.
Co-Authored-By: Claude Opus 5 <[email protected]>
Collaborator
|
@cpesch Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Marker#contains()dereferencesthis.bitmap, whileMarker#draw()returns early for anullor destroyed one. The constructor documents the bitmap as nullable ("the initialBitmapof this marker (may be null)"), so a marker whose icon failed to load throws on the first hit test:Seen in RouteConverter (mapsforge 0.29.0, awt): one failed
renderSvg()of the marker icon at startup turned every subsequent mouse press near a selected position into an uncaught NPE on the AWT event thread. Application-side hardening is in cpesch/RouteConverter#323; this is the upstream half.Since a marker without a usable bitmap draws nothing, it cannot be hit either, so
contains()now returnsfalsefor that case - the same conditiondraw()already uses.🤖 Generated with Claude Code