From 9960b4c997d361ff2697f69c7ae05ed84c84956b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Tue, 24 Sep 2024 10:04:25 +0200 Subject: [PATCH] Fixed: #2319 AS3 direct editation - class gets removed after pressing cancel --- CHANGELOG.md | 1 + .../flash/importers/FFDecAs3ScriptReplacer.java | 17 +++++++---------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 556638978..13d81149f 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 - [#2319] AS3 Compound assignments problems in some cases +- [#2319] AS3 direct editation - class gets removed after pressing cancel ## [21.1.0] - 2024-09-23 ### Added 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 600778256..a1f9d81bc 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 @@ -54,15 +54,10 @@ public class FFDecAs3ScriptReplacer implements As3ScriptReplacerInterface { String scriptName = pack.getPathScriptName() + ".as"; int oldIndex = pack.scriptIndex; int newIndex = abc.script_info.size(); + AbcIndexing abcIndex = swf.getAbcIndex(); try { ScriptInfo si = abc.script_info.get(oldIndex); - if (pack.isSimple) { - si.delete(abc, true); - } else { - for (int t : pack.traitIndices) { - si.traits.traits.get(t).delete(abc, true); - } - } + pack.delete(abc, true); int newClassIndex = abc.instance_info.size(); for (int t : pack.traitIndices) { @@ -74,9 +69,7 @@ public class FFDecAs3ScriptReplacer implements As3ScriptReplacerInterface { } List otherAbcs = new ArrayList<>(pack.allABCs); - otherAbcs.remove(abc); - abc.script_info.get(oldIndex).delete(abc, true); - AbcIndexing abcIndex = swf.getAbcIndex(); + otherAbcs.remove(abc); abcIndex.selectAbc(abc); abcIndex.refreshAbc(abc); @@ -92,9 +85,13 @@ public class FFDecAs3ScriptReplacer implements As3ScriptReplacerInterface { abc.pack(); //remove old deleted items ((Tag) abc.parentTag).setModified(true); } catch (AVM2ParseException ex) { + pack.delete(abc, false); + abcIndex.refreshAbc(abc); //ex.printStackTrace(); throw new As3ScriptReplaceException(new As3ScriptReplaceExceptionItem(null, ex.text, (int) ex.line)); } catch (CompilationException ex) { + pack.delete(abc, false); + abcIndex.refreshAbc(abc); //ex.printStackTrace(); throw new As3ScriptReplaceException(new As3ScriptReplaceExceptionItem(null, ex.text, (int) ex.line)); }