From 5f37a338f17ff8ca871cc78ce33e1ffcb6f2d404 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sun, 7 Mar 2021 11:12:25 +0100 Subject: [PATCH] Fixed: Goto usage exception and incorrect trait position --- CHANGELOG.md | 1 + .../decompiler/flash/gui/abc/UsageFrame.java | 16 +++++++--------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f53adf15..940cb3068 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ All notable changes to this project will be documented in this file. - Generic tag saving problem - timelined exception - [#1332] Flash viewer - Show directly added images when placeFlagHasImage is true on AS3 swfs - XML Import - not set SWF and Timelined internal values caused an exception on item display +- Goto usage exception and incorrect trait position ## [14.1.0] - 2021-03-05 ### Added diff --git a/src/com/jpexs/decompiler/flash/gui/abc/UsageFrame.java b/src/com/jpexs/decompiler/flash/gui/abc/UsageFrame.java index 34d6f1896..038e08499 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/UsageFrame.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/UsageFrame.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.gui.abc; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.types.Multiname; import com.jpexs.decompiler.flash.abc.types.Namespace; +import com.jpexs.decompiler.flash.abc.usages.ConstVarNameMultinameUsage; import com.jpexs.decompiler.flash.abc.usages.InsideClassMultinameUsageInterface; import com.jpexs.decompiler.flash.abc.usages.MethodMultinameUsage; import com.jpexs.decompiler.flash.abc.usages.MultinameUsage; @@ -64,11 +65,8 @@ public class UsageFrame extends AppDialog implements MouseListener { if (m.namespace_index > 0 && abc.constants.getNamespace(m.namespace_index).kind != Namespace.KIND_PRIVATE) { for (ABCContainerTag at : abc.getAbcTags()) { ABC a = at.getABC(); - if (a == abc) { - continue; - } - int mid = a.constants.getMultinameId(m, false); - if (mid > 0) { + List mids = a.constants.getMultinameIds(m, abc.constants); + for (int mid : mids) { usages.addAll(definitions ? a.findMultinameDefinition(mid) : a.findMultinameUsage(mid)); } } @@ -105,7 +103,7 @@ public class UsageFrame extends AppDialog implements MouseListener { final InsideClassMultinameUsageInterface icu = (InsideClassMultinameUsageInterface) usage; DecompiledEditorPane decompiledTextArea = abcPanel.decompiledTextArea; - ABC abc = abcPanel.abc; + ABC newAbc = icu.getAbc(); Runnable setTrait = new Runnable() { @Override public void run() { @@ -120,12 +118,12 @@ public class UsageFrame extends AppDialog implements MouseListener { traitIndex = tmu.getTraitIndex(); } if (tmu.getTraitsType() == TraitMultinameUsage.TRAITS_TYPE_INSTANCE) { - traitIndex += abc.class_info.get(tmu.getClassIndex()).static_traits.traits.size(); + traitIndex += newAbc.class_info.get(tmu.getClassIndex()).static_traits.traits.size(); } if (tmu instanceof MethodMultinameUsage) { MethodMultinameUsage mmu = (MethodMultinameUsage) usage; if (mmu.isInitializer() == true) { - traitIndex = abc.class_info.get(mmu.getClassIndex()).static_traits.traits.size() + abc.instance_info.get(mmu.getClassIndex()).instance_traits.traits.size() + (mmu.getTraitsType() == TraitMultinameUsage.TRAITS_TYPE_CLASS ? 1 : 0); + traitIndex = newAbc.class_info.get(mmu.getClassIndex()).static_traits.traits.size() + newAbc.instance_info.get(mmu.getClassIndex()).instance_traits.traits.size() + (mmu.getTraitsType() == TraitMultinameUsage.TRAITS_TYPE_CLASS ? 1 : 0); } } decompiledTextArea.gotoTrait(traitIndex); @@ -133,7 +131,7 @@ public class UsageFrame extends AppDialog implements MouseListener { } }; - if (decompiledTextArea.getClassIndex() == icu.getClassIndex() && abc == icu.getAbc()) { + if (decompiledTextArea.getClassIndex() == icu.getClassIndex() && abcPanel.abc == newAbc) { setTrait.run(); } else { decompiledTextArea.addScriptListener(setTrait);