]> git.lyx.org Git - features.git/commitdiff
avoid a crash on empty documents (bug 4859)
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 4 Feb 2009 10:46:54 +0000 (10:46 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 4 Feb 2009 10:46:54 +0000 (10:46 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@28345 a592a061-630c-0410-9148-cb99ea01b6c8

src/Text.cpp

index baf75c17c9d0bfce04037f85c265c8f430fe1834..144c070ef8d58251f740669b568b06d46a340503 100644 (file)
@@ -1298,8 +1298,18 @@ bool Text::read(Buffer const & buf, Lexer & lex,
                if (token == "\\begin_body")
                        continue;
 
-               if (token == "\\end_document")
+               if (token == "\\end_document") {
+                       // avoid a crash on weird documents (bug 4859)
+                       if (pars_.empty()) {
+                               Paragraph par;
+                               par.setInsetOwner(insetPtr);
+                               par.params().depth(depth);
+                               par.setFont(0, Font(inherit_font, 
+                                                   buf.params().language));
+                               pars_.push_back(par);
+                       }
                        return false;
+               }
 
                if (token == "\\begin_layout") {
                        lex.pushToken(token);