From b559352215b9eeb93408bc3f384489486cf001ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Wed, 18 Oct 2023 19:25:56 +0200 Subject: [PATCH] Fixed #2013 AS3 Multiname renaming - closing the script when renaming the class, nullpointer exception --- CHANGELOG.md | 2 ++ .../jpexs/decompiler/flash/gui/MainPanel.java | 22 ++++++++++++------- .../flash/gui/abc/ClassesListTreeModel.java | 1 + 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f0e3775c..5dc58e17b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ All notable changes to this project will be documented in this file. ### Fixed - [#1306], [#1768] Maximizing window on other than main monitor - AS3 Cast exception when used tree filter and then direct editing +- [#2013] AS3 Multiname renaming - closing the script when renaming the class, nullpointer exception ## [19.1.2] - 2023-10-16 ### Fixed @@ -3196,6 +3197,7 @@ Major version of SWF to XML export changed to 2. [#1717]: https://www.free-decompiler.com/flash/issues/1717 [#1306]: https://www.free-decompiler.com/flash/issues/1306 [#1768]: https://www.free-decompiler.com/flash/issues/1768 +[#2013]: https://www.free-decompiler.com/flash/issues/2013 [#2099]: https://www.free-decompiler.com/flash/issues/2099 [#2090]: https://www.free-decompiler.com/flash/issues/2090 [#2079]: https://www.free-decompiler.com/flash/issues/2079 diff --git a/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/src/com/jpexs/decompiler/flash/gui/MainPanel.java index 89e7e27a2..b70b1523f 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -1807,15 +1807,25 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se } public void renameMultiname(List abcList, int multiNameIndex) { + SWF swf = getABCPanel().getSwf(); String oldName = ""; AVM2ConstantPool constants = getABCPanel().abc.constants; if (constants.getMultiname(multiNameIndex).name_index > 0) { oldName = constants.getString(constants.getMultiname(multiNameIndex).name_index); } + + String scriptName = abcPanel.decompiledTextArea.getScriptLeaf().getClassPath().toString(); String newName = ViewMessages.showInputDialog(this, translate("rename.enternew"), oldName); if (newName != null) { if (!oldName.equals(newName)) { + + if (oldName.equals(abcPanel.decompiledTextArea.getScriptLeaf().getClassPath().className)) { + scriptName = abcPanel.decompiledTextArea.getScriptLeaf().getClassPath().packageStr.add(newName, "").toPrintableString(true); + } + + final String fScriptName = scriptName; + int mulCount = 0; for (ABCContainerTag cnt : abcList) { ABC abc = cnt.getABC(); @@ -1835,14 +1845,10 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se int fmulCount = mulCount; View.execInEventDispatch(() -> { ViewMessages.showMessageDialog(this, translate("rename.finished.multiname").replace("%count%", Integer.toString(fmulCount))); - if (abcPanel != null) { - abcPanel.reload(); - } - + swf.clearScriptCache(); updateClassesList(); - reload(true); - ABCPanel abcPanel = getABCPanel(); - abcPanel.hilightScript(abcPanel.getSwf(), abcPanel.decompiledTextArea.getScriptLeaf().getClassPath().toString()); + Main.stopWork(); + abcPanel.hilightScript(abcPanel.getSwf(), fScriptName); }); } } @@ -3079,7 +3085,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se @Override protected void done() { - Main.stopWork(); + } }.execute(); diff --git a/src/com/jpexs/decompiler/flash/gui/abc/ClassesListTreeModel.java b/src/com/jpexs/decompiler/flash/gui/abc/ClassesListTreeModel.java index 61a4f192a..4766742a7 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/ClassesListTreeModel.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/ClassesListTreeModel.java @@ -90,6 +90,7 @@ public class ClassesListTreeModel extends AS3ClassTreeItem implements TreeModel allAbcs.add(abc); this.list = abc.getScriptPacks(null, allAbcs); } + setFilter(null); TreeModelEvent event = new TreeModelEvent(this, new TreePath(root)); for (TreeModelListener listener : listeners) { listener.treeStructureChanged(event);