]> git.lyx.org Git - features.git/commitdiff
Remove buggy and redundant BufferView::update() calls.
authorAbdelrazak Younes <younes@lyx.org>
Wed, 24 Jan 2007 23:10:03 +0000 (23:10 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Wed, 24 Jan 2007 23:10:03 +0000 (23:10 +0000)
* BufferView::dispatch() now returns an Update::flags.

* lyx_cb.C::insertPlaintextFile(): delete redundant BufferView::update() call.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16844 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView.C
src/BufferView.h
src/lyx_cb.C
src/lyxfunc.C

index 008f03e4aa11e10347289ed7911525d6fbb5aa85..926fb0b9c05a3d18ff7f8b11a25e6b035f5d2c78 100644 (file)
@@ -690,7 +690,7 @@ FuncStatus BufferView::getStatus(FuncRequest const & cmd)
 }
 
 
-bool BufferView::dispatch(FuncRequest const & cmd)
+Update::flags BufferView::dispatch(FuncRequest const & cmd)
 {
        //lyxerr << BOOST_CURRENT_FUNCTION
        //       << [ cmd = " << cmd << "]" << endl;
@@ -704,30 +704,34 @@ bool BufferView::dispatch(FuncRequest const & cmd)
                << " button[" << cmd.button() << ']'
                << endl;
 
+       // FIXME: this should not be possible.
+       if (!buffer_)
+               return Update::None;
+
        LCursor & cur = cursor_;
+       // Default Update flags.
+       Update::flags updateFlags = Update::Force | Update::FitCursor;
 
        switch (cmd.action) {
 
        case LFUN_UNDO:
-               if (buffer_) {
-                       cur.message(_("Undo"));
-                       cur.clearSelection();
-                       if (!textUndo(*this))
-                               cur.message(_("No further undo information"));
-                       update();
-                       switchKeyMap();
+               cur.message(_("Undo"));
+               cur.clearSelection();
+               if (!textUndo(*this)) {
+                       cur.message(_("No further undo information"));
+                       updateFlags = Update::None;
                }
+               switchKeyMap();
                break;
 
        case LFUN_REDO:
-               if (buffer_) {
-                       cur.message(_("Redo"));
-                       cur.clearSelection();
-                       if (!textRedo(*this))
-                               cur.message(_("No further redo information"));
-                       update();
-                       switchKeyMap();
+               cur.message(_("Redo"));
+               cur.clearSelection();
+               if (!textRedo(*this)) {
+                       cur.message(_("No further redo information"));
+                       updateFlags = Update::None;
                }
+               switchKeyMap();
                break;
 
        case LFUN_FILE_INSERT:
@@ -789,13 +793,13 @@ bool BufferView::dispatch(FuncRequest const & cmd)
                                if (b == buffer_) {
                                        // Set the cursor
                                        setCursor(makeDocIterator(par, 0));
-                                       update();
                                        switchKeyMap();
                                } else {
                                        // Switch to other buffer view and resend cmd
                                        theLyXFunc().dispatch(FuncRequest(
                                                LFUN_BUFFER_SWITCH, b->fileName()));
                                        theLyXFunc().dispatch(cmd);
+                                       updateFlags = Update::None;
                                }
                                break;
                        }
@@ -839,10 +843,9 @@ bool BufferView::dispatch(FuncRequest const & cmd)
                buffer_->params().trackChanges = !buffer_->params().trackChanges;
                break;
 
-       case LFUN_CHANGES_OUTPUT: {
+       case LFUN_CHANGES_OUTPUT:
                buffer_->params().outputChanges = !buffer_->params().outputChanges;
                break;
-       }
 
        case LFUN_CHANGE_NEXT:
                findNextChange(this);
@@ -860,7 +863,6 @@ bool BufferView::dispatch(FuncRequest const & cmd)
 #endif
                while (findNextChange(this))
                        getLyXText()->acceptOrRejectChange(cursor_, true);
-               update();
                break;
        }
 
@@ -995,10 +997,10 @@ bool BufferView::dispatch(FuncRequest const & cmd)
        }
 
        default:
-               return false;
+               updateFlags = Update::None;
        }
 
-       return true;
+       return updateFlags;
 }
 
 
index bceaf1f82fd92d4d6bdffc091c312130802d6bd6..103d4d10b74c35f5a1da92ac5b86155ccf55f8b6 100644 (file)
@@ -157,7 +157,8 @@ public:
        /// return true for events that will handle.
        FuncStatus getStatus(FuncRequest const & cmd);
        /// execute the given function.
-       bool dispatch(FuncRequest const & argument);
+       /// \return the Update::flags for further metrics update.
+       Update::flags dispatch(FuncRequest const & argument);
 
        /// request an X11 selection.
        /// \return the selected string.
index d455f132aea6845385a84478ff1caaa565ff1448..896f1a99b2f605fb60405eaf3eb10d11c44358e3 100644 (file)
@@ -337,7 +337,6 @@ void insertPlaintextFile(BufferView * bv, string const & f, bool asParagraph)
                bv->getLyXText()->insertStringAsParagraphs(bv->cursor(), tmpstr);
        else
                bv->getLyXText()->insertStringAsLines(bv->cursor(), tmpstr);
-       bv->update();
 }
 
 
index 1e10da58a27ec1bb8c2a228a0206563507b25185..adcf1ce862c5dcb2746d99c6855a12756e65e3e1 100644 (file)
@@ -1739,8 +1739,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                        view()->cursor().dispatch(cmd);
                        updateFlags = view()->cursor().result().update();
                        if (!view()->cursor().result().dispatched())
-                               if (view()->dispatch(cmd)) 
-                                       updateFlags = Update::Force | Update::FitCursor;
+                               updateFlags = view()->dispatch(cmd);
                        break;
                }
                }