this patch removes the bv parameter from the inset methods open/close/status + removes a redundant update() call.
Concerning the markDirty() calls, I noticed that there is a general mechanisms which is based on the action type. I.e. we do not check whether a change has actually taken place. Special cases like opening an open inset are not captured. Very well, in this case we can simply remove the markDirty() calls :-)
Please check and apply,
Michael
Index: src/ChangeLog =================================================================== RCS file: /cvs/lyx/lyx-devel/src/ChangeLog,v retrieving revision 1.1713 diff -u -r1.1713 ChangeLog --- src/ChangeLog 2003/11/21 15:52:11 1.1713 +++ src/ChangeLog 2003/11/21 16:58:35 @@ -1,3 +1,10 @@ +2003-11-21 Michael Schmitt <[EMAIL PROTECTED]> + + * factory.C: change call to InsetERT constructor to avoid + additional invocation of method status + * text2.C (toggleInset): remove redundant update() call + * InsetList.[Ch] (insetsOpenCloseBranch): Pass Buffer reference + instead of a Bufferview pointer 2003-11-21 André Pönitz <[EMAIL PROTECTED]> Index: src/InsetList.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/InsetList.C,v retrieving revision 1.17 diff -u -r1.17 InsetList.C --- src/InsetList.C 2003/11/13 13:43:37 1.17 +++ src/InsetList.C 2003/11/21 16:58:35 @@ -158,18 +158,17 @@ } -void InsetList::insetsOpenCloseBranch(BufferView * bv) +void InsetList::insetsOpenCloseBranch(Buffer const & buf) { - BufferParams const & bp = bv->buffer()->params(); List::iterator it = list.begin(); List::iterator end = list.end(); for (; it != end; ++it) { if (it->inset && it->inset->lyxCode() == InsetOld::BRANCH_CODE) { InsetBranch * inset = static_cast<InsetBranch *>(it->inset); - if (bp.branchlist().selected(inset->params().branch)) { - inset->open(bv); + if (buf.params().branchlist().selected(inset->params().branch)) { + inset->open(); } else { - inset->close(bv); + inset->close(); } } } Index: src/InsetList.h =================================================================== RCS file: /cvs/lyx/lyx-devel/src/InsetList.h,v retrieving revision 1.8 diff -u -r1.8 InsetList.h --- src/InsetList.h 2003/11/13 13:43:38 1.8 +++ src/InsetList.h 2003/11/21 16:58:35 @@ -17,7 +17,7 @@ #include <vector> class InsetOld; -class BufferView; +class Buffer; /// @@ -66,7 +66,7 @@ /// void decreasePosAfterPos(lyx::pos_type pos); /// - void insetsOpenCloseBranch(BufferView * bv); + void insetsOpenCloseBranch(Buffer const & buf); private: /// Index: src/factory.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/factory.C,v retrieving revision 1.70 diff -u -r1.70 factory.C --- src/factory.C 2003/11/13 20:16:34 1.70 +++ src/factory.C 2003/11/21 16:58:37 @@ -229,11 +229,9 @@ return new InsetCitation(icp); } else if (name == "ert") { - InsetERT * inset = new InsetERT(params); InsetERT::ERTStatus s; InsetERTMailer::string2params(cmd.argument, s); - inset->status(bv, s); - return inset; + return new InsetERT(params,s); } else if (name == "external") { Buffer const & buffer = *cmd.view()->buffer(); Index: src/text2.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/text2.C,v retrieving revision 1.507 diff -u -r1.507 text2.C --- src/text2.C 2003/11/21 11:16:36 1.507 +++ src/text2.C 2003/11/21 16:58:41 @@ -256,7 +256,7 @@ if (inset_owner && inset_owner->owner() && inset_owner->owner()->isOpen()) { finishUndo(); - inset_owner->owner()->close(bv()); + inset_owner->owner()->close(); bv()->getLyXText()->cursorRight(true); bv()->updateParagraphDialog(); } @@ -269,11 +269,9 @@ recUndo(cursor.par()); if (inset->isOpen()) - inset->close(bv()); + inset->close(); else - inset->open(bv()); - - bv()->update(); + inset->open(); } Index: src/frontends/controllers/ChangeLog =================================================================== RCS file: /cvs/lyx/lyx-devel/src/frontends/controllers/ChangeLog,v retrieving revision 1.393 diff -u -r1.393 ChangeLog --- src/frontends/controllers/ChangeLog 2003/11/07 09:40:48 1.393 +++ src/frontends/controllers/ChangeLog 2003/11/21 16:58:47 @@ -1,3 +1,7 @@ +2003-11-21 Michael Schmitt <[EMAIL PROTECTED]> + + * ControlDocument.C: Change call to insetsOpenCloseBranch + 2003-11-07 Alfredo Braunstein <[EMAIL PROTECTED]> * ControlSpellchecker.C (isLetter): skip ert Index: src/frontends/controllers/ControlDocument.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/frontends/controllers/ControlDocument.C,v retrieving revision 1.42 diff -u -r1.42 ControlDocument.C --- src/frontends/controllers/ControlDocument.C 2003/10/27 07:05:07 1.42 +++ src/frontends/controllers/ControlDocument.C 2003/11/21 16:58:48 @@ -90,7 +90,7 @@ ParIterator pit = buffer()->par_iterator_begin(); ParIterator pend = buffer()->par_iterator_end(); for (; pit != pend; ++pit) { - pit->insetlist.insetsOpenCloseBranch(bufferview()); + pit->insetlist.insetsOpenCloseBranch(*buffer()); } } Index: src/insets/ChangeLog =================================================================== RCS file: /cvs/lyx/lyx-devel/src/insets/ChangeLog,v retrieving revision 1.916 diff -u -r1.916 ChangeLog --- src/insets/ChangeLog 2003/11/21 14:59:22 1.916 +++ src/insets/ChangeLog 2003/11/21 16:59:07 @@ -1,3 +1,9 @@ +2003-11-21 Michael Schmitt <[EMAIL PROTECTED]> + + * inset.h: + * insetcollapsable.[Ch]: + * insetert.[Ch]: remove bufferview parameter in methods + open, close, status, and updateStatus. 2003-11-21 Michael Schmitt <[EMAIL PROTECTED]> Index: src/insets/inset.h =================================================================== RCS file: /cvs/lyx/lyx-devel/src/insets/inset.h,v retrieving revision 1.143 diff -u -r1.143 inset.h --- src/insets/inset.h 2003/11/13 13:43:42 1.143 +++ src/insets/inset.h 2003/11/21 16:59:08 @@ -233,9 +233,9 @@ // is the inset open? virtual bool isOpen() const { return false; } /// open the inset - virtual void open(BufferView *) {} + virtual void open() {} /// close the inset - virtual void close(BufferView *) const {} + virtual void close() const {} /// check if the font of the char we want inserting is correct /// and modify it if it is not. virtual bool checkInsertChar(LyXFont &); Index: src/insets/insetcollapsable.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/insets/insetcollapsable.C,v retrieving revision 1.212 diff -u -r1.212 insetcollapsable.C --- src/insets/insetcollapsable.C 2003/11/21 14:59:23 1.212 +++ src/insets/insetcollapsable.C 2003/11/21 16:59:08 @@ -264,7 +264,7 @@ { lyxerr << "InsetCollapsable: edit left/right" << endl; inset.edit(bv, left); - open(bv); + open(); bv->cursor().push(this); } @@ -380,7 +380,7 @@ } -void InsetCollapsable::open(BufferView *) +void InsetCollapsable::open() { if (!collapsed_) return; @@ -389,7 +389,7 @@ } -void InsetCollapsable::close(BufferView * bv) const +void InsetCollapsable::close() const { if (collapsed_) return; Index: src/insets/insetcollapsable.h =================================================================== RCS file: /cvs/lyx/lyx-devel/src/insets/insetcollapsable.h,v retrieving revision 1.149 diff -u -r1.149 insetcollapsable.h --- src/insets/insetcollapsable.h 2003/11/21 14:59:23 1.149 +++ src/insets/insetcollapsable.h 2003/11/21 16:59:09 @@ -108,9 +108,9 @@ /// bool isOpen() const; /// - void open(BufferView *); + void open(); /// - void close(BufferView *) const; + void close() const; /// void markErased(); /// Index: src/insets/insetert.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/insets/insetert.C,v retrieving revision 1.173 diff -u -r1.173 insetert.C --- src/insets/insetert.C 2003/11/10 13:23:11 1.173 +++ src/insets/insetert.C 2003/11/21 16:59:10 @@ -119,12 +119,12 @@ string const tmp_token = lex.getString(); if (tmp_token == "Inlined") { - status(0, Inlined); + status(Inlined); } else if (tmp_token == "Collapsed") { - status(0, Collapsed); + status(Collapsed); } else { // leave this as default! - status(0, Open); + status(Open); } token_found = true; @@ -154,9 +154,9 @@ if (!token_found) { if (isOpen()) - status(0, Open); + status(Open); else - status(0, Collapsed); + status(Collapsed); } setButtonLabel(); } @@ -237,13 +237,13 @@ } -void InsetERT::updateStatus(BufferView * bv, bool swap) const +void InsetERT::updateStatus(bool swap) const { if (status_ != Inlined) { if (isOpen()) - status(bv, swap ? Collapsed : Open); + status(swap ? Collapsed : Open); else - status(bv, swap ? Open : Collapsed); + status(swap ? Open : Collapsed); } } @@ -276,7 +276,7 @@ } if (status_ != Inlined && hitButton(cmd)) { - updateStatus(bv, true); + updateStatus(true); } else { FuncRequest cmd1 = cmd; #warning metrics? @@ -409,7 +409,7 @@ InsetCollapsable::edit(bv, left); } set_latex_font(bv); - updateStatus(bv); + updateStatus(); } @@ -426,7 +426,7 @@ case LFUN_INSET_MODIFY: { InsetERT::ERTStatus status_; InsetERTMailer::string2params(cmd.argument, status_); - status(bv, status_); + status(status_); bv->update(); return DispatchResult(true, true); } @@ -537,13 +537,13 @@ } -// attention this function can be called with bv == 0 -void InsetERT::status(BufferView * bv, ERTStatus const st) const +void InsetERT::status(ERTStatus const st) const { if (st == status_) return; status_ = st; + switch (st) { case Inlined: break; @@ -554,16 +554,8 @@ case Collapsed: setCollapsed(true); setButtonLabel(); -#ifdef LOCK - if (bv) - bv->unlockInset(); -#endif break; } - if (bv) { - bv->update(); - bv->buffer()->markDirty(); - } } @@ -574,19 +566,19 @@ } -void InsetERT::open(BufferView * bv) +void InsetERT::open() { if (!isOpen()) - status(bv, Open); + status(Open); } -void InsetERT::close(BufferView * bv) const +void InsetERT::close() const { if (status_ == Collapsed || status_ == Inlined) return; - status(bv, Collapsed); + status(Collapsed); } Index: src/insets/insetert.h =================================================================== RCS file: /cvs/lyx/lyx-devel/src/insets/insetert.h,v retrieving revision 1.93 diff -u -r1.93 insetert.h --- src/insets/insetert.h 2003/11/07 09:40:49 1.93 +++ src/insets/insetert.h 2003/11/21 16:59:10 @@ -88,15 +88,15 @@ /// ERTStatus status() const { return status_; } /// - void open(BufferView *); + void open(); /// - void close(BufferView *) const; + void close() const; /// void metrics(MetricsInfo &, Dimension &) const; /// void draw(PainterInfo & pi, int x, int y) const; /// set the status of the inset - void status(BufferView *, ERTStatus const st) const; + void status(ERTStatus const st) const; /// bool showInsetDialog(BufferView *) const; /// @@ -130,7 +130,7 @@ /// void set_latex_font(BufferView *); /// update status on button - void updateStatus(BufferView *, bool = false) const; + void updateStatus(bool = false) const; /// void edit(BufferView * bv, bool left); ///