Skip to content

Commit eb616fd

Browse files
committed
feat(as3): allow display of duplicate classes, warn (#2710, #2254)
ScriptPacks that are duplicate - multiple packs with the same name exist - are displayed and can be edited / deleted / ... Previously, there was SEVERE error logged when such state was detected, now only WARNING is issued.
1 parent 5bb8a2c commit eb616fd

2 files changed

Lines changed: 16 additions & 13 deletions

File tree

libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3165,25 +3165,22 @@ public List<ScriptPack> getScriptPacksByClassNames(List<String> classNames) thro
31653165
}
31663166

31673167
/**
3168-
* Makes scriptpacks unique. Unique = no two packs with same classpath
3168+
* Checks scriptpacks whether they are unique. Unique = no two packs with same classpath
31693169
* exist.
31703170
*
31713171
* @param packs List of ScriptPacks
31723172
* @return List of unique ScriptPacks
31733173
*/
3174-
private List<ScriptPack> uniqueAS3Packs(List<ScriptPack> packs) {
3175-
List<ScriptPack> ret = new ArrayList<>();
3174+
private void checkUniqueAS3Packs(List<ScriptPack> packs) {
31763175
Set<ClassPath> classPaths = new HashSet<>();
31773176
for (ScriptPack item : packs) {
31783177
ClassPath key = item.getClassPath();
31793178
if (classPaths.contains(key) && item.isSimple) {
3180-
logger.log(Level.SEVERE, "Duplicate pack path found ({0})!", key);
3179+
logger.log(Level.WARNING, "Duplicate scriptpack path found ({0})!", key);
31813180
} else {
3182-
classPaths.add(key);
3183-
ret.add(item);
3181+
classPaths.add(key);
31843182
}
3185-
}
3186-
return ret;
3183+
}
31873184
}
31883185

31893186
/**
@@ -3205,7 +3202,8 @@ public List<ScriptPack> getAS3Packs() {
32053202
for (ABCContainerTag abcTag : abcList) {
32063203
packs.addAll(abcTag.getABC().getScriptPacks(null, allAbcList));
32073204
}
3208-
return uniqueAS3Packs(packs);
3205+
checkUniqueAS3Packs(packs);
3206+
return packs;
32093207
}
32103208

32113209
/**

libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/AS3Package.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -273,10 +273,15 @@ public List<ScriptPack> getScriptPacks() {
273273
*
274274
* @param script ScriptPack
275275
*/
276-
public void addScriptPack(ScriptPack script) {
277-
/*ClassPath cp = script.getClassPath();
278-
scripts.put(cp.className + cp.namespaceSuffix, script);*/
279-
scripts.put(script.getPrintableNameWithNamespaceSuffix(), script);
276+
public void addScriptPack(ScriptPack script) {
277+
int i = 1;
278+
String baseKey = script.getPrintableNameWithNamespaceSuffix();
279+
String key = baseKey;
280+
while (scripts.containsKey(key)) {
281+
i++;
282+
key = baseKey + i;
283+
}
284+
scripts.put(key, script);
280285
sortedScripts = null;
281286
}
282287

0 commit comments

Comments
 (0)