]> git.lyx.org Git - features.git/commitdiff
remove unneeded calls to BufferView::update() in insets
authorGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Mon, 9 May 2005 17:29:22 +0000 (17:29 +0000)
committerGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Mon, 9 May 2005 17:29:22 +0000 (17:29 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9925 a592a061-630c-0410-9148-cb99ea01b6c8

12 files changed:
src/ChangeLog
src/cursor.h
src/insets/ChangeLog
src/insets/insetbase.h
src/insets/insetcommand.C
src/insets/insetfloat.C
src/insets/insetgraphics.C
src/insets/insetinclude.C
src/insets/insetnote.C
src/insets/insetwrap.C
src/insets/render_preview.h
src/insets/updatableinset.C

index 03e681dc8049a053b6d3e5f4981d51bc1a474d61..c878219061746bea7fa8252e309bdcdd8e35ebf5 100644 (file)
@@ -1,3 +1,7 @@
+2005-05-09  Georg Baum  <Georg.Baum@post.rwth-aachen.de>
+
+       * cursor.h (undispatched, noUpdate): add comments from AndrĂ©
+
 2005-05-07  Michael Schmitt  <michael.schmitt@teststep.org>
 
        * lfuns.h:
index 5cd4b39ad52c20a8de90b9b2fe34862570c3e376..773513a16192c9e8abe466e7b5c3d18ab49aaaa8 100644 (file)
@@ -146,13 +146,30 @@ public:
        void reset(InsetBase &);
        /// for spellchecking
        void replaceWord(std::string const & replacestring);
-       /// the event was not (yet) dispatched
+       /**
+        * the event was not (yet) dispatched.
+        *
+        * Should only be called by an inset's doDispatch() method. It means:
+        * I, the doDispatch() method of InsetFoo, hereby declare that I am
+        * not able to handle that request and trust my parent will do the
+        * Right Thing (even if my getStatus partner said that I can do it).
+        * It is sort of a kludge that should be used only rarely...
+        */
        void undispatched();
        /// the event was already dispatched
        void dispatched();
        /// call update() when done
        void needsUpdate();
-       /// don't call update() when done
+       /**
+        * don't call update() when done
+        *
+        * Should only be called by an inset's doDispatch() method. It means:
+        * I handled that request and I can reassure you that the screen does
+        * not need to be re-drawn and all entries in the coord cache stay
+        * valid (and there are no other things to put in the coord cache).
+        * This is a fairly rare event as well and only some optimization.
+        * Not using noUpdate() should never be wrong.
+        */
        void noUpdate();
        /// fix cursor in circumstances that should never happen
        void fixIfBroken();
index fb62381fb2bba001d243178ad0c0e0089db34fc9..b6f316e330b04be126df3801ad48e576f1b7691c 100644 (file)
@@ -1,3 +1,11 @@
+2005-05-09  Georg Baum  <Georg.Baum@post.rwth-aachen.de>
+
+       * insetbase.h (doDispatch): document a bit more
+       * insetcommand.C, insetfloat.C, insetgraphics.C, insetinclude.C,
+       insetnote.C, insetwrap.C, updatableinset.C (doDispatch): don't call
+       cur.bv().update(), because that leads to nested updates. Call
+       cur.noUpdate() instead where approriate.
+
 2005-05-07  Michael Schmitt  <michael.schmitt@teststep.org>
 
        * insetbibtex.C: change screen label
index 887879481d1d2346a2a8784f6527df0710755c8d..e414bd6b150a1eadb3b5f879f6be0399f21a4290 100644 (file)
@@ -402,8 +402,17 @@ public:
 protected:
        InsetBase();
        InsetBase(InsetBase const &);
-       /// the real dispatcher.
-       /// \sa getStatus
+       /** The real dispatcher.
+        *  Gets normally called from LCursor::dispatch(). LCursor::dispatch()
+        *  assumes the common case of 'LFUN handled, need update'.
+        *  This has to be overriden by calling LCursor::undispatched() or
+        *  LCursor::noUpdate() if appropriate.
+        *  If you need to call the dispatch method of some inset directly
+        *  you may have to explicitly request an update at that place. Don't
+        *  do it in doDispatch(), since that causes nested updates when
+        *  called from LCursor::dispatch(), and these can lead to crashes.
+        *  \sa getStatus
+        */
        virtual void doDispatch(LCursor & cur, FuncRequest & cmd);
 private:
        virtual std::auto_ptr<InsetBase> doClone() const = 0;
index 66d049448ce619c5da30b5c7054951ed038cc571..deef84d0ea50c08e9098d75c97e09f125d6f8795 100644 (file)
@@ -109,12 +109,10 @@ void InsetCommand::doDispatch(LCursor & cur, FuncRequest & cmd)
        case LFUN_INSET_MODIFY: {
                InsetCommandParams p;
                InsetCommandMailer::string2params(mailer_name_, cmd.argument, p);
-               if (p.getCmdName().empty()) {
-                       cur.undispatched();
-               } else {
+               if (p.getCmdName().empty())
+                       cur.noUpdate();
+               else
                        setParams(p);
-                       cur.bv().update();
-               }
                break;
        }
 
index 4b9490688dfa20516757e3f85953d69378fdba7f..a68d8a677421c660282acd49e0d9c7691d27ef41 100644 (file)
@@ -160,7 +160,6 @@ void InsetFloat::doDispatch(LCursor & cur, FuncRequest & cmd)
                params_.sideways  = params.sideways;
                wide(params_.wide, cur.buffer().params());
                sideways(params_.sideways, cur.buffer().params());
-               cur.bv().update();
                break;
        }
 
