Skip to content

Commit

Permalink
Fix for issue 9518 (#9520)
Browse files Browse the repository at this point in the history
* Add regression test for #9518

* More thorough input checks for isPatternMissing function
Fixes regression introduced by #9380

ResolvedImage.fromString may now return null, which potentially leaves CrossFaded<ResolvedImage>
with missing image patterns

I have traced other code paths using ResolvedImage.fromString and have not seen
any other potential offenders
  • Loading branch information
karimnaaji committed Apr 9, 2020
1 parent acb48ab commit 2114824
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/render/painter.js
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,7 @@ class Painter {
*/
isPatternMissing(image: ?CrossFaded<ResolvedImage>): boolean {
if (!image) return false;
if (!image.from || !image.to) return true;
const imagePosA = this.imageManager.getPattern(image.from.toString());
const imagePosB = this.imageManager.getPattern(image.to.toString());
return !imagePosA || !imagePosB;
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"version": 8,
"metadata": {
"test": {
"width": 8,
"height": 8
}
},
"zoom": 3,
"sources": {},
"sprite": "local://sprites/emerald",
"layers": [
{
"id": "background",
"type": "background",
"paint": {
"background-pattern": [
"step",
["zoom"],
"",
5,
"cemetery_icon"
]
}
}
]
}

0 comments on commit 2114824

Please sign in to comment.