]> git.lyx.org Git - features.git/commitdiff
Fix bug http://www.lyx.org/trac/ticket/6026
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 23 Jun 2009 14:54:35 +0000 (14:54 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 23 Jun 2009 14:54:35 +0000 (14:54 +0000)
LyX crashes when backward selecting during formula writing

The problem is basically that the anchor is not set (because there is no
selection going on) and BufferView::mouseSetCursor does not handle this.

 * Cursor.cpp (anchor): return immediately when there is no selection.

 * BufferView.cpp (mouseSetCursor): reset anchor before setting cursor

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30245 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView.cpp
src/Cursor.cpp

index 3be5cf7cf283969c8408786d61bc1f72416c5880..94d8c056bac533e22c44d87bca3209b0c1365458 100644 (file)
@@ -1920,6 +1920,7 @@ bool BufferView::mouseSetCursor(Cursor & cur, bool select)
                update |= checkDepm(cur, d->cursor_);
        d->cursor_.macroModeClose();
 
+       d->cursor_.resetAnchor();
        d->cursor_.setCursor(cur);
        d->cursor_.boundary(cur.boundary());
        if (do_selection)
index 572e062876d461d8680adb218b857e59c51eddc2..85607b218239ebba459bacee72d5e2bee3d09397 100644 (file)
@@ -923,6 +923,8 @@ void Cursor::posVisToRowExtremity(bool left)
 
 CursorSlice Cursor::anchor() const
 {
+       if (!selection())
+               return top();
        LASSERT(anchor_.depth() >= depth(), /**/);
        CursorSlice normal = anchor_[depth() - 1];
        if (depth() < anchor_.depth() && top() <= normal) {