]> git.lyx.org Git - features.git/commitdiff
Fix bug 3356 by Bernhard Roider:
authorAbdelrazak Younes <younes@lyx.org>
Wed, 28 Mar 2007 16:01:32 +0000 (16:01 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Wed, 28 Mar 2007 16:01:32 +0000 (16:01 +0000)
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

src/text3.C

index 94827a27132d91fb28165369c526df345ce7f778..6dac2facf7f0d3d044ebf1f62cfe6311022cf959 100644 (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);