From 3a44891b26d390d66c5d6b683c87c8cdaed0a835 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sun, 15 Feb 2026 16:12:47 +0100 Subject: [PATCH] Ignore SWF files that are not instrumented by FFDec. Fixed: AS1/2 debug panel not visible on first break --- .../decompiler/flash/gui/DebugPanel.java | 2 +- .../decompiler/flash/gui/DebuggerSession.java | 30 +++++++++++++++++-- src/com/jpexs/decompiler/flash/gui/Main.java | 4 +-- .../jpexs/decompiler/flash/gui/MainPanel.java | 7 +++-- .../flash/gui/action/ActionPanel.java | 1 + .../gui/editor/DebuggableEditorPane.java | 4 ++- 6 files changed, 39 insertions(+), 9 deletions(-) diff --git a/src/com/jpexs/decompiler/flash/gui/DebugPanel.java b/src/com/jpexs/decompiler/flash/gui/DebugPanel.java index 2a7abfd4b..11c78d93c 100644 --- a/src/com/jpexs/decompiler/flash/gui/DebugPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/DebugPanel.java @@ -466,7 +466,7 @@ public class DebugPanel extends JPanel { }); add(new HeaderLabel(AppStrings.translate("debugpanel.header")), BorderLayout.NORTH); - add(varTabs, BorderLayout.CENTER); + add(varTabs, BorderLayout.CENTER); } /* private void getVariableList() { diff --git a/src/com/jpexs/decompiler/flash/gui/DebuggerSession.java b/src/com/jpexs/decompiler/flash/gui/DebuggerSession.java index 07973200f..cdbea6e06 100644 --- a/src/com/jpexs/decompiler/flash/gui/DebuggerSession.java +++ b/src/com/jpexs/decompiler/flash/gui/DebuggerSession.java @@ -323,6 +323,7 @@ public class DebuggerSession { Runnable r = new Runnable() { @Override public void run() { + boolean modulesEmptyBefore = debuggedSwfs.isEmpty(); try { for (InSwfInfo.SwfInfo s : t.swfInfos) { try { @@ -350,11 +351,12 @@ public class DebuggerSession { connected = false; } disconnected(); + return; } else { debuggedSwfs.put((int) s.index, debuggedSwf); if (debuggedSwfs.size() == 1) { //it's the first one con.isAS3 = debuggedSwf.isAS3(); - } + } } } catch (IOException | NoSuchAlgorithmException ex) { //ignore @@ -370,7 +372,26 @@ public class DebuggerSession { } try { - if (!debuggedSwfs.isEmpty()) { + + Set hashes = new LinkedHashSet<>(); + + for (int file : modulePaths.keySet()) { + String path = modulePaths.get(file); + if (!path.contains(":")) { + //This is probably SWF file instrumented by another software + throw new IOException("Missing hash"); + } + String hash = path.substring(0, path.indexOf(":")); + hashes.add(hash); + } + for (String hash : hashes) { + if (Main.findOpenedSwfByHash(hash) == null) { + //This is probably SWF file instrumented by another software + throw new IOException("SWF with hash " + hash + " not found"); + } + } + + if (!debuggedSwfs.isEmpty() && modulesEmptyBefore) { if (con.isAS3) { //Widelines - only AS3, it hangs in AS1/2 and SWD does not support UI32 lines con.wideLines = commands.getOption("wide_line_player", "false").equals("true"); @@ -457,6 +478,11 @@ public class DebuggerSession { @Override public void run() { synchronized (DebuggerSession.this) { + if (!connected) { + return; + } + + paused = true; Logger.getLogger(DebuggerSession.class.getName()).log(Level.FINE, "paused"); } diff --git a/src/com/jpexs/decompiler/flash/gui/Main.java b/src/com/jpexs/decompiler/flash/gui/Main.java index 0767117c2..660d5ca05 100644 --- a/src/com/jpexs/decompiler/flash/gui/Main.java +++ b/src/com/jpexs/decompiler/flash/gui/Main.java @@ -1120,9 +1120,9 @@ public class Main { return null; } SWF currentSwf = mainFrame.getPanel().getCurrentSwf(); - if (currentSwf == null) { + if (currentSwf == null) { return null; - } + } return getDebugHandler().getSessionContainingSwf(currentSwf); } diff --git a/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/src/com/jpexs/decompiler/flash/gui/MainPanel.java index 7c6f78b13..09cbd9fb1 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -2878,7 +2878,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se if (asms.containsKey(rawScriptName)) { oldItem = null; getCurrentTree().setSelectionPath(null); - setTagTreeSelectedNode(getCurrentTree(), asms.get(rawScriptName)); + setTagTreeSelectedNode(getCurrentTree(), asms.get(rawScriptName)); } /*if (actionPanel != null && asms.containsKey(rawScriptName)) { actionPanel.setSource(asms.get(rawScriptName), true); @@ -5776,12 +5776,13 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se private void valueChanged(Object source, TreePath selectedPath) { TreeItem treeItem = selectedPath == null ? null : (TreeItem) selectedPath.getLastPathComponent(); - Main.updateSession(); - if (treeItem == null) { + if (treeItem == null) { updateUi(null); reload(false); return; } + + Main.updateSession(); if (!(treeItem instanceof OpenableList)) { Openable openable = treeItem.getOpenable(); diff --git a/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java b/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java index fb2c472ce..3b1014fac 100644 --- a/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java @@ -1158,6 +1158,7 @@ public class ActionPanel extends JPanel implements SearchListener 0 && ipPath != null && ipHash.equals(myhash) && ipPath.equals(breakPointScriptName)) { addColorMarker(ip + firstLineOffset(), IP_MARKER); }