lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> Do you mean creating new Lua userdata and then using the 
> placement new operator on the Lua-allocated memory? How does 
> it work with the Qt parent-child memory management, when 
> child objects are deleted along with parent objects? How did 
> you implement the delete operator, so it does not mess up Lua memory?

Yes, I meant exactly that, and I did it for Qt classes with value semantics
(like QPoint, QString, QDataStream, etc, etc). 
There is no point in letting Lua allocate memory for Qt memory managed
objets (like derivates of QObject* or QGraphicsItem* and some others). For
these I just kept the pointer (a lightuserdata) and did some bookkeeping to
determine when Lua side needed to take over the ownership from Qt or vice
versa. It was actually quite simple and works very well.