Move Undo::beginUndoGroup() and Undo::endUndoGroup() calls to where they are used and necessary, hopefully.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31492 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2009-10-03 19:12:21 +00:00
parent 116c7c34c3
commit d38ca04ff7
5 changed files with 20 additions and 25 deletions

View File

@ -1742,6 +1742,7 @@ void Buffer::dispatch(FuncRequest const & func, DispatchResult & dr)
string const argument = to_utf8(func.argument());
// We'll set this back to false if need be.
bool dispatched = true;
undo().beginUndoGroup();
switch (func.action) {
case LFUN_BUFFER_TOGGLE_READ_ONLY:
@ -2065,6 +2066,7 @@ void Buffer::dispatch(FuncRequest const & func, DispatchResult & dr)
break;
}
dr.dispatched(dispatched);
undo().endUndoGroup();
}

View File

@ -1214,6 +1214,11 @@ bool BufferView::dispatch(FuncRequest const & cmd)
if (buffer_.isInternal() && lyxaction.funcHasFlag(cmd.action, LyXAction::NoInternal))
return false;
// We'll set this back to false if need be.
bool dispatched = true;
if (cmd.action != LFUN_UNDO && cmd.action != LFUN_REDO)
buffer_.undo().beginUndoGroup();
switch (cmd.action) {
case LFUN_BUFFER_PARAMS_APPLY: {
@ -1868,22 +1873,21 @@ bool BufferView::dispatch(FuncRequest const & cmd)
if (!setCursorFromInset(inset)) {
LASSERT(false, break);
}
// useful if we are called from a dialog.
cur.beginUndoGroup();
cur.recordUndo();
FuncRequest fr(LFUN_INSET_MODIFY, cmd.argument());
inset->dispatch(cur, fr);
cur.endUndoGroup();
processUpdateFlags(Update::SinglePar | Update::FitCursor);
break;
}
default:
return false;
dispatched = false;
break;
}
return true;
if (cmd.action != LFUN_UNDO && cmd.action != LFUN_REDO)
buffer_.undo().endUndoGroup();
return dispatched;
}

View File

@ -286,6 +286,8 @@ void Cursor::dispatch(FuncRequest const & cmd0)
fixIfBroken();
FuncRequest cmd = cmd0;
Cursor safe = *this;
buffer()->undo().beginUndoGroup();
// store some values to be used inside of the handlers
beforeDispatchCursor_ = *this;
@ -327,6 +329,7 @@ void Cursor::dispatch(FuncRequest const & cmd0)
// are possible which would change it
beforeDispatchCursor_ = safe.beforeDispatchCursor_;
}
buffer()->undo().endUndoGroup();
}

View File

@ -734,20 +734,12 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
? &(lv->documentBufferView()->buffer()) : 0;
if (doc_buffer && !theBufferList().isLoaded(doc_buffer))
doc_buffer = 0;
// Start an undo group. This may be needed for
// some stuff like inset-apply on labels.
if (doc_buffer)
doc_buffer->undo().beginUndoGroup();
// Let the current LyXView dispatch its own actions.
if (lv->dispatch(cmd)) {
BufferView * bv = lv->currentBufferView();
if (bv) {
Buffer * buffer = &(bv->buffer());
if (bv)
updateFlags = bv->cursor().result().update();
if (buffer == doc_buffer && theBufferList().isLoaded(buffer))
buffer->undo().endUndoGroup();
}
break;
}
@ -757,21 +749,14 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
// Let the current BufferView dispatch its own actions.
if (bv->dispatch(cmd)) {
// The BufferView took care of its own updates if needed.
Buffer * buffer = &(bv->buffer());
updateFlags = Update::None;
if (buffer == doc_buffer && theBufferList().isLoaded(buffer))
buffer->undo().endUndoGroup();
break;
}
BufferView * doc_bv = lv->documentBufferView();
// Try with the document BufferView dispatch if any.
if (doc_bv && doc_bv->dispatch(cmd)) {
// The BufferView took care of its own updates if needed.
Buffer * buffer = &(doc_bv->buffer());
updateFlags = Update::None;
if (buffer == doc_buffer && theBufferList().isLoaded(buffer))
buffer->undo().endUndoGroup();
break;
}
@ -818,9 +803,6 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
if (badcursor)
bv->cursor().fixIfBroken();
}
Buffer * buffer = &(bv->buffer());
if (buffer == doc_buffer && theBufferList().isLoaded(buffer))
buffer->undo().endUndoGroup();
// update completion. We do it here and not in
// processKeySym to avoid another redraw just for a

View File

@ -174,6 +174,9 @@ void TocWidget::doDispatch(Cursor & cur, FuncRequest const & cmd)
TocItem const & item =
gui_view_.tocModels().currentItem(current_type_, index);
// Start an undo group.
cur.beginUndoGroup();
switch (cmd.action)
{
case LFUN_CHANGE_ACCEPT:
@ -202,6 +205,7 @@ void TocWidget::doDispatch(Cursor & cur, FuncRequest const & cmd)
if (inset)
inset->dispatch(cur, tmpcmd);
}
cur.endUndoGroup();
}