Fix opening nonexistent files on restoring last session

This commit is contained in:
Jindra Petřík
2015-06-07 14:55:26 +02:00
parent a5933ca43f
commit 16a48a6004
+13 -7
View File
@@ -1143,15 +1143,21 @@ public class Main {
String lastSession = Configuration.lastSessionFiles.get();
if (lastSession != null && lastSession.length() > 0) {
String[] filesToOpen = lastSession.split(File.pathSeparator, -1);
SWFSourceInfo[] sourceInfos = new SWFSourceInfo[filesToOpen.length];
List<String> exfiles = new ArrayList<>();
for (int i = 0; i < filesToOpen.length; i++) {
String fileToOpen = filesToOpen[i];
sourceInfos[i] = new SWFSourceInfo(null, fileToOpen, null);
if (new File(filesToOpen[i]).exists()) {
exfiles.add(filesToOpen[i]);
}
}
SWFSourceInfo[] sourceInfos = new SWFSourceInfo[exfiles.size()];
for (int i = 0; i < exfiles.size(); i++) {
sourceInfos[i] = new SWFSourceInfo(null, exfiles.get(i), null);
}
if (sourceInfos.length > 0) {
openFile(sourceInfos, () -> {
mainFrame.getPanel().tagTree.setSelectionPathString(Configuration.lastSessionSelection.get());
});
}
openFile(sourceInfos, () -> {
mainFrame.getPanel().tagTree.setSelectionPathString(Configuration.lastSessionSelection.get());
});
}
}
}