fix cbz import when no story
authorNiki Roo <niki@nikiroo.be>
Sun, 12 May 2019 12:24:33 +0000 (14:24 +0200)
committerNiki Roo <niki@nikiroo.be>
Sun, 12 May 2019 12:24:33 +0000 (14:24 +0200)
src/be/nikiroo/fanfix/supported/Cbz.java

index dfc1bbb86e90ea4705ca967bd319904484ac49f3..3da65ee728406b0cc21c3e69c425601d700f109e 100644 (file)
@@ -132,25 +132,27 @@ class Cbz extends Epub {
                        story.setChapters(new ArrayList<Chapter>());
 
                        // Check if we can find non-images chapters, for hybrid-cbz support
-                       for (Chapter chap : origStory) {
-                               Boolean isImages = null;
-                               for (Paragraph para : chap) {
-                                       ParagraphType t = para.getType();
-                                       if (isImages == null && !t.isText(true)) {
-                                               isImages = true;
-                                       }
-                                       if (t.isText(false)) {
-                                               String line = para.getContent();
-                                               // Images are saved in text mode as "[image-link]"
-                                               if (!(line.startsWith("[") && line.endsWith("]"))) {
-                                                       isImages = false;
+                       if (origStory != null) {
+                               for (Chapter chap : origStory) {
+                                       Boolean isImages = null;
+                                       for (Paragraph para : chap) {
+                                               ParagraphType t = para.getType();
+                                               if (isImages == null && !t.isText(true)) {
+                                                       isImages = true;
+                                               }
+                                               if (t.isText(false)) {
+                                                       String line = para.getContent();
+                                                       // Images are saved in text mode as "[image-link]"
+                                                       if (!(line.startsWith("[") && line.endsWith("]"))) {
+                                                               isImages = false;
+                                                       }
                                                }
                                        }
-                               }
 
-                               if (isImages != null && !isImages) {
-                                       story.getChapters().add(chap);
-                                       chap.setNumber(story.getChapters().size());
+                                       if (isImages != null && !isImages) {
+                                               story.getChapters().add(chap);
+                                               chap.setNumber(story.getChapters().size());
+                                       }
                                }
                        }