From 43ffd2ce511e3e35cc737383712d312d7050cd79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=F8=EDk?= Date: Sat, 22 Jun 2013 19:25:08 +0200 Subject: [PATCH] Issue #67 Fixed skipping rename occasionally --- trunk/src/com/jpexs/decompiler/flash/SWF.java | 31 +++++++++++++------ .../action/treemodel/DirectValueTreeItem.java | 11 +++++-- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/trunk/src/com/jpexs/decompiler/flash/SWF.java b/trunk/src/com/jpexs/decompiler/flash/SWF.java index b0d0a39a6..e76171418 100644 --- a/trunk/src/com/jpexs/decompiler/flash/SWF.java +++ b/trunk/src/com/jpexs/decompiler/flash/SWF.java @@ -1359,21 +1359,32 @@ public class SWF { String name = ti.toStringNoH(allVariableNames.get(ti)); String changed = deobfuscateName(deobfuscated, name, false); if (changed != null) { - /*boolean addNew=false; - for (DirectValueTreeItem snv : stringsNoVar.keySet()) { - if (stringsNoVar.get(snv) == allVariableNames.get(ti)) { //Same constantpool - if(snv.toStringNoH(stringsNoVar.get(snv)).equals(name)){ //Same string - addNew = true; - break; - } - } - }*/ + boolean addNew = false; + for (DirectValueTreeItem snv : stringsNoVar.keySet()) { + if (stringsNoVar.get(snv) == allVariableNames.get(ti)) { //Same constantpool + if (snv.toStringNoH(stringsNoVar.get(snv)).equals(name)) { //Same string + addNew = true; + break; + } + } + } ActionPush pu = (ActionPush) ti.src; if (pu.replacement == null) { pu.replacement = new ArrayList<>(); pu.replacement.addAll(pu.values); } - pu.replacement.set(ti.pos, changed); + if (pu.replacement.get(ti.pos) instanceof ConstantIndex) { + ConstantIndex ci = (ConstantIndex) pu.replacement.get(ti.pos); + ConstantPool pool = allVariableNames.get(ti); + if (addNew) { + pool.constants.add(changed); + ci.index = pool.constants.size() - 1; + } else { + pool.constants.set(ci.index, changed); + } + } else { + pu.replacement.set(ti.pos, changed); + } ret++; } } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/treemodel/DirectValueTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/action/treemodel/DirectValueTreeItem.java index b0513cff0..782478636 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/treemodel/DirectValueTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/treemodel/DirectValueTreeItem.java @@ -22,6 +22,7 @@ import com.jpexs.decompiler.flash.graph.GraphSourceItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; import com.jpexs.decompiler.flash.helpers.Helper; import java.util.List; +import java.util.Objects; public class DirectValueTreeItem extends TreeItem { @@ -194,7 +195,6 @@ public class DirectValueTreeItem extends TreeItem { @Override public int hashCode() { int hash = 7; - hash = 97 * hash + (this.value != null ? this.value.hashCode() : 0); return hash; } @@ -207,9 +207,16 @@ public class DirectValueTreeItem extends TreeItem { return false; } final DirectValueTreeItem other = (DirectValueTreeItem) obj; - if (this.value != other.value && (this.value == null || !this.value.equals(other.value))) { + if (!Objects.equals(this.value, other.value)) { + return false; + } + if (!Objects.equals(this.constants, other.constants)) { + return false; + } + if(other.pos!=this.pos){ return false; } return true; } + }