index e9c1105cd824d4d0892de044d5b8cfd80a78fd1f..72139e5bab3b7e6b57aa8c7731c00c5941d08673 100644 (file)
@@ -197,10 +197,10 @@ void InsetGraphics::doDispatch(LCursor & cur, FuncRequest & cmd)
                Buffer const & buffer = cur.buffer();
                InsetGraphicsParams p;
                InsetGraphicsMailer::string2params(cmd.argument, buffer, p);
-               if (!p.filename.empty()) {
+               if (!p.filename.empty())
                        setParams(p);
-                       cur.bv().update();
-               }
+               else
+                       cur.noUpdate();
                break;
        }
 
index 129fd7cc93f7b07100a6a3d8f31b6c33033784be..74f7b4f28406dd35322632949be7aed6081ee7a8 100644 (file)
@@ -128,10 +128,10 @@ void InsetInclude::doDispatch(LCursor & cur, FuncRequest & cmd)
        case LFUN_INSET_MODIFY: {
                InsetCommandParams p;
                InsetIncludeMailer::string2params(cmd.argument, p);
-               if (!p.getCmdName().empty()) {
+               if (!p.getCmdName().empty())
                        set(p, cur.buffer());
-                       cur.bv().update();
-               }
+               else
+                       cur.noUpdate();
                break;
        }
 
index faa31ab0e4186d3dfc2e17ae3395ecf48df678af..affb96bb0ac4471a31cced8673dd0944fe2f8ec2 100644 (file)
@@ -192,7 +192,6 @@ void InsetNote::doDispatch(LCursor & cur, FuncRequest & cmd)
        case LFUN_INSET_MODIFY:
                InsetNoteMailer::string2params(cmd.argument, params_);
                setButtonLabel();
-               cur.bv().update();
                break;
 
        case LFUN_INSET_DIALOG_UPDATE:
index a08c43cc57ee33208d13111c89bf0d316e25fe5c..1ac102ba36c3dd12ded6f33057766aa4fe9b1397 100644 (file)
@@ -83,7 +83,6 @@ void InsetWrap::doDispatch(LCursor & cur, FuncRequest & cmd)
                InsetWrapMailer::string2params(cmd.argument, params);
                params_.placement = params.placement;
                params_.width     = params.width;
-               cur.bv().update();
                break;
        }
 
index b525f8633111150bf70b4f867f82a47e31a13709..ecec3237a0c163069703a006ff7cd60acc11f7b3 100644 (file)
@@ -25,7 +25,6 @@
 #include <boost/signals/connection.hpp>
 
 class Buffer;
-class BufferView;
 class LyXRC_PreviewStatus;
 class MetricsInfo;
 class PainterInfo;
index 3d62deed019ab9bf8e3a37a650de677266c276b2..7ec246b69f7b3bb69838e6b3397ede7b338d5c96 100644 (file)
@@ -99,8 +99,8 @@ void UpdatableInset::doDispatch(LCursor & cur, FuncRequest & cmd)
                                scroll(cur.bv(), static_cast<float>(convert<double>(cmd.argument)));
                        else
                                scroll(cur.bv(), convert<int>(cmd.argument));
-                       cur.bv().update();
-               }
+               } else
+                       cur.noUpdate();
                break;
 
        default: