[squeak-dev] Execute code when a Morph is destroyed
skadge at gmail.com
Tue Jan 6 20:57:00 UTC 2009
> I never dealt with bin in Morphic.
> But something tells me that you employing wrong model :)
> In a right way, you should use a separate class which operates with
> com port, and morph should be a view of an instance of such object.
> Then your question will lose context, since you have a model - which
> acts by itself and closing external resources when it becomes garbage.
> And you have a morph, which is a view of your model object, and you
> can have as many views as you want to, and it is irrelevant if any of
> them alive or not, putted in bin or somewhere else :)
It's definitely the way I do :-)
I've basically a SerialHandler, a Module and a ModuleMorph. The Module
class (the "C" of the MVC model) holds all the logic and lives outside
of the "morphic" world. But, to be "user friendly", I would like to
close the serial port when the ModuleMorph (the "V" :-) ) is put in
the garbage. So I need to call smthg in Module from ModuleMorph when
the morph is destroyed.
In parallel, your tip concerning finalization is useful at all events
for the Module class.
More information about the Squeak-dev