summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2014-07-21 17:58:03 -0300
committerSavio Sena <savio@expertisesolutions.com.br>2014-07-21 20:53:12 -0300
commit8a6249938571c79a29e23637329878ccf38162a2 (patch)
tree3a311a65714c4330d1c930b07b442f90ae390fa8
parent089029a68fec6d989e138a8a76da34007caf3153 (diff)
c++: Added workaround for correct unref times
The legacy functions do unref after construction of the object. Which doesn't happen on the eo_add calls directly. So it is needed to do two unref's before letting the parent own the child.
-rw-r--r--src/examples/box_cxx_example_02.cc20
1 files changed, 9 insertions, 11 deletions
diff --git a/src/examples/box_cxx_example_02.cc b/src/examples/box_cxx_example_02.cc
index 10fcb0cc0..1f57247e8 100644
--- a/src/examples/box_cxx_example_02.cc
+++ b/src/examples/box_cxx_example_02.cc
@@ -79,16 +79,19 @@ elm_main(int argc, char *argv[])
79 win.autodel_set(true); 79 win.autodel_set(true);
80 80
81 elm_box bigbox ( efl::eo::parent = win ); 81 elm_box bigbox ( efl::eo::parent = win );
82 ::eo_unref(bigbox._eo_ptr());
82 bigbox.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 83 bigbox.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
83 win.resize_object_add(bigbox); 84 win.resize_object_add(bigbox);
84 bigbox.visibility_set(true); 85 bigbox.visibility_set(true);
85 86
86 elm_box buttons ( efl::eo::parent = win ); 87 elm_box buttons ( efl::eo::parent = win );
88 ::eo_unref(buttons._eo_ptr());
87 buttons.horizontal_set(EINA_TRUE); 89 buttons.horizontal_set(EINA_TRUE);
88 bigbox.pack_end(buttons); 90 bigbox.pack_end(buttons);
89 buttons.visibility_set(true); 91 buttons.visibility_set(true);
90 92
91 elm_button add ( efl::eo::parent = win ); 93 elm_button add ( efl::eo::parent = win );
94 ::eo_unref(add._eo_ptr());
92 add.text_set("Add"); 95 add.text_set("Add");
93 buttons.pack_end(add); 96 buttons.pack_end(add);
94 add.visibility_set(true); 97 add.visibility_set(true);
@@ -111,12 +114,14 @@ elm_main(int argc, char *argv[])
111 })); 114 }));
112 115
113 elm_button clear ( efl::eo::parent = win ); 116 elm_button clear ( efl::eo::parent = win );
117 ::eo_unref(clear._eo_ptr());
114 clear.text_set("Clear"); 118 clear.text_set("Clear");
115 buttons.pack_end(clear); 119 buttons.pack_end(clear);
116 clear.visibility_set(true); 120 clear.visibility_set(true);
117 clear.event_clicked_callback_add(std::bind([&tdata] { tdata.box.lock()->clear(); })); 121 clear.event_clicked_callback_add(std::bind([&tdata] { tdata.box.lock()->clear(); }));
118 122
119 elm_box dynamic ( efl::eo::parent = win ); 123 elm_box dynamic ( efl::eo::parent = win );
124 ::eo_unref(dynamic._eo_ptr());
120 dynamic.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 125 dynamic.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
121 dynamic.size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL); 126 dynamic.size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL);
122 bigbox.pack_end(dynamic); 127 bigbox.pack_end(dynamic);
@@ -132,6 +137,7 @@ elm_main(int argc, char *argv[])
132 ; 137 ;
133 138
134 elm_button bt1 ( efl::eo::parent = win ); 139 elm_button bt1 ( efl::eo::parent = win );
140 ::eo_unref(bt1._eo_ptr());
135 bt1.text_set("Button 1"); 141 bt1.text_set("Button 1");
136 bt1.event_clicked_callback_add(unpack); 142 bt1.event_clicked_callback_add(unpack);
137 bt1.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 143 bt1.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
@@ -140,6 +146,7 @@ elm_main(int argc, char *argv[])
140 bt1.visibility_set(true); 146 bt1.visibility_set(true);
141 147
142 elm_button bt2 ( efl::eo::parent = win ); 148 elm_button bt2 ( efl::eo::parent = win );
149 ::eo_unref(bt2._eo_ptr());
143 bt2.text_set("Button 2"); 150 bt2.text_set("Button 2");
144 bt2.size_hint_weight_set(EVAS_HINT_EXPAND, 0.0); 151 bt2.size_hint_weight_set(EVAS_HINT_EXPAND, 0.0);
145 bt2.size_hint_align_set(1.0, 0.5); 152 bt2.size_hint_align_set(1.0, 0.5);
@@ -148,6 +155,7 @@ elm_main(int argc, char *argv[])
148 bt2.visibility_set(true); 155 bt2.visibility_set(true);
149 156
150 elm_button bt3 ( efl::eo::parent = win ); 157 elm_button bt3 ( efl::eo::parent = win );
158 ::eo_unref(bt3._eo_ptr());
151 bt3.text_set("Button 3"); 159 bt3.text_set("Button 3");
152 bt3.event_clicked_callback_add(unpack); 160 bt3.event_clicked_callback_add(unpack);
153 dynamic.pack_end(bt3); 161 dynamic.pack_end(bt3);
@@ -170,19 +178,9 @@ elm_main(int argc, char *argv[])
170 win.size_set(300, 320); 178 win.size_set(300, 320);
171 win.visibility_set(true); 179 win.visibility_set(true);
172 180
173 // bigbox._release();
174 // buttons._release();
175 // add._release();
176 // clear._release();
177 // dynamic._release();
178 // bt1._release();
179 // bt2._release();
180 // bt3._release();
181
182
183 std::cout << "references to win " << win.ref_get() << std::endl; 181 std::cout << "references to win " << win.ref_get() << std::endl;
184 test = win._eo_ptr(); 182 test = win._eo_ptr();
185 //win._release(); 183 win._release();
186 } 184 }
187 std::cout << "references to win " << ::eo_ref_get(test) << std::endl; 185 std::cout << "references to win " << ::eo_ref_get(test) << std::endl;
188 186