Am Samstag, 17. Februar 2007 22:41 schrieb Bernhard Roider: > Bernhard Roider wrote: > The reason for the crash is that the ERT is constructed with an illegal value for CollapseStatus. > This comes from the lines > > int s; > lex >> s; > if (lex) > status = static_cast<InsetCollapsable::CollapseStatus>(s); > > method InsetERTMailer::string2params(), where the condition if(lex) always returns true even if > there is no status present as in our case. If i change the condition to > > if (lex.isOK()) > > then everything is fine. So i took a closer look into the code: in the first case the method > is.bad() from the stl stream is called, in the second case is.good() is called. My STL book says > (translated from german): > > good() > returns true if the stream is in a good condition. Operations on a stream that does not return true > are ignored. > > bad() > returns true if the integrity of the stream cannot be guaranteed.
Good investigation! > So maybe the attached patch is the one that solves the problem best. But this needs further > investigation if other parts of lyx are broken then. I would rather go the safe way. I am going to apply the attached patch instead, it is 100% safe. I am not sure whether the cases where if (!lex) is used should be changed as well or not, but I am not going to investigate further for now. Georg
Index: src/insets/insetvspace.C =================================================================== --- src/insets/insetvspace.C (Revision 17280) +++ src/insets/insetvspace.C (Arbeitskopie) @@ -88,7 +88,7 @@ void InsetVSpace::read(Buffer const &, L BOOST_ASSERT(lex.isOK()); string vsp; lex >> vsp; - if (lex) + if (lex.isOK()) space_ = VSpace(vsp); string end_token; @@ -257,7 +257,7 @@ void InsetVSpaceMailer::string2params(st string vsp; lex >> vsp; - if (lex) + if (lex.isOK()) vspace = VSpace(vsp); } Index: src/insets/insetert.C =================================================================== --- src/insets/insetert.C (Revision 17280) +++ src/insets/insetert.C (Arbeitskopie) @@ -466,7 +466,7 @@ void InsetERTMailer::string2params(strin int s; lex >> s; - if (lex) + if (lex.isOK()) status = static_cast<InsetCollapsable::CollapseStatus>(s); } Index: src/insets/insetnote.C =================================================================== --- src/insets/insetnote.C (Revision 17280) +++ src/insets/insetnote.C (Arbeitskopie) @@ -105,7 +105,7 @@ void InsetNoteParams::read(LyXLex & lex) { string label; lex >> label; - if (lex) + if (lex.isOK()) type = notetranslator().find(label); }