From: John L. <jla...@gm...> - 2006-02-14 18:24:08
|
On 2/14/06, klaas.holwerda <kho...@xs...> wrote: > >>But this does not work, when run from the run script menu, it still > >>calls function that are wrong. > > > >I've changed wxluacan to use the "wxluacan" namespace and everything > >seems to work properly. Please let me know if there are other > >problems. > > > I did update from cvs, and in the wxluacan sample in the menu -> > ModifyObjects->Run Script. > And you run the script in wxCanlua.acripts/incircles.lua. > > I get still the same error: > attempt to call field `getCan` ( a nil value ). > Do you not get this? No, it works on two different machines in MSW and Linux. It adds some rects and an ellipse. Try doing another checkout maybe? > >I also changed the interface file and removed %delete for the classes. > >It's meant only for classes that lua itself will delete, like wxColour > >for example. > > > But what if both can happen? Can an object not be created in lua and/or C= ++? > Like here i can imagine one wants to create a wxlCan in lua script, and > add objects to it in lua. > But in the sample it is all added to C++ instead. Well, you can always remove the pointers from the wxLuaState, but that's not so elegant. > >If I > >understand correctly the c++ AddObject function takes ownership of the > >pointer and deletes it in the destructor. > > > Yes, as i say, i can imagine that for a class both can happen. > I would say this is a perfect use of smart pointers. In that case Lua > and C++ can hold a smrtPtr to the object, who releases it last will > delete the object. > So making the wxLuaState::m_pTrackedList a smart pointer list, will > already solve it. > Since then i would use for say the object in a canvas smart pointers > too, and all will be fine, no matter if Lua or C++ releases its smrtPtr > to the object first. > I think it would make thinks easier. I'm still a little sketchy about smart pointers. Does the template code work in MSVC 6? The last I tried templates VC6 couldn't handle them and I gave up. Your smart pointer class is just a single header file right? Regards, John Labenski |