mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-08 18:19:42 +00:00
Fix bug #10316.
By sending the request through the usual dispatch machinery, we make sure the cursor is valid when we're done.
This commit is contained in:
parent
15659fed53
commit
e5b6be0712
@ -181,7 +181,6 @@ void TocWidget::doDispatch(Cursor & cur, FuncRequest const & cmd,
|
|||||||
{
|
{
|
||||||
|
|
||||||
Inset * inset = itemInset();
|
Inset * inset = itemInset();
|
||||||
FuncRequest tmpcmd(cmd);
|
|
||||||
|
|
||||||
QModelIndex const & index = tocTV->currentIndex();
|
QModelIndex const & index = tocTV->currentIndex();
|
||||||
TocItem const & item =
|
TocItem const & item =
|
||||||
@ -193,15 +192,25 @@ void TocWidget::doDispatch(Cursor & cur, FuncRequest const & cmd,
|
|||||||
switch (cmd.action())
|
switch (cmd.action())
|
||||||
{
|
{
|
||||||
case LFUN_CHANGE_ACCEPT:
|
case LFUN_CHANGE_ACCEPT:
|
||||||
case LFUN_CHANGE_REJECT:
|
case LFUN_CHANGE_REJECT: {
|
||||||
|
// The action is almost always LYX_UNKNOWN_ACTION, which will
|
||||||
|
// have the effect of moving the cursor to the location of
|
||||||
|
// the change. (See TocItem::action.)
|
||||||
dispatch(item.action());
|
dispatch(item.action());
|
||||||
cur.dispatch(tmpcmd);
|
// If we do not reset the origin, then the request will be sent back
|
||||||
|
// here, and we are in an infinite loop. But we need the dispatch
|
||||||
|
// machinery to clean up for us, if the cursor is in an inset that
|
||||||
|
// will be deleted. See bug #10316.
|
||||||
|
FuncRequest tmpcmd(cmd);
|
||||||
|
tmpcmd.setOrigin(FuncRequest::INTERNAL);
|
||||||
|
dispatch(tmpcmd);
|
||||||
dr.forceBufferUpdate();
|
dr.forceBufferUpdate();
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case LFUN_SECTION_SELECT:
|
case LFUN_SECTION_SELECT:
|
||||||
dispatch(item.action());
|
dispatch(item.action());
|
||||||
cur.dispatch(tmpcmd);
|
cur.dispatch(cmd);
|
||||||
// necessary to get the selection drawn.
|
// necessary to get the selection drawn.
|
||||||
cur.buffer()->changed(true);
|
cur.buffer()->changed(true);
|
||||||
gui_view_.setFocus();
|
gui_view_.setFocus();
|
||||||
@ -222,10 +231,12 @@ void TocWidget::doDispatch(Cursor & cur, FuncRequest const & cmd,
|
|||||||
outline(cmd.action());
|
outline(cmd.action());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default: {
|
||||||
|
FuncRequest tmpcmd(cmd);
|
||||||
if (inset)
|
if (inset)
|
||||||
inset->dispatch(cur, tmpcmd);
|
inset->dispatch(cur, tmpcmd);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
cur.endUndoGroup();
|
cur.endUndoGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user