From: Richard Heck Date: Sat, 9 May 2009 15:49:09 +0000 (+0000) Subject: Fix outliner crash reported by Vincent. X-Git-Tag: 2.0.0~6633 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=6537f7aca066f136405833225861f01bed2d8ee8;p=features.git Fix outliner crash reported by Vincent. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@29583 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/Text3.cpp b/src/Text3.cpp index b95e84d503..c7392600e1 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -311,12 +311,12 @@ static void outline(OutlineOp mode, Cursor & cur) Buffer & buf = *cur.buffer(); pit_type & pit = cur.pit(); ParagraphList & pars = buf.text().paragraphs(); - ParagraphList::iterator bgn = pars.begin(); + ParagraphList::iterator const bgn = pars.begin(); // The first paragraph of the area to be copied: ParagraphList::iterator start = boost::next(bgn, pit); // The final paragraph of area to be copied: ParagraphList::iterator finish = start; - ParagraphList::iterator end = pars.end(); + ParagraphList::iterator const end = pars.end(); DocumentClass const & tc = buf.params().documentClass(); @@ -333,6 +333,10 @@ static void outline(OutlineOp mode, Cursor & cur) break; } + // Do we need to set insets' buffer_ members, because we copied + // some stuff? We'll assume we do and reset it otherwise. + bool setBuffers = true; + switch (mode) { case OutlineUp: { if (start == pars.begin()) @@ -360,7 +364,7 @@ static void outline(OutlineOp mode, Cursor & cur) start = boost::next(pars.begin(), deletepit); pit = newpit; pars.erase(start, finish); - return; + break; } case OutlineDown: { if (finish == end) @@ -383,7 +387,7 @@ static void outline(OutlineOp mode, Cursor & cur) start = boost::next(bgn, pit); pit = newpit - len; pars.erase(start, finish); - return; + break; } case OutlineIn: { pit_type const len = distance(start, finish); @@ -402,7 +406,8 @@ static void outline(OutlineOp mode, Cursor & cur) } } } - return; + setBuffers = false; + break; } case OutlineOut: { pit_type const len = distance(start, finish); @@ -421,9 +426,20 @@ static void outline(OutlineOp mode, Cursor & cur) } } } - return; + setBuffers = false; + break; } } + if (setBuffers) + // FIXME This only really needs doing for the newly introduced + // paragraphs. Something like: + // pit_type const numpars = distance(start, finish); + // start = boost::next(bgn, pit); + // finish = boost::next(start, numpars); + // for (; start != finish; ++start) + // start->setBuffer(buf); + // But while this seems to work, it is kind of fragile. + buf.inset().setBuffer(buf); }