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
This commit is contained in:
Enrico Forestieri 2011-04-15 23:14:21 +00:00
parent 3fac56f031
commit 41c6e460c6
2 changed files with 19 additions and 12 deletions

View File

@ -1122,8 +1122,7 @@ bool BufferView::dispatch(FuncRequest const & cmd)
docstring label = cmd.argument(); docstring label = cmd.argument();
if (label.empty()) { if (label.empty()) {
InsetRef * inset = InsetRef * inset =
getInsetByCode<InsetRef>(d->cursor_, getInsetByCode<InsetRef>(cur, REF_CODE);
REF_CODE);
if (inset) { if (inset) {
label = inset->getParam("reference"); label = inset->getParam("reference");
// persistent=false: use temp_bookmark // persistent=false: use temp_bookmark
@ -1248,23 +1247,25 @@ bool BufferView::dispatch(FuncRequest const & cmd)
case LFUN_ALL_CHANGES_ACCEPT: case LFUN_ALL_CHANGES_ACCEPT:
// select complete document // select complete document
d->cursor_.reset(buffer_.inset()); cur.reset(buffer_.inset());
d->cursor_.selHandle(true); cur.selHandle(true);
buffer_.text().cursorBottom(d->cursor_); buffer_.text().cursorBottom(cur);
// accept everything in a single step to support atomic undo // 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: // FIXME: Move this LFUN to Buffer so that we don't have to do this:
processUpdateFlags(Update::Force | Update::FitCursor); processUpdateFlags(Update::Force | Update::FitCursor);
break; break;
case LFUN_ALL_CHANGES_REJECT: case LFUN_ALL_CHANGES_REJECT:
// select complete document // select complete document
d->cursor_.reset(buffer_.inset()); cur.reset(buffer_.inset());
d->cursor_.selHandle(true); cur.selHandle(true);
buffer_.text().cursorBottom(d->cursor_); buffer_.text().cursorBottom(cur);
// reject everything in a single step to support atomic undo // reject everything in a single step to support atomic undo
// Note: reject does not work recursively; the user may have to repeat the operation // 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: // FIXME: Move this LFUN to Buffer so that we don't have to do this:
processUpdateFlags(Update::Force | Update::FitCursor); processUpdateFlags(Update::Force | Update::FitCursor);
break; break;
@ -1336,7 +1337,7 @@ bool BufferView::dispatch(FuncRequest const & cmd)
break; break;
case LFUN_BIBTEX_DATABASE_ADD: { case LFUN_BIBTEX_DATABASE_ADD: {
Cursor tmpcur = d->cursor_; Cursor tmpcur = cur;
findInset(tmpcur, BIBTEX_CODE, false); findInset(tmpcur, BIBTEX_CODE, false);
InsetBibtex * inset = getInsetByCode<InsetBibtex>(tmpcur, InsetBibtex * inset = getInsetByCode<InsetBibtex>(tmpcur,
BIBTEX_CODE); BIBTEX_CODE);
@ -1348,7 +1349,7 @@ bool BufferView::dispatch(FuncRequest const & cmd)
} }
case LFUN_BIBTEX_DATABASE_DEL: { case LFUN_BIBTEX_DATABASE_DEL: {
Cursor tmpcur = d->cursor_; Cursor tmpcur = cur;
findInset(tmpcur, BIBTEX_CODE, false); findInset(tmpcur, BIBTEX_CODE, false);
InsetBibtex * inset = getInsetByCode<InsetBibtex>(tmpcur, InsetBibtex * inset = getInsetByCode<InsetBibtex>(tmpcur,
BIBTEX_CODE); BIBTEX_CODE);
@ -1507,6 +1508,7 @@ bool BufferView::dispatch(FuncRequest const & cmd)
buffer_.changed(); buffer_.changed();
d->text_metrics_[&buffer_.text()].editXY(cur, p.x_, p.y_, d->text_metrics_[&buffer_.text()].editXY(cur, p.x_, p.y_,
true, cmd.action == LFUN_SCREEN_UP); true, cmd.action == LFUN_SCREEN_UP);
cur.resetAnchor();
//FIXME: what to do with cur.x_target()? //FIXME: what to do with cur.x_target()?
bool update = false; bool update = false;
if (in_texted) if (in_texted)
@ -1867,6 +1869,8 @@ void BufferView::setCursorFromRow(int row)
buffer_.text().setCursor(d->cursor_, 0, 0); buffer_.text().setCursor(d->cursor_, 0, 0);
else else
buffer_.text().setCursor(d->cursor_, buffer_.getParFromID(tmpid).pit(), tmppos); buffer_.text().setCursor(d->cursor_, buffer_.getParFromID(tmpid).pit(), tmppos);
d->cursor_.setSelection(false);
d->cursor_.resetAnchor();
} }

View File

@ -75,6 +75,9 @@ What's new
- Fix a crash when requesting the wrong context menu due to paragraphs that - Fix a crash when requesting the wrong context menu due to paragraphs that
are automatically removed between the mouse press and release (bug 7209). 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 - Show mnemonics in context menus that are requested by the keyboard
key (only Windows; bug 5414). key (only Windows; bug 5414).