From 20af9e85559789af33e6d0504005677a9e715e5c Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Thu, 13 Oct 2005 14:48:27 +0000 Subject: [PATCH] fix two crashes related to dEPM. Some crashes remain git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10551 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 11 +++++++++++ src/lyxtext.h | 4 ++-- src/text.C | 4 ++-- src/text2.C | 2 ++ src/text3.C | 12 ++++++++---- 5 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 77cc8d1df8..bd7abe2435 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,14 @@ +2005-10-07 Jean-Marc Lasgouttes + + * text.C (setCursorFromCoordinates): return a bool telling whether + dEPM triggered. + + * text3.C (cursorPrevious): update if needed after + setCursorFromCoordinates (when dEPM triggered). + + * text2.C (cursorDown, cursorUp): make sure to reset the anchor + (otherwise the anchor may be completely wrong and make dEPM assert). + 2005-10-12 Jürgen Spitzmüller * buffer.C: version upgrade to 245. diff --git a/src/lyxtext.h b/src/lyxtext.h index 52f9b6b34b..ab1362d932 100644 --- a/src/lyxtext.h +++ b/src/lyxtext.h @@ -176,8 +176,8 @@ public: void recUndo(pit_type first, pit_type last) const; /// void recUndo(pit_type first) const; - /// - void setCursorFromCoordinates(LCursor & cur, int x, int y); + /// returns true if par was empty and was removed + bool setCursorFromCoordinates(LCursor & cur, int x, int y); /// InsetBase * editXY(LCursor & cur, int x, int y); /// Move cursor one line up. diff --git a/src/text.C b/src/text.C index 425b72f7d0..4603d9a2f9 100644 --- a/src/text.C +++ b/src/text.C @@ -2315,7 +2315,7 @@ pos_type LyXText::x2pos(pit_type pit, int row, int x) const // x,y are screen coordinates // sets cursor only within this LyXText -void LyXText::setCursorFromCoordinates(LCursor & cur, int const x, int const y) +bool LyXText::setCursorFromCoordinates(LCursor & cur, int const x, int const y) { pit_type pit = getPitNearY(y); int yy = theCoords.get(this, pit).y_ - pars_[pit].ascent(); @@ -2354,5 +2354,5 @@ void LyXText::setCursorFromCoordinates(LCursor & cur, int const x, int const y) << " pos: " << pos << endl; - setCursor(cur, pit, pos, true, bound); + return setCursor(cur, pit, pos, true, bound); } diff --git a/src/text2.C b/src/text2.C index 1bc7544ed7..81171bbd20 100644 --- a/src/text2.C +++ b/src/text2.C @@ -1056,6 +1056,7 @@ bool LyXText::cursorUp(LCursor & cur) int const y = bv_funcs::getPos(cur, cur.boundary()).y_; LCursor old = cur; editXY(cur, x, y - par.rows()[row].ascent() - 1); + cur.clearSelection(); // This happens when you move out of an inset. // And to give the DEPM the possibility of doing @@ -1101,6 +1102,7 @@ bool LyXText::cursorDown(LCursor & cur) int const y = bv_funcs::getPos(cur, cur.boundary()).y_; LCursor old = cur; editXY(cur, x, y + par.rows()[row].descent() + 1); + cur.clearSelection(); // This happens when you move out of an inset. // And to give the DEPM the possibility of doing diff --git a/src/text3.C b/src/text3.C index 5c75729a69..5f3323a0cd 100644 --- a/src/text3.C +++ b/src/text3.C @@ -192,8 +192,10 @@ bool LyXText::cursorPrevious(LCursor & cur) int x = cur.x_target(); - setCursorFromCoordinates(cur, x, 0); - bool updated = cursorUp(cur); + bool updated = setCursorFromCoordinates(cur, x, 0); + if (updated) + cur.bv().update(); + updated |= cursorUp(cur); if (cpar == cur.pit() && cpos == cur.pos()) { // we have a row which is taller than the workarea. The @@ -213,8 +215,10 @@ bool LyXText::cursorNext(LCursor & cur) lyx::pit_type cpar = cur.pit(); int x = cur.x_target(); - setCursorFromCoordinates(cur, x, cur.bv().workHeight() - 1); - bool updated = cursorDown(cur); + bool updated = setCursorFromCoordinates(cur, x, cur.bv().workHeight() - 1); + if (updated) + cur.bv().update(); + updated |= cursorDown(cur); if (cpar == cur.pit() && cpos == cur.pos()) { // we have a row which is taller than the workarea. The -- 2.39.5