Jean-Marc Lasgouttes wrote: > John Levon wrote: > >> A subtle thing I found out a few weeks ago. You need to have an out of >> line dtor for the object that has a scoped_ptr inside it. e.g. >> XMiniBuffer needs an outofline dtor because it contains a scoped_ptr as >> a member on a forward-declared class > > > The kind of things I cqnnot guess by myself. Thansk.
Hmm, I take my Thansk back. It did not work. Anyway my time is up for this evening. What I wanted to do is to add a Menu (or Menu*) member to MenuItem, so that Menu::expand can create an actual submenu for items of kind Submenu. This is needed to move toc support to menubackend. What is the right way to do it? Note that we tend to copy MenuItems from time to time (although avoiding that would not be bad). So, how do I do it? What I tried was to have a boost::scoped_ptr<Menu> submenu_; in Menubackend.h. I tried to do the magic proposed by John (add a destructor for MenuItem) but always got: g++ -DHAVE_CONFIG_H -I. -I../../lyx-devel/src -I. -I../../lyx-devel/boost -isystem /usr/X11R6/include -g -O -fno-exceptions -Wno-non-template-friend -W -Wall -c ../../lyx-devel/src/MenuBackend.C /usr/include/g++-3/stl_construct.h: In method `MenuItem::MenuItem (const MenuItem &)': /usr/include/g++-3/stl_construct.h:48: instantiated from `construct (_T1 *, const _T2 &) [with _T1 = MenuItem, _T2 = MenuItem]' ../../lyx-devel/src/MenuBackend.C:321: instantiated from here ../../lyx-devel/boost/boost/scoped_ptr.hpp:32: `boost::scoped_ptr<T>::scoped_ptr (const boost::scoped_ptr<T> &) [with T = Menu]' is private /usr/include/g++-3/stl_construct.h:48: within this context /usr/include/g++-3/stl_vector.h: In method `MenuItem &MenuItem::operator= (const MenuItem &)': /usr/include/g++-3/stl_vector.h:595: instantiated from `vector<_Tp, _Alloc>::_M_insert_aux (_Tp *, const _Tp &) [with _Tp = MenuItem, _Alloc = allocator<MenuItem>]' /usr/include/g++-3/stl_vector.h:325: instantiated from `vector<_Tp, _Alloc>::push_back (const _Tp &) [with _Tp = MenuItem, _Alloc = allocator<MenuItem>]' ../../lyx-devel/src/MenuBackend.C:97: instantiated from here ../../lyx-devel/boost/boost/scoped_ptr.hpp:33: `boost::scoped_ptr<T> &boost::scoped_ptr<T>::operator= (const boost::scoped_ptr<T> &) [with T = Menu]' is private /usr/include/g++-3/stl_vector.h:595: within this context