From: Martin Vermeer Date: Mon, 7 Nov 2005 15:02:08 +0000 (+0000) Subject: Fix bug 2115 (crash, selection begin and end different depths) X-Git-Tag: 1.6.10~13801 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=4288e62d0884d3322cc95a6fe29516bf50e89eeb;p=features.git Fix bug 2115 (crash, selection begin and end different depths) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10594 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/ChangeLog b/src/ChangeLog index 1c38fc5a22..c495f9774c 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2005-11-07 Martin Vermeer + + * cursor.C (selectionBegin, selectionEnd): + * text.C (drawSelection): Fix bug 2115: assertion when anchor and + cursor at different depths + 2005-11-03 Jürgen Spitzmüller * bufferview_funcs.C (coordOffset): do not call cursorPos diff --git a/src/cursor.C b/src/cursor.C index ff206f5320..61559ffa22 100644 --- a/src/cursor.C +++ b/src/cursor.C @@ -438,7 +438,9 @@ DocIterator LCursor::selectionBegin() const { if (!selection()) return *this; - return anchor() < top() ? anchor_ : *this; + DocIterator di = (anchor() < top() ? anchor_ : *this); + di.resize(depth()); + return di; } @@ -446,7 +448,12 @@ DocIterator LCursor::selectionEnd() const { if (!selection()) return *this; - return anchor() > top() ? anchor_ : *this; + DocIterator di = (anchor() > top() ? anchor_ : *this); + if (di.depth() > depth()) { + di.resize(depth()); + ++di.pos(); + } + return di; } diff --git a/src/text.C b/src/text.C index 264a732a3c..b56b9f4a46 100644 --- a/src/text.C +++ b/src/text.C @@ -1775,12 +1775,8 @@ void LyXText::drawSelection(PainterInfo & pi, int x , int) const lyxerr << "draw selection at " << x << endl; - // is there a better way of getting these two iterators? - DocIterator beg = cur; - DocIterator end = cur; - - beg.top() = cur.selBegin(); - end.top() = cur.selEnd(); + DocIterator beg = cur.selectionBegin(); + DocIterator end = cur.selectionEnd(); // the selection doesn't touch the visible screen if (bv_funcs::status(pi.base.bv, beg) == bv_funcs::CUR_BELOW @@ -1848,12 +1844,8 @@ void LyXText::drawSelection(PainterInfo & pi, int x, int) const << "draw selection at " << x << endl; - // is there a better way of getting these two iterators? - DocIterator beg = cur; - DocIterator end = cur; - - beg.top() = cur.selBegin(); - end.top() = cur.selEnd(); + DocIterator beg = cur.selectionBegin(); + DocIterator end = cur.selectionEnd(); // the selection doesn't touch the visible screen if (bv_funcs::status(pi.base.bv, beg) == bv_funcs::CUR_BELOW