From 29ed2cc266307af99af42a75922e9d9fd7847db9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sun, 29 Jan 2023 22:11:51 +0100 Subject: [PATCH] Fixed AS3 - Select the trait after adding new Fixed #1955 AS3 - Exception during removing trait --- CHANGELOG.md | 3 +++ .../jpexs/decompiler/flash/gui/abc/ABCPanel.java | 16 ++++++++++++---- .../decompiler/flash/gui/abc/TraitsListItem.java | 14 ++++++++++++-- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 255571382..df90dc60f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,8 @@ All notable changes to this project will be documented in this file. - [#1944] Scroll position not retained on Ctrl+click in the tag tree - [#1940] AS3 decompilation - wrong assignment - AS3 - incorrect switching P-code causing empty text +- AS3 - Select the trait after adding new +- [#1955] AS3 - Exception during removing trait ## [18.3.3] - 2023-01-22 ### Added @@ -2931,6 +2933,7 @@ All notable changes to this project will be documented in this file. [#1954]: https://www.free-decompiler.com/flash/issues/1954 [#1944]: https://www.free-decompiler.com/flash/issues/1944 [#1940]: https://www.free-decompiler.com/flash/issues/1940 +[#1955]: https://www.free-decompiler.com/flash/issues/1955 [#1913]: https://www.free-decompiler.com/flash/issues/1913 [#1894]: https://www.free-decompiler.com/flash/issues/1894 [#1801]: https://www.free-decompiler.com/flash/issues/1801 diff --git a/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java b/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java index 172a790a8..413c52736 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java @@ -122,6 +122,7 @@ import java.util.logging.Logger; import javax.swing.AbstractAction; import javax.swing.BorderFactory; import javax.swing.BoxLayout; +import javax.swing.DefaultListModel; import javax.swing.JButton; import javax.swing.JCheckBoxMenuItem; import javax.swing.JComboBox; @@ -1781,7 +1782,7 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener()); if (scriptTraitsUsed) { final int fTraitIndex = traitIndex; final Traits fTraits = traits; @@ -1802,7 +1803,7 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener()); switch (kind) { case Trait.TRAIT_GETTER: case Trait.TRAIT_SETTER: @@ -1906,8 +1908,14 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener traits = abc.class_info.get(classIndex).static_traits.traits; + if (index >= traits.size()) { + return ""; + } + Trait trait = traits.get(index); trait.convertHeader(null, convertData, "", abc, true, ScriptExportMode.AS, scriptIndex, classIndex, new NulWriter(), new ArrayList<>(), false); HighlightedTextWriter writer = new HighlightedTextWriter(Configuration.getCodeFormatting(), false); trait.toStringHeader(null, convertData, "", abc, true, ScriptExportMode.AS, scriptIndex, classIndex, writer, new ArrayList<>(), false); s = writer.toString(); } else { ConvertData convertData = new ConvertData(); - Trait trait = abc.instance_info.get(classIndex).instance_traits.traits.get(index); + List traits = abc.instance_info.get(classIndex).instance_traits.traits; + if (index >= traits.size()) { + return ""; + } + Trait trait = traits.get(index); trait.convertHeader(null, convertData, "", abc, false, ScriptExportMode.AS, scriptIndex, classIndex, new NulWriter(), new ArrayList<>(), false); HighlightedTextWriter writer = new HighlightedTextWriter(Configuration.getCodeFormatting(), false); trait.toStringHeader(null, convertData, "", abc, false, ScriptExportMode.AS, scriptIndex, classIndex, writer, new ArrayList<>(), false);