From 41c6e460c68c9b1237b87ff001a84e7e27654a4a Mon Sep 17 00:00:00 2001 From: Enrico Forestieri Date: Fri, 15 Apr 2011 23:14:21 +0000 Subject: [PATCH] Fix bug #7394 (Crash while selecting texts). See r38385 and r38388. Also replace d->cursor_ with its reference cur, as done everywhere else in BufferView::dispatch(). git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_6_X@38408 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView.cpp | 28 ++++++++++++++++------------ status.16x | 3 +++ 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/BufferView.cpp b/src/BufferView.cpp index aa416f7766..c0cb98a52e 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -1122,8 +1122,7 @@ bool BufferView::dispatch(FuncRequest const & cmd) docstring label = cmd.argument(); if (label.empty()) { InsetRef * inset = - getInsetByCode(d->cursor_, - REF_CODE); + getInsetByCode(cur, REF_CODE); if (inset) { label = inset->getParam("reference"); // persistent=false: use temp_bookmark @@ -1248,23 +1247,25 @@ bool BufferView::dispatch(FuncRequest const & cmd) case LFUN_ALL_CHANGES_ACCEPT: // select complete document - d->cursor_.reset(buffer_.inset()); - d->cursor_.selHandle(true); - buffer_.text().cursorBottom(d->cursor_); + cur.reset(buffer_.inset()); + cur.selHandle(true); + buffer_.text().cursorBottom(cur); // accept everything in a single step to support atomic undo - buffer_.text().acceptOrRejectChanges(d->cursor_, Text::ACCEPT); + buffer_.text().acceptOrRejectChanges(cur, Text::ACCEPT); + cur.resetAnchor(); // FIXME: Move this LFUN to Buffer so that we don't have to do this: processUpdateFlags(Update::Force | Update::FitCursor); break; case LFUN_ALL_CHANGES_REJECT: // select complete document - d->cursor_.reset(buffer_.inset()); - d->cursor_.selHandle(true); - buffer_.text().cursorBottom(d->cursor_); + cur.reset(buffer_.inset()); + cur.selHandle(true); + buffer_.text().cursorBottom(cur); // reject everything in a single step to support atomic undo // Note: reject does not work recursively; the user may have to repeat the operation - buffer_.text().acceptOrRejectChanges(d->cursor_, Text::REJECT); + buffer_.text().acceptOrRejectChanges(cur, Text::REJECT); + cur.resetAnchor(); // FIXME: Move this LFUN to Buffer so that we don't have to do this: processUpdateFlags(Update::Force | Update::FitCursor); break; @@ -1336,7 +1337,7 @@ bool BufferView::dispatch(FuncRequest const & cmd) break; case LFUN_BIBTEX_DATABASE_ADD: { - Cursor tmpcur = d->cursor_; + Cursor tmpcur = cur; findInset(tmpcur, BIBTEX_CODE, false); InsetBibtex * inset = getInsetByCode(tmpcur, BIBTEX_CODE); @@ -1348,7 +1349,7 @@ bool BufferView::dispatch(FuncRequest const & cmd) } case LFUN_BIBTEX_DATABASE_DEL: { - Cursor tmpcur = d->cursor_; + Cursor tmpcur = cur; findInset(tmpcur, BIBTEX_CODE, false); InsetBibtex * inset = getInsetByCode(tmpcur, BIBTEX_CODE); @@ -1507,6 +1508,7 @@ bool BufferView::dispatch(FuncRequest const & cmd) buffer_.changed(); d->text_metrics_[&buffer_.text()].editXY(cur, p.x_, p.y_, true, cmd.action == LFUN_SCREEN_UP); + cur.resetAnchor(); //FIXME: what to do with cur.x_target()? bool update = false; if (in_texted) @@ -1867,6 +1869,8 @@ void BufferView::setCursorFromRow(int row) buffer_.text().setCursor(d->cursor_, 0, 0); else buffer_.text().setCursor(d->cursor_, buffer_.getParFromID(tmpid).pit(), tmppos); + d->cursor_.setSelection(false); + d->cursor_.resetAnchor(); } diff --git a/status.16x b/status.16x index 6721069901..eca53fa3fb 100644 --- a/status.16x +++ b/status.16x @@ -75,6 +75,9 @@ What's new - Fix a crash when requesting the wrong context menu due to paragraphs that are automatically removed between the mouse press and release (bug 7209). +- Fix assertion when selecting with shift+click immediately after reverse + search, accept/reject all changes, or page down/up operations (bug 7394). + - Show mnemonics in context menus that are requested by the keyboard key (only Windows; bug 5414).