From: Georg Baum Date: Mon, 9 May 2005 17:29:22 +0000 (+0000) Subject: remove unneeded calls to BufferView::update() in insets X-Git-Tag: 1.6.10~14305 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=92379230ffaa2cfe6f2d382498b0c9a6009933be;p=features.git remove unneeded calls to BufferView::update() in insets git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9925 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/ChangeLog b/src/ChangeLog index 03e681dc80..c878219061 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2005-05-09 Georg Baum + + * cursor.h (undispatched, noUpdate): add comments from André + 2005-05-07 Michael Schmitt * lfuns.h: diff --git a/src/cursor.h b/src/cursor.h index 5cd4b39ad5..773513a161 100644 --- a/src/cursor.h +++ b/src/cursor.h @@ -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(); diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index fb62381fb2..b6f316e330 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,11 @@ +2005-05-09 Georg Baum + + * 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 * insetbibtex.C: change screen label diff --git a/src/insets/insetbase.h b/src/insets/insetbase.h index 887879481d..e414bd6b15 100644 --- a/src/insets/insetbase.h +++ b/src/insets/insetbase.h @@ -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 doClone() const = 0; diff --git a/src/insets/insetcommand.C b/src/insets/insetcommand.C index 66d049448c..deef84d0ea 100644 --- a/src/insets/insetcommand.C +++ b/src/insets/insetcommand.C @@ -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; } diff --git a/src/insets/insetfloat.C b/src/insets/insetfloat.C index 4b9490688d..a68d8a6774 100644 --- a/src/insets/insetfloat.C +++ b/src/insets/insetfloat.C @@ -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; } diff --git a/src/insets/insetgraphics.C b/src/insets/insetgraphics.C index e9c1105cd8..72139e5bab 100644 --- a/src/insets/insetgraphics.C +++ b/src/insets/insetgraphics.C @@ -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; } diff --git a/src/insets/insetinclude.C b/src/insets/insetinclude.C index 129fd7cc93..74f7b4f284 100644 --- a/src/insets/insetinclude.C +++ b/src/insets/insetinclude.C @@ -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; } diff --git a/src/insets/insetnote.C b/src/insets/insetnote.C index faa31ab0e4..affb96bb0a 100644 --- a/src/insets/insetnote.C +++ b/src/insets/insetnote.C @@ -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: diff --git a/src/insets/insetwrap.C b/src/insets/insetwrap.C index a08c43cc57..1ac102ba36 100644 --- a/src/insets/insetwrap.C +++ b/src/insets/insetwrap.C @@ -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; } diff --git a/src/insets/render_preview.h b/src/insets/render_preview.h index b525f86331..ecec3237a0 100644 --- a/src/insets/render_preview.h +++ b/src/insets/render_preview.h @@ -25,7 +25,6 @@ #include class Buffer; -class BufferView; class LyXRC_PreviewStatus; class MetricsInfo; class PainterInfo; diff --git a/src/insets/updatableinset.C b/src/insets/updatableinset.C index 3d62deed01..7ec246b69f 100644 --- a/src/insets/updatableinset.C +++ b/src/insets/updatableinset.C @@ -99,8 +99,8 @@ void UpdatableInset::doDispatch(LCursor & cur, FuncRequest & cmd) scroll(cur.bv(), static_cast(convert(cmd.argument))); else scroll(cur.bv(), convert(cmd.argument)); - cur.bv().update(); - } + } else + cur.noUpdate(); break; default: