From: klaas.holwerda <kho...@xs...> - 2006-02-14 18:14:34
|
John Labenski 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? Now if you change all the name spaces in lua to use wx instead of wxcanlua, it all works well. ( so in the rules file and in the script ). >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. >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. Klaas |