Method: Destructor Done()
Every class and class variant definition may implement its own destructor. Destructors are specialized methods, which are invoked automatically during the disposal of unused objects to complement and finalize their de-initialization. In Embedded Wizard, destructors are usual methods named explicitly with the identifier Done and declared without any return value and any parameters:
Declaration of a destructor method within the Code Editor window.
Unlike an ordinary method, destructors are invoked by the system's own Garbage Collector only. Calling the Done() method directly from another method is not possible. Moreover, in derived classes when the destructor method is overridden, the system ensures automatically, that starting with the most recently derived class every destructor implementation of every ancestor class is being called. The usage of the pseudo method super() is not necessary and even not possible.
Override inherited Done() method
Each class inherits the Done() method from its immediate ancestor class. In case of a class not descending from a concrete class, the Done() method is inherited from an internal class serving as very base ancestor for all Chora classes. In other words, each Chora class includes implicitly an Done() method. You see this inherited method in the Inspector window:
Inherited destructor within the Inspector window.
In order to implement this method:
★Localize and override the Done method first.
Implement the Done() method
Done() methods are implemented similarly as you do with ordinary methods. The unique limitation is, that from the destructor's implementation no other objects can be accessed, no new objects or observers can be created nor signals can be sent. In other words, the destructor can operate on this object only without interacting with other objects as it is not predictable whether these objects do still exist at this time of the actual garbage collection.