Fix crash noticed by Vincent. We don't know that insetText is non-null here!

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26112 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Richard Heck 2008-08-09 16:56:30 +00:00
parent 4e2d14a363
commit b3c5c1ca89

View File

@ -225,7 +225,7 @@ static bool doInsertInset(Cursor & cur, Text * text,
cur.clearSelection(); // bug 393 cur.clearSelection(); // bug 393
cur.finishUndo(); cur.finishUndo();
InsetText * insetText = dynamic_cast<InsetText *>(inset); InsetText * insetText = dynamic_cast<InsetText *>(inset);
if (insetText && !insetText->allowMultiPar() || cur.lastpit() == 0) { if (insetText && (!insetText->allowMultiPar() || cur.lastpit() == 0)) {
// reset first par to default // reset first par to default
cur.text()->paragraphs().begin() cur.text()->paragraphs().begin()
->setPlainOrDefaultLayout(bparams.documentClass()); ->setPlainOrDefaultLayout(bparams.documentClass());
@ -238,9 +238,10 @@ static bool doInsertInset(Cursor & cur, Text * text,
} else { } else {
cur.leaveInset(*inset); cur.leaveInset(*inset);
// reset surrounding par to default // reset surrounding par to default
docstring const layoutname = insetText->usePlainLayout() DocumentClass const & dc = bparams.documentClass();
? bparams.documentClass().plainLayoutName() docstring const layoutname = inset->usePlainLayout()
: bparams.documentClass().defaultLayoutName(); ? dc.plainLayoutName()
: dc.defaultLayoutName();
text->setLayout(cur, layoutname); text->setLayout(cur, layoutname);
} }