]> git.lyx.org Git - features.git/commitdiff
Move Undo::beginUndoGroup() and Undo::endUndoGroup() calls to where they are used...
authorAbdelrazak Younes <younes@lyx.org>
Sat, 3 Oct 2009 19:12:21 +0000 (19:12 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Sat, 3 Oct 2009 19:12:21 +0000 (19:12 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31492 a592a061-630c-0410-9148-cb99ea01b6c8

src/Buffer.cpp
src/BufferView.cpp
src/Cursor.cpp
src/LyXFunc.cpp
src/frontends/qt4/TocWidget.cpp

index b9a4f42958f21ff86a456d392c0ab6859b4a64e3..94f46af094bb7b2b7cd3878eb17b03541a20f7cc 100644 (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();
 }
 
 
index 46b3e079b451d3fba7010efde633d895f593119d..82399c77b74ac6b176b9378dfa835e846493a44e 100644 (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;
 }
 
 
index b8d1b9fe57f63464190b43d09079aa4da50f9de6..9b6c82dcd852028e956cdc8ec76fbad55a406bac 100644 (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();
 }
 
 
index ef568b57e5471275cc567ac07110bcb026abd7d6..72bbee61ca9d19d0eed1b3685e50eea6846fa23e 100644 (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
index 7eae64667b04c57ef3b13b1d00c4f8aaf0a8b759..538c04c177cb894dd2f4045301e7db29fb640087 100644 (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();
 }