]> git.lyx.org Git - features.git/commitdiff
avoid creating empty paragraph list also in the case of an inner insettext (bug 4859...
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 4 Feb 2009 11:28:29 +0000 (11:28 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 4 Feb 2009 11:28:29 +0000 (11:28 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@28346 a592a061-630c-0410-9148-cb99ea01b6c8

src/Text.cpp

index 144c070ef8d58251f740669b568b06d46a340503..1d8366930a6378ae10e63869291fa97ccc94eada 100644 (file)
@@ -1281,6 +1281,7 @@ bool Text::read(Buffer const & buf, Lexer & lex,
                ErrorList & errorList, InsetText * insetPtr)
 {
        depth_type depth = 0;
+       bool res = true;
 
        while (lex.isOK()) {
                lex.nextToken();
@@ -1299,16 +1300,8 @@ bool Text::read(Buffer const & buf, Lexer & lex,
                        continue;
 
                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;
+                       res = false;
+                       break;
                }
 
                if (token == "\\begin_layout") {
@@ -1339,7 +1332,18 @@ bool Text::read(Buffer const & buf, Lexer & lex,
                        LYXERR0("Handling unknown body token: `" << token << '\'');
                }
        }
-       return true;
+
+       // 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 res;
 }
 
 // Returns the current font and depth as a message.