Languages

Menu
Sites
Language
Checking whether a control is constructed

Hi, everyone.

Basically, the question is in the subject: how do I check if some UI control is constructed or not (or already destroyed, as in my case)? Sometimes controls' inner implementation (_pControlImpl) seems to be destroyed automatically by the system, and while the wrapper object is still valid, trying to call its methods leads to the app crashing. I could easily avoid this, if I could check if the object has already been destroyed. But so far the only way to do this that I've found is to derive from the class in question, overload OnTerminating and store the object's state in some boolean variable. Yet, this is quite ugly. Does anyone know a better way? Have I overlooked something?

Edited by: Brock Boland on 17 Mar, 2014 Reason: Paragraph tags added automatically from tizen_format_fix module.

Responses

2 Replies
wil smith
Infact there is hardly any way to detect whether a control is constructed or not. I think you can avoid these kind of issues by following a simple practice for controls. 1. Check if you the Construct() method succeeds with return code E_SUCCESS. 2. Use the RemoveControl() or RemoveAllControls() methods to explicitly delete controls. Note that you must explicitly delete controls that have not been added to a container.
Anton Smetanin
Yes, my problem was basically a code design issue. As it turned out, by the time I tried to work with the control, the whole UI frame it belonged to had already been destroyed. But thanks anyway.