Hi, I’m developing an application with this beautifull framework, had read the book by the way. I’m wondering if I should call destroy() in those widgets which I’ll not use anymore. Here is the real example: when I push a button, a FXDialogBox object raise, it content is dynamic, what I mean is that it content will be random, sometimes you will see a bunch of widgets, sometimes you will see another different bunch of widgets, the question is: Should I call destroy() in that FXDialogBox object?(I will not use the SAME dialog box anymore) or ruby will take care of it. What I learned reading the book is that the object in the CLIENT SIDE will be erased by the Ruby GC when it is unavailable to reach by another object or scope in the runtime(classic work of the GC, nothing strange); by other side I’m not pretty sure about what happen with the SERVER SIDE resource created in the past by that object now erased by the GC, what happen with that? it’s erased from the Windows GDI(Yes, I’m developing for Windows OS)? should I call destroy() once I don’t need anymore the group of widgets? Hope I was clear in explanation, thanks for your time.
The GC deletes the object, if it is no longer in use (as you described). Part of the deletion is the destruction of server side resources, removing the focus, etc. This is equal to what can be done explicitly by the FXWindow#destroy method, if you want a window to disappear from screen. The GC also deletes any client side resources (memory, parent/sibling connections, acceltable, recalc layout, etc.) and the Ruby object itself. So you usually don’t have to care about #destroy.
To remove a FXWindow from screen or out of a surrounding frame you may call FXWindow#removeChild in the form fxwindow.parent.removeChild(fxwindow). This does immediate server and client side deletion as described above (but of course keeps the ruby object). Since this call isn’t very obvious, I was already thinking about adding a method FXWindow#delete that just calls C++ object destructor of the given object.
Thanks for your time Lars. Would be practice…
|You must be logged in to comment|