On Wednesday 27 November 2002 12:43 pm, Lars Gullik Bjønnes wrote: > Angus Leeming <[EMAIL PROTECTED]> writes: > | On Wednesday 27 November 2002 3:17 am, John Levon wrote: > | > but I can reproduce your math crash > | > | Which also has a silly cause (although I can't reproduce it.) Bet it's > | fixed by this though: > | > | ControlMath::ControlMath(LyXView & lv, Dialogs & d) > | - : ControlDialogBD(lv, d) > | + : ControlDialogBD(lv, d), active_(0) > | {} > > So this would have been a case for the "help_ptr<>" > > template <class T> > class held_ptr : boost::noncopyable { > public: > held_ptr() : ptr_(0) {} > held_ptr(T*t) : ptr_(t) {} > T & operator->() { return *ptr; } > operator T* { return ptr_; } > private: > T * ptr_; > }; > > kindo thingie
Seems a lot of effort, and anyway, I'm going to be changing it regularly. > or just a shared_ptr<> of course... No, I already store the things as typedef boost::shared_ptr<GUIMathSub> DaughterPtr; typedef std::map<void *, DaughterPtr> Store; /** The store of all daughter dialogs. * The map uses the button on the main panel to identify them. */ Store daughters_; I use active_ to flag which one is currently being shown. /// A pointer to the currently active daughter dialog. GUIMathSub * active_; Used so: void ControlMath::showDaughter(void * key) { Store::iterator it = daughters_.find(key); GUIMathSub * const new_active = (it == daughters_.end()) ? 0 : it->second.get(); if (active_ != new_active) { if (active_ ) active_->controller().hide(); active_ = new_active; } if (active_) active_->controller().show(); } Regards, Angus