Commit 118fa98c authored by Skylot's avatar Skylot

gui: fix incorrect settings loading

parent 001fa639
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment