From: Jean-Marc Lasgouttes Date: Tue, 23 Jun 2009 14:54:35 +0000 (+0000) Subject: Fix bug http://www.lyx.org/trac/ticket/6026 X-Git-Tag: 2.0.0~6215 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=042c5bf425a5c996440c2e0126c2df913ad91555;p=lyx.git Fix bug http://www.lyx.org/trac/ticket/6026 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 --- diff --git a/src/BufferView.cpp b/src/BufferView.cpp index 3be5cf7cf2..94d8c056ba 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -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) diff --git a/src/Cursor.cpp b/src/Cursor.cpp index 572e062876..85607b2182 100644 --- a/src/Cursor.cpp +++ b/src/Cursor.cpp @@ -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) {