Fix bug 3356 by Bernhard Roider:

The crash happens on alt+up and alt+down if the position of the cursor
in the moved paragraph is beyond the length of the target paragraph.

To avoid it the Position of the iterators for the target paragraph must
be corrected. I set it to 0 as i assume it is not really used.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17613 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2007-03-28 16:01:32 +00:00
parent 3b9f86926d
commit ae4db7543f

View File

@ -333,6 +333,10 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
std::swap(pars_[pit], pars_[pit + 1]);
ParIterator begin(cur);
// begin.pos() (== cur.pos()) may point beyond the end of the
// paragraph referenced by begin. This would cause a crash
// in updateLabels()
begin.pos() = 0;
++cur.pit();
ParIterator end = boost::next(ParIterator(cur));
updateLabels(cur.buffer(), begin, end);
@ -347,7 +351,12 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
finishUndo();
std::swap(pars_[pit], pars_[pit - 1]);
ParIterator end = boost::next(ParIterator(cur));
ParIterator end = ParIterator(cur);
// end.pos() (== cur.pos()) may point beyond the end of the
// paragraph referenced by end. This would cause a crash
// in boost::next()
end.pos() = 0;
end = boost::next(end);
--cur.pit();
ParIterator begin(cur);
updateLabels(cur.buffer(), begin, end);