]> git.lyx.org Git - features.git/commitdiff
fix two crashes related to dEPM. Some crashes remain
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 13 Oct 2005 14:48:27 +0000 (14:48 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 13 Oct 2005 14:48:27 +0000 (14:48 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10551 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/lyxtext.h
src/text.C
src/text2.C
src/text3.C

index 77cc8d1df840d23aaa92bc5cd131c3c3a7305073..bd7abe24352237765cbd24c996951479a6ce5363 100644 (file)
@@ -1,3 +1,14 @@
+2005-10-07  Jean-Marc Lasgouttes  <lasgouttes@lyx.org>
+
+       * 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  <j.spitzmueller@gmx.de>
 
        * buffer.C: version upgrade to 245.
index 52f9b6b34b292b945551576f8049c539693cf2d0..ab1362d932a490bb776bf9486e73a60ab910edec 100644 (file)
@@ -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.
index 425b72f7d06cbefbc2d807f2c52034ca912d3cfd..4603d9a2f9fc051e17500919bf1d5b9651541dfd 100644 (file)
@@ -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);
 }
index 1bc7544ed77f9b0d11520ead4a191276805c126e..81171bbd20d969123da105e4595775ddbbac5fc7 100644 (file)
@@ -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
index 5c75729a69c18332217517a50146e4b081a25bff..5f3323a0cd1bde047fb0003de8e1d11b9596b99c 100644 (file)
@@ -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