diff --git a/CHANGELOG.md b/CHANGELOG.md index 3887f6e2e..52e6c2d04 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ All notable changes to this project will be documented in this file. - AS3 Direct editation - Top level classes do not use ":" in their namespace names - AS3 Direct editation - Using "/" separator for method names - Folder preview resizing (scrollbar too long) +- [#1872] Removing PlaceObject/RemoveObject with no characterid with Remove character action ## [16.3.1] - 2022-11-14 ### Fixed @@ -2586,6 +2587,7 @@ All notable changes to this project will be documented in this file. [alpha 7]: https://github.com/jindrapetrik/jpexs-decompiler/releases/tag/alpha7 [#1870]: https://www.free-decompiler.com/flash/issues/1870 [#1869]: https://www.free-decompiler.com/flash/issues/1869 +[#1872]: https://www.free-decompiler.com/flash/issues/1872 [#1867]: https://www.free-decompiler.com/flash/issues/1867 [#1868]: https://www.free-decompiler.com/flash/issues/1868 [#1649]: https://www.free-decompiler.com/flash/issues/1649 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 09cef9b6a..aa6677243 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java @@ -3067,10 +3067,18 @@ public final class SWF implements SWFContainerItem, Timelined { } removeTagWithDependenciesFromTimeline(toRemove, timeline, dependingChars); } - private void removeTagWithDependenciesFromTimeline(Tag toRemove, Timeline timeline, Set dependingChars) { + + public boolean removeCharacterFromTimeline(int characterId, Timeline timeline) { + Set chars = new HashSet<>(); + chars.add(characterId); + return removeTagWithDependenciesFromTimeline(null, timeline, chars); + } + + private boolean removeTagWithDependenciesFromTimeline(Tag toRemove, Timeline timeline, Set dependingChars) { Map stage = new HashMap<>(); Timelined timelined = timeline.timelined; ReadOnlyTagList tags = timelined.getTags(); + boolean modified = false; for (int i = 0; i < tags.size(); i++) { Tag t = tags.get(i); if (t instanceof RemoveTag) { @@ -3081,6 +3089,7 @@ public final class SWF implements SWFContainerItem, Timelined { stage.remove(depth); if (dependingChars.contains(currentCharId)) { timelined.removeTag(i); + modified = true; i--; continue; } @@ -3099,6 +3108,7 @@ public final class SWF implements SWFContainerItem, Timelined { if (placeCharId >= 0 && dependingChars.contains(placeCharId)) { timelined.removeTag(i); + modified = true; i--; continue; } @@ -3108,6 +3118,7 @@ public final class SWF implements SWFContainerItem, Timelined { CharacterIdTag c = (CharacterIdTag) t; if (dependingChars.contains(c.getCharacterId())) { timelined.removeTag(i); + modified = true; i--; continue; } @@ -3115,14 +3126,16 @@ public final class SWF implements SWFContainerItem, Timelined { if (t == toRemove) { timelined.removeTag(i); + modified = true; i--; continue; } if (t instanceof Timelined) { - removeTagWithDependenciesFromTimeline(toRemove, ((Timelined) t).getTimeline(), dependingChars); + modified |= removeTagWithDependenciesFromTimeline(toRemove, ((Timelined) t).getTimeline(), dependingChars); } } + return modified; } private boolean removeTagFromTimeline(Tag toRemove, Timeline timeline) { @@ -3130,7 +3143,7 @@ public final class SWF implements SWFContainerItem, Timelined { int characterId = -1; if (toRemove instanceof CharacterTag) { characterId = ((CharacterTag) toRemove).getCharacterId(); - modified = timeline.removeCharacter(characterId); + modified = removeCharacterFromTimeline(characterId, timeline); } Timelined timelined = timeline.timelined; ReadOnlyTagList tags = timelined.getTags(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/Timeline.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/Timeline.java index 7dd8c8605..265e83149 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/Timeline.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/Timeline.java @@ -559,16 +559,7 @@ public class Timeline { } public boolean removeCharacter(int characterId) { - boolean modified = false; - for (int i = 0; i < timelined.getTags().size(); i++) { - Tag t = timelined.getTags().get(i); - if (t instanceof CharacterIdTag && ((CharacterIdTag) t).getCharacterId() == characterId) { - timelined.removeTag(i); - i--; - modified = true; - } - } - return modified; + return swf.removeCharacterFromTimeline(characterId, this); } public double roundToPixel(double val) {