Andre Poenitz wrote: > On Wed, Feb 19, 2003 at 04:08:26PM +0000, Angus Leeming wrote: >> Sorry, I didn't see this one. I saw only >> >> | The problem with this is that the BufferView is sometimes redone >> | and you point to a non valid pointer (the problems we had >> | especially in the beginning with InsetText after cleaning it up >> | a bit, but IMO we still can have this problem!). > > The choice is probably: Make a safe cache or pass a BufferView > around. > > As I don't have problems with math, I'd guess a safe cache is > possible, but we've never had more than one BufferView, so I don't > know for sure. > > The first option gives clean interfaces and a potential mess,
> the second a messy interface but less chance of a mess. Doesn't this sound contradictory to you? > I'd probably go for the first one, but I wanted to make sure we are > aware of the consequences. Ok. I'm aware ;-) I've also been thinking further about my suggestion. I think that 'has a dialog' is cleaner than 'is an inset with a dialog': class DialogInvoker { public: DialogInvoker(string const & name, InsetBase & parent) : name_(name), parent_(parent) {} void show() { BufferView * bv = parent_->view(); if (!bv) return; ostringstream data; parent_.write(data); data << "\\end_inset\n"; bv->owner()->getDialogs.show(name_, data.str(), &parent_); } void hide() { BufferView * bv = parent_->view(); if (!bv) return; bv->owner()->getDialogs.hide(name_); } private: string const name_; InsetBase & parent_; }; class InsetCitation : public InsetCommand { public: InsetCitation() : dialog_("citation", this) {} ~InsetCitation() { dialog_.hide(); } void edit(BufferView * bv, ...) { view_ = bv->owner()->view(); dialog_->show(); } private: DialogInvoker dialog_; }; -- Angus