diff --git a/CHANGELOG.md b/CHANGELOG.md index 4fbea3765..edf76cc36 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ All notable changes to this project will be documented in this file. ## [Unreleased] ### Fixed - Hex view for unknown tags was not scrollable +- [#2269] Nullpointer on importing (ImportAssets) a character that does not exists ## [21.0.1] - 2024-08-08 ### Added @@ -3476,6 +3477,7 @@ Major version of SWF to XML export changed to 2. [alpha 9]: https://github.com/jindrapetrik/jpexs-decompiler/compare/alpha8...alpha9 [alpha 8]: https://github.com/jindrapetrik/jpexs-decompiler/compare/alpha7...alpha8 [alpha 7]: https://github.com/jindrapetrik/jpexs-decompiler/releases/tag/alpha7 +[#2269]: https://www.free-decompiler.com/flash/issues/2269 [#2221]: https://www.free-decompiler.com/flash/issues/2221 [#2267]: https://www.free-decompiler.com/flash/issues/2267 [#2268]: https://www.free-decompiler.com/flash/issues/2268 diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java index 4e04db448..303464cf6 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java @@ -959,7 +959,8 @@ public final class SWF implements SWFContainerItem, Timelined, Openable { for (int importedCharacterId : importedCharacterIds.keySet()) { int exportedCharacterId = importedCharacterIds.get(importedCharacterId); SWF importedSwf = importedCharacterSourceSwfs.get(importedCharacterId); - charsWithImported.put(importedCharacterId, importedSwf.getCharacter(exportedCharacterId)); + CharacterTag exportedCharacter = importedSwf.getCharacter(exportedCharacterId); + charsWithImported.put(importedCharacterId, exportedCharacter); charIdtags.put(importedCharacterId, importedSwf.getCharacterIdTags(exportedCharacterId)); //FIXME? eimages @@ -1617,7 +1618,9 @@ public final class SWF implements SWFContainerItem, Timelined, Openable { if (characterId != -1) { if (t instanceof CharacterTag) { if (characters.containsKey(characterId)) { - logger.log(Level.SEVERE, "SWF already contains characterId={0}", characterId); + CharacterTag ct = (CharacterTag) t; + CharacterTag oldCt = characters.get(characterId); + logger.log(Level.SEVERE, "SWF already contains characterId={0} of type {1}, tried to add type {2}", new Object[]{characterId, oldCt.getTagName(), ct.getTagName()}); } characters.put(characterId, (CharacterTag) t); @@ -2333,6 +2336,10 @@ public final class SWF implements SWFContainerItem, Timelined, Openable { String importedName = importedIdToNameMap.get(importedId); if (exportedNameToIdsMap.containsKey(importedName)) { int exportedId = exportedNameToIdsMap.get(importedName); + if (iSwf.getCharacter(exportedId) == null) { + logger.log(Level.WARNING, "Imported character from URL {0} not found: exported id = {1}, exported name = {2}, imported id = {3}", new Object[]{importTag.getUrl(), exportedId, importedName, importedId}); + continue; + } importedCharacterSourceSwfs.put(importedId, iSwf); importedCharacterIds.put(importedId, exportedId); importedNameToCharacter.put(importedName, importedId); @@ -5137,7 +5144,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable { } return readOnlyTags; - } + } /** * Adds a tag to the SWF.