mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-18 21:21:54 +00:00
jsyntaxpane issue fixed: Resetting content type for multiple editor panes yields NPE
http://code.google.com/p/jsyntaxpane/issues/detail?id=172 singleton_editor_kit.patch applied
This commit is contained in:
@@ -193,7 +193,7 @@ public class ActionListReader {
|
||||
actions = deobfuscateActionList(listeners, containerSWFOffset, actions, version, ip, path);
|
||||
updateActionLengths(actions, version);
|
||||
removeZeroJumps(actions, version);
|
||||
} catch (TranslateException ex) {
|
||||
} catch (OutOfMemoryError | StackOverflowError | TranslateException ex) {
|
||||
// keep orignal (not deobfuscated) actions
|
||||
Logger.getLogger(ActionListReader.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
|
||||
@@ -182,6 +182,8 @@ public class Configuration {
|
||||
public static final ConfigurationItem<Integer> guiSplitPane2DividerLocation = null;
|
||||
@ConfigurationDefaultInt(3)
|
||||
public static final ConfigurationItem<Integer> saveAsExeScaleMode = null;
|
||||
@ConfigurationDefaultInt(1024 * 100/*100KB*/)
|
||||
public static final ConfigurationItem<Integer> syntaxHighlightLimit = null;
|
||||
|
||||
private enum OSId {
|
||||
|
||||
|
||||
@@ -494,11 +494,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL
|
||||
traitHighlights = cd.getTraitHighlights();
|
||||
methodHighlights = cd.getMethodHighlights();
|
||||
classHighlights = cd.getClassHighlights();
|
||||
if (hilightedCode.length() > 1024 * 1024 * 2/*2MB*/) {
|
||||
setContentType("text/plain");
|
||||
} else {
|
||||
setContentType("text/actionscript");
|
||||
}
|
||||
setContentType("text/actionscript");
|
||||
setText(hilightedCode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,6 +62,12 @@ public class LineMarkedEditorPane extends UndoFixedEditorPane {
|
||||
super.setText(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setText(String t, String contentType) {
|
||||
lastLine = -1;
|
||||
super.setText(t, contentType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paint(Graphics g) {
|
||||
g.setColor(Color.white);
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.gui.abc;
|
||||
|
||||
import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||
import javax.swing.JEditorPane;
|
||||
import javax.swing.text.Document;
|
||||
import jsyntaxpane.SyntaxDocument;
|
||||
@@ -28,8 +29,26 @@ public class UndoFixedEditorPane extends JEditorPane {
|
||||
|
||||
@Override
|
||||
public void setText(String t) {
|
||||
super.setText(t);
|
||||
clearUndos();
|
||||
if (getText() != t) {
|
||||
super.setText(t);
|
||||
clearUndos();
|
||||
}
|
||||
}
|
||||
|
||||
public void setText(String t, String contentType) {
|
||||
if (getText() != t) {
|
||||
// OK to check reference equals, because the string object should be the same
|
||||
super.setText(null);
|
||||
if(t.length() > Configuration.syntaxHighlightLimit.get()){
|
||||
setContentType("text/plain");
|
||||
} else {
|
||||
if (!getContentType().equals(contentType)) {
|
||||
setContentType(contentType);
|
||||
}
|
||||
}
|
||||
super.setText(t);
|
||||
clearUndos();
|
||||
}
|
||||
}
|
||||
|
||||
public void clearUndos() {
|
||||
|
||||
@@ -277,7 +277,31 @@ public class ActionPanel extends JPanel implements ActionListener {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setText(HilightedText text) {
|
||||
private void setDecompiledText(final String text) {
|
||||
View.execInEventDispatch(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
ignoreCarret = true;
|
||||
decompiledEditor.setText(text, "text/actionscript");
|
||||
ignoreCarret = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setEditorText(final String text, final String contentType) {
|
||||
View.execInEventDispatch(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
ignoreCarret = true;
|
||||
editor.setText(text, contentType);
|
||||
ignoreCarret = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setText(HilightedText text, String contentType) {
|
||||
int pos = editor.getCaretPosition();
|
||||
Highlighting lastH = null;
|
||||
for (Highlighting h : disassembledHilights) {
|
||||
@@ -287,22 +311,17 @@ public class ActionPanel extends JPanel implements ActionListener {
|
||||
lastH = h;
|
||||
}
|
||||
String offset = lastH == null ? "0" : lastH.getPropertyString("offset");
|
||||
editor.setText("; " + AppStrings.translate("work.gettinghilights") + "...");
|
||||
// getting hilights is fast now
|
||||
// setEditorText("; " + AppStrings.translate("work.gettinghilights") + "...", "text/flasm");
|
||||
disassembledHilights = text.instructionHilights;
|
||||
String stripped = text.text;
|
||||
/*if(stripped.length()>30000){
|
||||
editor.setContentType("text/plain");
|
||||
}else{
|
||||
editor.setContentType("text/flasm");
|
||||
}*/
|
||||
editor.setText(stripped);
|
||||
setEditorText(stripped, contentType);
|
||||
Highlighting h = Highlighting.search(disassembledHilights, "offset", offset);
|
||||
if (h != null) {
|
||||
if (h.startPos <= editor.getText().length()) {
|
||||
editor.setCaretPosition(h.startPos);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private HilightedText getHilightedText(ExportMode exportMode) {
|
||||
@@ -321,26 +340,24 @@ public class ActionPanel extends JPanel implements ActionListener {
|
||||
|
||||
public void setHex(ExportMode exportMode) {
|
||||
if (exportMode != ExportMode.HEX) {
|
||||
editor.setContentType("text/flasm");
|
||||
if (exportMode == ExportMode.PCODE) {
|
||||
if (srcNoHex == null) {
|
||||
srcNoHex = getHilightedText(exportMode);
|
||||
}
|
||||
setText(srcNoHex);
|
||||
setText(srcNoHex, "text/flasm");
|
||||
} else {
|
||||
if (srcWithHex == null) {
|
||||
srcWithHex = getHilightedText(exportMode);
|
||||
}
|
||||
setText(srcWithHex);
|
||||
setText(srcWithHex, "text/flasm");
|
||||
}
|
||||
} else {
|
||||
editor.setContentType("text/plain");
|
||||
if (srcHexOnly == null) {
|
||||
HilightedTextWriter writer = new HilightedTextWriter(true);
|
||||
Helper.byteArrayToHexWithHeader(writer, src.getActionBytes());
|
||||
srcHexOnly = new HilightedText(writer);
|
||||
}
|
||||
setText(srcHexOnly);
|
||||
setText(srcHexOnly, "text/plain");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -358,7 +375,7 @@ public class ActionPanel extends JPanel implements ActionListener {
|
||||
if (((newpercent > percent) || (!this.phase.equals(phase))) && newpercent <= 100) {
|
||||
percent = newpercent;
|
||||
this.phase = phase;
|
||||
editor.setText("; " + AppStrings.translate("work.disassembling") + " - " + phase + " " + percent + "%...");
|
||||
setEditorText("; " + AppStrings.translate("work.disassembling") + " - " + phase + " " + percent + "%...", "text/flasm");
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -377,9 +394,9 @@ public class ActionPanel extends JPanel implements ActionListener {
|
||||
|
||||
@Override
|
||||
protected Void doInBackground() throws Exception {
|
||||
editor.setText("; " + AppStrings.translate("work.disassembling") + "...");
|
||||
setEditorText("; " + AppStrings.translate("work.disassembling") + "...", "text/flasm");
|
||||
if (Configuration.decompile.get()) {
|
||||
decompiledEditor.setText("//" + AppStrings.translate("work.waitingfordissasembly") + "...");
|
||||
setDecompiledText("//" + AppStrings.translate("work.waitingfordissasembly") + "...");
|
||||
}
|
||||
DisassemblyListener listener = getDisassemblyListener();
|
||||
asm.addDisassemblyListener(listener);
|
||||
@@ -391,7 +408,7 @@ public class ActionPanel extends JPanel implements ActionListener {
|
||||
srcHexOnly = null;
|
||||
setHex(getExportMode());
|
||||
if (Configuration.decompile.get()) {
|
||||
decompiledEditor.setText("//" + AppStrings.translate("work.decompiling") + "...");
|
||||
setDecompiledText("//" + AppStrings.translate("work.decompiling") + "...");
|
||||
if (!useCache) {
|
||||
uncache(asm);
|
||||
}
|
||||
@@ -400,7 +417,7 @@ public class ActionPanel extends JPanel implements ActionListener {
|
||||
decompiledHilights = sc.hilights;
|
||||
lastDecompiled = sc.text;
|
||||
lastASM = asm;
|
||||
decompiledEditor.setText(lastDecompiled);
|
||||
setDecompiledText(lastDecompiled);
|
||||
}
|
||||
setEditMode(false);
|
||||
setDecompiledEditMode(false);
|
||||
@@ -419,9 +436,9 @@ public class ActionPanel extends JPanel implements ActionListener {
|
||||
try {
|
||||
get();
|
||||
} catch (CancellationException ex) {
|
||||
editor.setText("; " + AppStrings.translate("work.canceled"));
|
||||
setEditorText("; " + AppStrings.translate("work.canceled"), "text/flasm");
|
||||
} catch (Exception ex) {
|
||||
decompiledEditor.setText("//Decompilation error: " + ex);
|
||||
setDecompiledText("//Decompilation error: " + ex);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -580,9 +597,7 @@ public class ActionPanel extends JPanel implements ActionListener {
|
||||
Configuration.guiActionSplitPaneDividerLocation.set((int) pce.getNewValue());
|
||||
}
|
||||
});
|
||||
editor.setContentType("text/flasm");
|
||||
editor.setFont(new Font("Monospaced", Font.PLAIN, editor.getFont().getSize()));
|
||||
decompiledEditor.setContentType("text/actionscript");
|
||||
decompiledEditor.setFont(new Font("Monospaced", Font.PLAIN, decompiledEditor.getFont().getSize()));
|
||||
|
||||
//tagTree.addTreeSelectionListener(this);
|
||||
@@ -660,11 +675,9 @@ public class ActionPanel extends JPanel implements ActionListener {
|
||||
|
||||
if (val) {
|
||||
if (rawEdit) {
|
||||
editor.setContentType("text/plain");
|
||||
setText(srcHexOnly);
|
||||
setText(srcHexOnly, "text/plain");
|
||||
} else {
|
||||
editor.setContentType("text/flasm");
|
||||
setText(srcNoHex);
|
||||
setText(srcNoHex, "text/flasm");
|
||||
}
|
||||
editor.setEditable(true);
|
||||
saveButton.setVisible(true);
|
||||
@@ -695,7 +708,7 @@ public class ActionPanel extends JPanel implements ActionListener {
|
||||
int prefLines = lastASM.getPrefixLineCount();
|
||||
if (val) {
|
||||
String newText = lastASM.removePrefixAndSuffix(lastDecompiled);
|
||||
decompiledEditor.setText(newText);
|
||||
setDecompiledText(newText);
|
||||
if (lastLine > -1) {
|
||||
if (lastLine - prefLines >= 0) {
|
||||
decompiledEditor.gotoLine(lastLine - prefLines + 1);
|
||||
@@ -710,7 +723,7 @@ public class ActionPanel extends JPanel implements ActionListener {
|
||||
decLabel.setIcon(View.getIcon("editing16"));
|
||||
} else {
|
||||
String newText = lastDecompiled;
|
||||
decompiledEditor.setText(newText);
|
||||
setDecompiledText(newText);
|
||||
if (lastLine > -1) {
|
||||
decompiledEditor.gotoLine(lastLine + prefLines + 1);
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ public abstract class CancellableWorker<T> implements RunnableFuture<T> {
|
||||
|
||||
@Override
|
||||
public final T get(long timeout, TimeUnit unit) throws InterruptedException,
|
||||
ExecutionException, TimeoutException {
|
||||
ExecutionException, TimeoutException {
|
||||
return future.get(timeout, unit);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user