Languages

Menu
Sites
Language
Do I need to evas_object_del all items in a layout?

Let's say I create a layout.

layout = elm_layout_add(window);

I use the default layout

elm_layout_theme_set(layout, "layout", "application", "default");

Then I create a rectangle, inheriting from the layout, e.g.

rect = evas_object_rectangle_add(evas_object_evas_get(layout));

And I added it to the layout:

elm_object_part_content_set(layout, "elm.swallow.content", rectangle);

 

Now, when it comes the time to dispose the layout, I can call

evas_object_del(layout);

 

But the million dollar question is, is rect object automatically gone, or do I still have to explicitly call evas_object_del(rect) as well?

Repeat the same question for other kind of contains as well, such as Box, Grid, Table, Conformant and Naviframe.

 

Thanks.

Responses

3 Replies
Safwan

I have written two labels (text) and set both the content over a box object. And when I apply evas_object_del() function over the box, both the labels are gone along with the box. So I would say Yes, the internal objects are also gone with the objects deleted.

Try out this code snippet:

 

        Evas_Object *box = elm_box_add(ad->conform);
        elm_box_horizontal_set(box, EINA_TRUE);

	Evas_Object *Label1= elm_label_add(box);
	elm_object_text_set(Label1, "<align=center>Tizen</align>");
	evas_object_size_hint_weight_set(Label1, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
	elm_object_content_set(box, Label1);
	elm_box_pack_end(box, Label1);
	evas_object_show(Label1);

	Evas_Object *Label2= elm_label_add(box);
	elm_object_text_set(Label2, "<align=center>Application</align>");
	evas_object_size_hint_weight_set(Label2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
	elm_object_content_set(box, Label2);
	elm_box_pack_end(box, Label2);
	evas_object_show(Label2);


	elm_object_content_set(ad->conform, box);
	evas_object_show(box);

	// evas_object_del(Label1);          // [comment out according to your need]
	// evas_object_del(Label2);    
	// evas_object_del(box);

 

James B

Thank you Safwan.

This is indeed the case, as far as the visuals are concerned.

However my concern is whether any internal memory allocation are deleted as well? It's one thing that the label's aren't drawn anymore, it's another thing whether the allocated memory used to hold the objects are freed. The documentation isn't very clear on this.

cheers!

Safwan

Hello James,

I've find it out. Yes memory allocation of inner object is deleted. In above code when I delete the box object and try to call the box again after deletion the app fails.

 

evas_object_del(box);
elm_object_content_set(ad->conform, box);  //app breaks

 

Same happens when I try to call the Label object after deletion of box.

Label2= elm_label_add(box);
....
....
elm_box_pack_end(box, Label2);
evas_object_show(Label2);
....
....

evas_object_del(box);
elm_object_content_set(ad->conform, Label2);  //app breaks

 

So yes, memory allocation of the object including inner ones is freed.