342 views
in Embedded Wizard Studio by
Hi.

In my custom view, 'attachobserver to autoobject property' is called In overrided init method.

Then, that view is added to a parent view, then after a user control some widget, the view is removed.

At the time of remove , is the detachobserver explicitly required?

If the detachobserver is not called, the GC can destory that view?

If so, I'll add detachobserver in Done method.

Thanks and best regards.
Jinho.

1 Answer

0 votes
by
 
Best answer

Hi Jinho,

let me refer to the article attachobserver statement, in particular the section:

The established relations can be considered as 'weak references' and are ignored by the Garbage Collector. When the Garbage Collector reclaims an object, which is involved in an observer relation, the relation is dissolved automatically. In other words, one relation partner can't maintain alive another partner by the mere observer relation existing between them.

In other words, you don't need to worry about the view. It will be released even if it is involved in an observer relation. Please note, operations within the Done method are restricted. The Chora compiler will automatically report errors when Done method includes some code, which may cause side effects during garbage collection (e.g. an access to other object). Therefore, trying to use detachobserver in Done will raise a compilation error.

Best regards

Paul Banach

by
Hi Paul.

That behavior is what I want.

Thank you very much.

Ask Embedded Wizard

Welcome to the question and answer site for Embedded Wizard users and UI developers.

Ask your question and receive answers from the Embedded Wizard support team or from other members of the community!

Embedded Wizard Website | Privacy Policy | Imprint

...