On Monday 12 August 2002 6:01 pm, Angus Leeming wrote:
> On Monday 12 August 2002 6:13 pm, Lars Gullik Bjønnes wrote:
> > The real problem comes when you allocate _two_ pointers.

Lars, since we're on this subject, I'd like to make the following change. Are 
you happy now that this is safe?

I'll also change the associated accessor methods so that they return a 
reference rather than a pointer as this too is guaranteeded to be safe.

Happy?

Regards,
Angus

class LyXView : public boost::signals::trackable, boost::noncopyable {
protected:
        /// view's menubar
-       boost::scoped_ptr<Menubar> menubar_;
+       boost::scoped_ptr<Menubar> menubar_;
        /// view's toolbar
-       boost::scoped_ptr<Toolbar> toolbar_;
+       boost::scoped_ptr<Toolbar> toolbar_;
        /// view's command buffer controller
-       boost::scoped_ptr<ControlCommandBuffer> controlcommand_;
+       boost::scoped_ptr<ControlCommandBuffer> controlcommand_;

        /// keyboard mapping object
-       boost::scoped_ptr<Intl> intl_;
+       boost::scoped_ptr<Intl> intl_;

        /// auto-saving of buffers
-       boost::scoped_ptr<Timeout> autosave_timeout_;
+       boost::scoped_ptr<Timeout> autosave_timeout_;
};

LyXView::LyXView()
+       : lyxfunc_(new LyXFunc(this)),
+         intl_(new Intl),
+         autosave_timeout_(new Timeout(5000)),
+         dialogs_(new Dialogs(this)),
+         controlcommand_(new ControlCommandBuffer(*getLyXFunc()))
{
        lyxerr[Debug::INIT] << "Initializing LyXFunc" << endl;

-       lyxfunc_.reset(new LyXFunc(this));
-       intl_.reset(new Intl);
-
-       // Give the timeout some default sensible value.
-       autosave_timeout_.reset(new Timeout(5000));
-
-       dialogs_.reset(new Dialogs(this));
-       controlcommand_.reset(new ControlCommandBuffer(*getLyXFunc()));
}

Reply via email to