mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-05 18:34:45 +00:00
#1240 JPEXS does not use multiple threads for decompilation on Text Search: AS2 is also multi thread now, work status improvements during search
This commit is contained in:
@@ -360,6 +360,7 @@ public class AdvancedSettingsDialog extends AppDialog {
|
||||
String locName = locNames.get(name);
|
||||
|
||||
try {
|
||||
field.setAccessible(true);
|
||||
ConfigurationItem item = (ConfigurationItem) field.get(null);
|
||||
|
||||
ParameterizedType listType = (ParameterizedType) field.getGenericType();
|
||||
@@ -580,6 +581,7 @@ public class AdvancedSettingsDialog extends AppDialog {
|
||||
Field field = fields.get(name);
|
||||
ConfigurationItem item = null;
|
||||
try {
|
||||
field.setAccessible(true);
|
||||
item = (ConfigurationItem) field.get(null);
|
||||
} catch (IllegalArgumentException | IllegalAccessException ex) {
|
||||
// Reflection exceptions. This should never happen
|
||||
|
||||
@@ -851,24 +851,26 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
taskThread.interrupt();
|
||||
}
|
||||
|
||||
Thread t = new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
while (!Thread.currentThread().isInterrupted()) {
|
||||
DecompilerPool d = swf.getDecompilerPool();
|
||||
statusPanel.setStatus(swf.getFileTitle() + " " + d.getStat());
|
||||
if (Configuration._debugMode.get()) {
|
||||
Thread t = new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
while (!Thread.currentThread().isInterrupted()) {
|
||||
DecompilerPool d = swf.getDecompilerPool();
|
||||
statusPanel.setStatus(swf.getFileTitle() + " " + d.getStat());
|
||||
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException ex) {
|
||||
break;
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException ex) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
t.start();
|
||||
taskThread = t;
|
||||
t.start();
|
||||
taskThread = t;
|
||||
}
|
||||
}
|
||||
|
||||
private void updateUi() {
|
||||
|
||||
@@ -44,6 +44,7 @@ import com.jpexs.decompiler.flash.action.parser.ActionParseException;
|
||||
import com.jpexs.decompiler.flash.action.parser.script.ActionScriptLexer;
|
||||
import com.jpexs.decompiler.flash.action.parser.script.ParsedSymbol;
|
||||
import com.jpexs.decompiler.flash.action.parser.script.SymbolType;
|
||||
import com.jpexs.decompiler.flash.cache.ScriptDecompiledListener;
|
||||
import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||
import com.jpexs.decompiler.flash.ecma.EcmaScript;
|
||||
import com.jpexs.decompiler.flash.gui.AppDialog;
|
||||
@@ -101,6 +102,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
@@ -208,8 +210,11 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<ABC
|
||||
final Pattern pat = regexp
|
||||
? Pattern.compile(txt, ignoreCase ? (Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE) : 0)
|
||||
: Pattern.compile(Pattern.quote(txt), ignoreCase ? (Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE) : 0);
|
||||
|
||||
int pos = 0;
|
||||
List<Future<HighlightedText>> futures = new ArrayList<>();
|
||||
String workText = AppStrings.translate("work.searching");
|
||||
String decAdd = ", " + AppStrings.translate("work.decompiling");
|
||||
try {
|
||||
loop:
|
||||
for (final ScriptPack pack : allpacks) {
|
||||
@@ -229,22 +234,33 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<ABC
|
||||
}
|
||||
}
|
||||
|
||||
String workText = AppStrings.translate("work.searching");
|
||||
String decAdd = "";
|
||||
if (!SWF.isCached(pack)) {
|
||||
decAdd = ", " + AppStrings.translate("work.decompiling");
|
||||
}
|
||||
int fpos = pos;
|
||||
Future<HighlightedText> text = SWF.getCachedFuture(pack, new ScriptDecompiledListener<HighlightedText>() {
|
||||
@Override
|
||||
public void onStart() {
|
||||
Main.startWork(workText + " \"" + txt + "\"" + decAdd + " - (" + fpos + "/" + allpacks.size() + ") " + pack.getClassPath().toString() + "... ", worker);
|
||||
}
|
||||
|
||||
Main.startWork(workText + " \"" + txt + "\"" + decAdd + " - (" + pos + "/" + allpacks.size() + ") " + pack.getClassPath().toString() + "... ", worker);
|
||||
Future<HighlightedText> text = SWF.getCachedFuture(pack, (HighlightedText result) -> {
|
||||
if (pat.matcher(result.text).find()) {
|
||||
ABCPanelSearchResult searchResult = new ABCPanelSearchResult(pack);
|
||||
found.add(searchResult);
|
||||
@Override
|
||||
public void onComplete(HighlightedText result) {
|
||||
Main.startWork(workText + " \"" + txt + "\" - (" + fpos + "/" + allpacks.size() + ") " + pack.getClassPath().toString() + "... ", worker);
|
||||
if (pat.matcher(result.text).find()) {
|
||||
ABCPanelSearchResult searchResult = new ABCPanelSearchResult(pack);
|
||||
found.add(searchResult);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
futures.add(text);
|
||||
}
|
||||
|
||||
for (Future<HighlightedText> future : futures) {
|
||||
try {
|
||||
future.get();
|
||||
} catch (ExecutionException ex) {
|
||||
Logger.getLogger(ABCPanel.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
} catch (InterruptedException ex) {
|
||||
for (Future<HighlightedText> future : futures) {
|
||||
future.cancel(true);
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.jpexs.decompiler.flash.action.parser.script.ParsedSymbol;
|
||||
import com.jpexs.decompiler.flash.action.parser.script.SymbolType;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionPush;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ConstantIndex;
|
||||
import com.jpexs.decompiler.flash.cache.ScriptDecompiledListener;
|
||||
import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
|
||||
import com.jpexs.decompiler.flash.gui.AppStrings;
|
||||
@@ -69,6 +70,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -256,30 +258,48 @@ public class ActionPanel extends JPanel implements SearchListener<ActionSearchRe
|
||||
} else {
|
||||
pat = Pattern.compile(Pattern.quote(txt), ignoreCase ? (Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE) : 0);
|
||||
}
|
||||
int pos = 0;
|
||||
for (Entry<String, ASMSource> item : asms.entrySet()) {
|
||||
pos++;
|
||||
String workText = AppStrings.translate("work.searching");
|
||||
String decAdd = "";
|
||||
ASMSource asm = item.getValue();
|
||||
if (!pcode && !SWF.isCached(asm)) {
|
||||
decAdd = ", " + AppStrings.translate("work.decompiling");
|
||||
}
|
||||
|
||||
Main.startWork(workText + " \"" + txt + "\"" + decAdd + " - (" + pos + "/" + asms.size() + ") " + item.getKey() + "... ", worker);
|
||||
try {
|
||||
int pos = 0;
|
||||
List<Future<HighlightedText>> futures = new ArrayList<>();
|
||||
String workText = AppStrings.translate("work.searching");
|
||||
String decAdd = ", " + AppStrings.translate("work.decompiling");
|
||||
try {
|
||||
for (Entry<String, ASMSource> item : asms.entrySet()) {
|
||||
pos++;
|
||||
ASMSource asm = item.getValue();
|
||||
|
||||
if (pcode) {
|
||||
Main.startWork(workText + " \"" + txt + "\" - (" + pos + "/" + asms.size() + ") " + item.getKey() + "... ", worker);
|
||||
HighlightedTextWriter writer = new HighlightedTextWriter(Configuration.getCodeFormatting(), true);
|
||||
asm.getASMSource(ScriptExportMode.PCODE, writer, null);
|
||||
String text = writer.toString();
|
||||
if (pat.matcher(text).find()) {
|
||||
found.add(new ActionSearchResult(asm, pcode, item.getKey()));
|
||||
}
|
||||
} else if (pat.matcher(SWF.getCached(asm, null).text).find()) {
|
||||
found.add(new ActionSearchResult(asm, pcode, item.getKey()));
|
||||
} else {
|
||||
int fpos = pos;
|
||||
Future<HighlightedText> text = SWF.getCachedFuture(asm, null, new ScriptDecompiledListener<HighlightedText>() {
|
||||
@Override
|
||||
public void onStart() {
|
||||
Main.startWork(workText + " \"" + txt + "\"" + decAdd + " - (" + fpos + "/" + asms.size() + ") " + item.getKey() + "... ", worker);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete(HighlightedText result) {
|
||||
Main.startWork(workText + " \"" + txt + "\"" + decAdd + " - (" + fpos + "/" + asms.size() + ") " + item.getKey() + "... ", worker);
|
||||
if (pat.matcher(result.text).find()) {
|
||||
ActionSearchResult searchResult = new ActionSearchResult(asm, pcode, item.getKey());
|
||||
found.add(searchResult);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
futures.add(text);
|
||||
}
|
||||
} catch (InterruptedException ex) {
|
||||
break;
|
||||
}
|
||||
} catch (InterruptedException ex) {
|
||||
for (Future<HighlightedText> future : futures) {
|
||||
future.cancel(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user