LuaBind/MyGUI private destructor makes problems

wolfmanfx

08-01-2009 22:59:34

Hi,

I am exposing myGUI functionlity to lua with luabind but i get into troubles with the private destructors

error C2248: 'MyGUI::Widget::~Widget' : cannot access protected member declared in class 'MyGUI::Widget'

So my question is if anyone has a working luabinding with lua bind and how to overcome this problem.

my.name

09-01-2009 00:52:28

class WidgetWrap
{
public:
WidgetWrap() { mWidget = MyGUI::Gui::getInstance().createWidget ...
~WidgetWrap() { MyGUI::WidgetManager::getInstance().destroyWidget(mWidget ...
private:
WidgetPtr mWidget;
};

wolfmanfx

09-01-2009 09:29:00

Hoi,

That dont solve my problem i dont want to create destroy Widgets in lua i just want to use it in the script (i dont change the ownership). So i go the wrapper way i have to wrap every function which i want to expose and every widget: Button, Edit
I tempory solved the problem by making the destructors of the widgets public but that dont feel right :)

my.name

09-01-2009 12:27:25

=)
but dont call destructor

wolfmanfx

09-01-2009 12:28:05

:D no way

oddrose

28-08-2009 20:34:44

I am having the same problem and I guess I'll go with the same solution...
As wolfman, I don't like that modification though...feels so so dirty

EDIT:
Just found out that luabind now supports some kind of solution.
Donwload the latest (8.1) I think and check out "test_private_destructors.cpp" in the test folder that comes with the source.
I'll drop a line if I get it to work with MyGUI.

Note: If your code explodes, you should know that "super" is deprecated since luabind 0.8, I didn't know and all my inherited classes crashed.
Now we write:

function Derived:__init()
Base.__init(self)
end

merlinblack

25-11-2009 20:49:46

Also with the 'super' thing, it's still there, to tell you it's depreciated. You should set super to nil after construction, otherwise the last instance created may not be garbage collected until lua_close! :? Of course if that doesn't cause a problem for you, you need not bother.

I'm liking the better smart pointer support in 0.9.1. :)