未验证 提交 4586015f 编写于 作者: J Jan S 提交者: GitHub

fix(gui): resolve NPE on project save (#1463)(PR #1464)

* fix(gui): NullPointerException on project save

* chore(gui): ensure MainWindow.project is never null
* ensure `files` in `ProjectData` in not null
Co-authored-by: NSkylot <skylot@gmail.com>
上级 1832f2ae
...@@ -4,13 +4,14 @@ import java.nio.file.Path; ...@@ -4,13 +4,14 @@ import java.nio.file.Path;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Objects;
import jadx.api.data.impl.JadxCodeData; import jadx.api.data.impl.JadxCodeData;
public class ProjectData { public class ProjectData {
private int projectVersion = 1; private int projectVersion = 1;
private List<Path> files; private List<Path> files = new ArrayList<>();
private List<String[]> treeExpansions = new ArrayList<>(); private List<String[]> treeExpansions = new ArrayList<>();
private JadxCodeData codeData = new JadxCodeData(); private JadxCodeData codeData = new JadxCodeData();
private List<TabViewState> openTabs = Collections.emptyList(); private List<TabViewState> openTabs = Collections.emptyList();
...@@ -21,7 +22,7 @@ public class ProjectData { ...@@ -21,7 +22,7 @@ public class ProjectData {
} }
public void setFiles(List<Path> files) { public void setFiles(List<Path> files) {
this.files = files; this.files = Objects.requireNonNull(files);
} }
public List<String[]> getTreeExpansions() { public List<String[]> getTreeExpansions() {
......
...@@ -76,6 +76,7 @@ import javax.swing.tree.TreePath; ...@@ -76,6 +76,7 @@ import javax.swing.tree.TreePath;
import javax.swing.tree.TreeSelectionModel; import javax.swing.tree.TreeSelectionModel;
import org.fife.ui.rsyntaxtextarea.Theme; import org.fife.ui.rsyntaxtextarea.Theme;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -178,7 +179,8 @@ public class MainWindow extends JFrame { ...@@ -178,7 +179,8 @@ public class MainWindow extends JFrame {
private final transient JadxSettings settings; private final transient JadxSettings settings;
private final transient CacheObject cacheObject; private final transient CacheObject cacheObject;
private final transient BackgroundExecutor backgroundExecutor; private final transient BackgroundExecutor backgroundExecutor;
private transient JadxProject project; @NotNull
private transient JadxProject project = new JadxProject();
private transient Action newProjectAction; private transient Action newProjectAction;
private transient Action saveProjectAction; private transient Action saveProjectAction;
...@@ -516,7 +518,7 @@ public class MainWindow extends JFrame { ...@@ -516,7 +518,7 @@ public class MainWindow extends JFrame {
return jadxProject.getFilePaths(); return jadxProject.getFilePaths();
} }
public void updateProject(JadxProject jadxProject) { public void updateProject(@NotNull JadxProject jadxProject) {
jadxProject.setSettings(settings); jadxProject.setSettings(settings);
jadxProject.setMainWindow(this); jadxProject.setMainWindow(this);
this.project = jadxProject; this.project = jadxProject;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册