fix(gui): processing threads spinner initialization (#1331)(PR #1332)

* fix: processing threads spinner initialization (#1331)
* fix: processing threads spinner initialization (#1331)
This commit is contained in:
Jan S
2022-01-12 15:23:07 +01:00
committed by GitHub
parent a250d0461b
commit 72542fa6f9
2 changed files with 5 additions and 3 deletions
@@ -138,7 +138,7 @@ public class JadxArgs {
}
public void setThreadsCount(int threadsCount) {
this.threadsCount = threadsCount;
this.threadsCount = Math.max(1, threadsCount); // make sure threadsCount >= 1
}
public boolean isCfgOutput() {
@@ -433,8 +433,10 @@ public class JadxSettingsWindow extends JDialog {
needReload();
});
SpinnerNumberModel spinnerModel = new SpinnerNumberModel(
settings.getThreadsCount(), 1, Runtime.getRuntime().availableProcessors() * 2, 1);
// fix for #1331
int threadsCountValue = settings.getThreadsCount();
int threadsCountMax = Math.max(2, Math.max(threadsCountValue, Runtime.getRuntime().availableProcessors() * 2));
SpinnerNumberModel spinnerModel = new SpinnerNumberModel(threadsCountValue, 1, threadsCountMax, 1);
JSpinner threadsCount = new JSpinner(spinnerModel);
threadsCount.addChangeListener(e -> {
settings.setThreadsCount((Integer) threadsCount.getValue());