mirror of
https://github.com/skylot/jadx.git
synced 2024-11-24 05:09:55 +00:00
gui: fix incorrect settings loading
This commit is contained in:
parent
001fa639be
commit
118fa98ca9
@ -11,7 +11,7 @@ import org.slf4j.LoggerFactory;
|
||||
public class JadxCLI {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(JadxCLI.class);
|
||||
|
||||
public static void main(String[] args) throws JadxException {
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
JadxCLIArgs jadxArgs = new JadxCLIArgs();
|
||||
if (processArgs(jadxArgs, args)) {
|
||||
|
@ -25,6 +25,8 @@ import com.beust.jcommander.ParameterException;
|
||||
|
||||
public class JadxCLIArgs implements IJadxArgs {
|
||||
|
||||
protected static final int DEFAULT_THREADS_COUNT = Math.max(1, Runtime.getRuntime().availableProcessors() / 2);
|
||||
|
||||
@Parameter(description = "<input file> (.dex, .apk, .jar or .class)")
|
||||
protected List<String> files;
|
||||
|
||||
@ -32,7 +34,7 @@ public class JadxCLIArgs implements IJadxArgs {
|
||||
protected String outDirName;
|
||||
|
||||
@Parameter(names = {"-j", "--threads-count"}, description = "processing threads count")
|
||||
protected int threadsCount = Math.max(1, Runtime.getRuntime().availableProcessors() / 2);
|
||||
protected int threadsCount = DEFAULT_THREADS_COUNT;
|
||||
|
||||
@Parameter(names = {"-r", "--no-res"}, description = "do not decode resources")
|
||||
protected boolean skipResources = false;
|
||||
@ -108,7 +110,7 @@ public class JadxCLIArgs implements IJadxArgs {
|
||||
}
|
||||
try {
|
||||
if (threadsCount <= 0) {
|
||||
throw new JadxException("Threads count must be positive");
|
||||
throw new JadxException("Threads count must be positive, got: " + threadsCount);
|
||||
}
|
||||
if (files != null) {
|
||||
for (String fileName : files) {
|
||||
|
@ -43,6 +43,12 @@ public class JadxSettings extends JadxCLIArgs {
|
||||
JadxSettingsAdapter.store(this);
|
||||
}
|
||||
|
||||
public void fixOnLoad() {
|
||||
if (threadsCount <= 0) {
|
||||
threadsCount = DEFAULT_THREADS_COUNT;
|
||||
}
|
||||
}
|
||||
|
||||
public String getLastOpenFilePath() {
|
||||
return lastOpenFilePath;
|
||||
}
|
||||
|
@ -50,6 +50,7 @@ public class JadxSettingsAdapter {
|
||||
return new JadxSettings();
|
||||
}
|
||||
LOG.debug("Loaded settings: {}", makeString(settings));
|
||||
settings.fixOnLoad();
|
||||
return settings;
|
||||
} catch (Exception e) {
|
||||
LOG.error("Error load settings", e);
|
||||
|
Loading…
Reference in New Issue
Block a user