From 2023f17b3a189d1dd31efdc678f3cfca7f040a8c Mon Sep 17 00:00:00 2001 From: Christopher Schnick Date: Wed, 6 Mar 2024 23:46:52 +0100 Subject: [PATCH] Fix NPE --- .../pdxu/app/gui/game/Ck3CoatOfArmsCache.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pdxu-app/src/main/java/com/crschnick/pdxu/app/gui/game/Ck3CoatOfArmsCache.java b/pdxu-app/src/main/java/com/crschnick/pdxu/app/gui/game/Ck3CoatOfArmsCache.java index 849fc215..111c9b3f 100644 --- a/pdxu-app/src/main/java/com/crschnick/pdxu/app/gui/game/Ck3CoatOfArmsCache.java +++ b/pdxu-app/src/main/java/com/crschnick/pdxu/app/gui/game/Ck3CoatOfArmsCache.java @@ -5,6 +5,7 @@ import com.crschnick.pdxu.app.info.SavegameData; import com.crschnick.pdxu.app.installation.GameFileContext; import com.crschnick.pdxu.app.util.CascadeDirectoryHelper; +import com.crschnick.pdxu.app.util.ImageHelper; import com.crschnick.pdxu.io.node.Node; import com.crschnick.pdxu.io.parser.TextFormatParser; import com.crschnick.pdxu.model.GameColor; @@ -59,6 +60,10 @@ static Map getPredefinedColors(GameFileContext } public static Image realmImage(SavegameData data, Ck3Tag tag) { + if (data == null) { + return ImageHelper.DEFAULT_IMAGE; + } + var cache = CacheManager.getInstance().get(Ck3CoatOfArmsCache.class); var cachedImg = cache.realms.get(tag); if (cachedImg != null) { @@ -72,6 +77,10 @@ public static Image realmImage(SavegameData data, Ck3Tag tag) { } public static Image houseImage(Ck3House house, GameFileContext ctx) { + if (house == null) { + return ImageHelper.DEFAULT_IMAGE; + } + var cache = CacheManager.getInstance().get(Ck3CoatOfArmsCache.class); var cachedImg = cache.houses.get(house); if (cachedImg != null) { @@ -83,6 +92,10 @@ public static Image houseImage(Ck3House house, GameFileContext ctx) { } public static Image titleImage(Ck3Title title, GameFileContext ctx) { + if (title == null) { + return ImageHelper.DEFAULT_IMAGE; + } + var cache = CacheManager.getInstance().get(Ck3CoatOfArmsCache.class); var cachedImg = cache.titles.get(title); if (cachedImg != null) {