From: Jean-Marc Lasgouttes Date: Wed, 4 Feb 2009 11:28:29 +0000 (+0000) Subject: avoid creating empty paragraph list also in the case of an inner insettext (bug 4859... X-Git-Tag: 2.0.0~7315 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=a5e8cc750be754a6c7687b45002ba384c8711601;p=lyx.git avoid creating empty paragraph list also in the case of an inner insettext (bug 4859 again) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@28346 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/Text.cpp b/src/Text.cpp index 144c070ef8..1d8366930a 100644 --- a/src/Text.cpp +++ b/src/Text.cpp @@ -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.