From 8d7ecce4c0644f9498f3fec764d7a20701f88b37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Wed, 28 Dec 2022 09:16:49 +0100 Subject: [PATCH] Fixed #1921 AS3 direct editation - exception on code save - wrong selected ABC --- CHANGELOG.md | 2 ++ .../abc/avm2/parser/script/ActionScript3Parser.java | 8 ++++---- .../flash/importers/FFDecAs3ScriptReplacer.java | 9 ++++++--- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f0ebe25e0..abbd6975a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ All notable changes to this project will be documented in this file. ### Fixed - Copy/Move/Cut with dependencies did not handle original tag when not charactertag - [#1922] FLA/XFL/Canvas/SVG export - exporting DefineBitsJPEG3/4 with alpha as JPEG with PNG extension +- [#1921] AS3 direct editation - exception on code save - wrong selected ABC ## [18.2.0] - 2022-12-27 ### Added @@ -2806,6 +2807,7 @@ All notable changes to this project will be documented in this file. [alpha 8]: https://github.com/jindrapetrik/jpexs-decompiler/compare/alpha7...alpha8 [alpha 7]: https://github.com/jindrapetrik/jpexs-decompiler/releases/tag/alpha7 [#1922]: https://www.free-decompiler.com/flash/issues/1922 +[#1921]: https://www.free-decompiler.com/flash/issues/1921 [#1917]: https://www.free-decompiler.com/flash/issues/1917 [#1827]: https://www.free-decompiler.com/flash/issues/1827 [#1424]: https://www.free-decompiler.com/flash/issues/1424 diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScript3Parser.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScript3Parser.java index f17bcbefa..65be05e6b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScript3Parser.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScript3Parser.java @@ -2640,15 +2640,15 @@ public class ActionScript3Parser { try { SWF.initPlayer(); ABC abc = new ABC(null); - ActionScript3Parser parser = new ActionScript3Parser(swf.getAbcIndex()); + AbcIndexing abcIndex = swf.getAbcIndex(); + abcIndex.selectAbc(abc); + ActionScript3Parser parser = new ActionScript3Parser(abcIndex); parser.addScript(new String(Helper.readFile(src), Utf8Helper.charset), src, classPos, scriptIndex); try ( OutputStream fos = new BufferedOutputStream(new FileOutputStream(new File(dst)))) { abc.saveToStream(fos); - } } catch (Exception ex) { - Logger.getLogger(ActionScript3Parser.class - .getName()).log(Level.SEVERE, null, ex); + Logger.getLogger(ActionScript3Parser.class.getName()).log(Level.SEVERE, null, ex); } System.exit(0); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/FFDecAs3ScriptReplacer.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/FFDecAs3ScriptReplacer.java index c7c899cf8..48d3769d1 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/FFDecAs3ScriptReplacer.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/FFDecAs3ScriptReplacer.java @@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.ScriptPack; import com.jpexs.decompiler.flash.abc.avm2.parser.AVM2ParseException; +import com.jpexs.decompiler.flash.abc.avm2.parser.script.AbcIndexing; import com.jpexs.decompiler.flash.abc.avm2.parser.script.ActionScript3Parser; import com.jpexs.decompiler.flash.abc.types.ScriptInfo; import com.jpexs.decompiler.flash.abc.types.traits.TraitClass; @@ -70,8 +71,10 @@ public class FFDecAs3ScriptReplacer implements As3ScriptReplacerInterface { otherAbcs.remove(abc); abc.script_info.get(oldIndex).delete(abc, true); - - ActionScript3Parser.compile(text, abc, swf.getAbcIndex(), scriptName, newClassIndex, oldIndex, air); + AbcIndexing abcIndex = swf.getAbcIndex(); + abcIndex.selectAbc(abc); + + ActionScript3Parser.compile(text, abc, abcIndex, scriptName, newClassIndex, oldIndex, air); if (pack.isSimple) { // Move newly added script to its position abc.script_info.set(oldIndex, abc.script_info.get(newIndex)); @@ -80,7 +83,7 @@ public class FFDecAs3ScriptReplacer implements As3ScriptReplacerInterface { //??? } abc.script_info.get(oldIndex).setModified(true); - abc.pack();//remove old deleted items + abc.pack();//remove old deleted items ((Tag) abc.parentTag).setModified(true); } catch (AVM2ParseException ex) { abc.script_info.get(oldIndex).delete(abc, false);