Re: Phix+EuGTK

new topic     » goto parent     » topic index » view thread      » older message » newer message
irv said...

When or how is it called?

The private destroy_instance() in builtins\structs.e is called when the reference count of an instance drops to zero, as per delete_routine(), or when delete(instance) is explicitly invoked.
Should a destructor be defined, it is invoked out of courtesy so the app can do any needed housekeeping.

irv said...

Do I have to connect every widget's "destroy" signal to call the deconstructor for that class of widget?

I wouldn't think so, delete_routine() should take care of it, eventually - in some cases an explicit delete(instance) might fix some race condition.
Generally speaking all reference counts are tidied up when a routine returns, but an active loop might squirrel away a reference in a hidden temp (or explicit local var) until the next iteration.
Obviously, should you invoke delete(instance) but keep a reference, that is explicitly, and try to keep on using it, that's on you: sometimes it'll crash, sometimes it'll clobber a (new) sibling.
Here I'm just using it so that get_by_handle() does not return (long-)dead window handles, and in such simple code race conditions would seem quite unlikely.

irv said...

What does it do besides remove the Window instance from the dictionary?

destroy_instance() places the slot in the (also private) instance table on a free list for re-use (ditto now-unused dicts from any dynamic class instances).
If it didn't do that some applications might exhibit a continuous memory leak.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu