Breakpoints are hidden until disassembly/decompilation is complete.

Fixed AS1/2 Vanishing source code in some cases
This commit is contained in:
Jindra Petřík
2023-11-26 10:45:06 +01:00
parent f3e3bd941a
commit b976096e57
4 changed files with 36 additions and 2 deletions

View File

@@ -56,6 +56,7 @@ All notable changes to this project will be documented in this file.
- [#2131] Debugger - Breakpoints can be added while SWF is running (not just on pause)
- AS3 Direct editation - types on instance variable values not properly resolved
- AS1/2 Debugger - script was cleared on stop button
- AS1/2 Vanishing source code in some cases
### Changed
- [#2120] Exported assets no longer take names from assigned classes if there is more than 1 assigned class

View File

@@ -916,6 +916,7 @@ public class DecompiledEditorPane extends DebuggableEditorPane implements CaretL
if (decompileNeeded) {
//long timeBefore = System.currentTimeMillis();
setShowMarkers(false);
View.execInEventDispatch(() -> {
setText("// " + AppStrings.translate("work.decompiling") + "...");
});
@@ -924,6 +925,7 @@ public class DecompiledEditorPane extends DebuggableEditorPane implements CaretL
//long timeAfter = System.currentTimeMillis();
//long delta = timeAfter - timeBefore;
//System.err.println("Finished in " + Helper.formatTimeSec(delta));
setShowMarkers(true);
View.execInEventDispatch(() -> {
setSourceCompleted(scriptLeaf, htext);
});
@@ -943,12 +945,14 @@ public class DecompiledEditorPane extends DebuggableEditorPane implements CaretL
try {
get();
} catch (CancellationException ex) {
setShowMarkers(false);
setText("// " + AppStrings.translate("work.canceled"));
} catch (Exception ex) {
Throwable cause = ex;
if (ex instanceof ExecutionException) {
cause = ex.getCause();
}
setShowMarkers(false);
if (cause instanceof CancellationException) {
setText("// " + AppStrings.translate("work.canceled"));
} else {
@@ -966,6 +970,7 @@ public class DecompiledEditorPane extends DebuggableEditorPane implements CaretL
Main.startWork(AppStrings.translate("work.decompiling") + "...", worker);
}
} else {
setShowMarkers(true);
setSourceCompleted(scriptLeaf, decompiledText);
}
}

View File

@@ -516,6 +516,8 @@ public class ActionPanel extends JPanel implements SearchListener<ScriptSearchRe
} else {
decompiledText = SWF.getFromCache(asm);
}
HighlightedText fdecompiledText = decompiledText;
setDecompiledEditMode(false);
setEditMode(false);
@@ -533,20 +535,23 @@ public class ActionPanel extends JPanel implements SearchListener<ScriptSearchRe
ActionList innerActions = actions;
if (disassemblingNeeded) {
View.execInEventDispatch(() -> {
editor.setShowMarkers(false);
setEditorText(asm.getScriptName(), asm.getExportedScriptName(), "; " + AppStrings.translate("work.disassembling") + "...", "text/flasm");
if (decompileNeeded) {
decompiledEditor.setShowMarkers(false);
setDecompiledText("-", "-", "// " + AppStrings.translate("work.waitingfordissasembly") + "...");
}
});
DisassemblyListener listener = getDisassemblyListener();
asm.addDisassemblyListener(listener);
innerActions = asm.getActions();
innerActions = asm.getActions();
asm.removeDisassemblyListener(listener);
}
if (decompileNeeded) {
View.execInEventDispatch(() -> {
decompiledEditor.setShowMarkers(false);
setDecompiledText("-", "-", "// " + AppStrings.translate("work.decompiling") + "...");
});
@@ -555,6 +560,11 @@ public class ActionPanel extends JPanel implements SearchListener<ScriptSearchRe
View.execInEventDispatch(() -> {
setSourceCompleted(asm, htext, finalActions);
});
} else {
ActionList finalActions = innerActions;
View.execInEventDispatch(() -> {
setSourceCompleted(asm, fdecompiledText, finalActions);
});
}
return null;
@@ -571,9 +581,11 @@ public class ActionPanel extends JPanel implements SearchListener<ScriptSearchRe
try {
get();
} catch (CancellationException ex) {
editor.setShowMarkers(false);
setEditorText("-", "-", "; " + AppStrings.translate("work.canceled"), "text/flasm");
} catch (Exception ex) {
logger.log(Level.SEVERE, "Error", ex);
decompiledEditor.setShowMarkers(false);
setDecompiledText("-", "-", "// " + AppStrings.translate("decompilationError") + ": " + ex);
}
});
@@ -583,6 +595,7 @@ public class ActionPanel extends JPanel implements SearchListener<ScriptSearchRe
worker.execute();
setSourceWorker = worker;
if (!Main.isDebugging()) {
decompiledEditor.setShowMarkers(false);
Main.startWork(AppStrings.translate("work.decompiling") + "...", worker);
}
} else {
@@ -596,7 +609,9 @@ public class ActionPanel extends JPanel implements SearchListener<ScriptSearchRe
if (decompiledText == null) {
decompiledText = HighlightedText.EMPTY;
}
editor.setShowMarkers(true);
decompiledEditor.setShowMarkers(true);
lastASM = asm;
lastCode = actions;
lastDecompiled = decompiledText;

View File

@@ -76,6 +76,8 @@ public class DebuggableEditorPane extends LineMarkedEditorPane implements BreakP
protected String breakPointScriptName = null;
private LineNumbersBreakpointsRuler ruler;
private boolean showMarkers = true;
public DebuggableEditorPane() {
@@ -120,6 +122,9 @@ public class DebuggableEditorPane extends LineMarkedEditorPane implements BreakP
if (breakPointScriptName == null) {
return;
}
if (!showMarkers) {
return;
}
Set<Integer> bkptLines = Main.getScriptBreakPoints(breakPointScriptName, false);
@@ -146,6 +151,14 @@ public class DebuggableEditorPane extends LineMarkedEditorPane implements BreakP
}
}
public void setShowMarkers(boolean showMarkers) {
this.showMarkers = showMarkers;
}
public boolean isShowMarkers() {
return showMarkers;
}
@Override
public void setText(String t) {
super.setText(t);