summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKai Huuhko <kai.huuhko@gmail.com>2014-06-02 09:18:01 +0300
committerKai Huuhko <kai.huuhko@gmail.com>2014-06-02 09:18:01 +0300
commit5045352434529b93e26316b732bd32989fd160ce (patch)
treee2983d00fb1ed67b5f2c4c46cd45dc643305a94a
parent59f2835f53b2bf45365f45d6c5c921a191d2317b (diff)
Evas: Add NULL safety to SmartObject callbacks, exposes a BUG
Apparently the Python instance gets deleted before the smart hide/del callbacks are called (by eo callback?).
-rw-r--r--efl/evas/efl.evas.pyx6
-rw-r--r--efl/evas/efl.evas_object_smart.pxi129
-rwxr-xr-xexamples/elementary/test.py7
3 files changed, 113 insertions, 29 deletions
diff --git a/efl/evas/efl.evas.pyx b/efl/evas/efl.evas.pyx
index fa63f8a..fc96dd0 100644
--- a/efl/evas/efl.evas.pyx
+++ b/efl/evas/efl.evas.pyx
@@ -17,6 +17,10 @@
17 17
18cimport efl.evas.enums as enums 18cimport efl.evas.enums as enums
19from efl.utils.conversions cimport eina_list_strings_to_python_list 19from efl.utils.conversions cimport eina_list_strings_to_python_list
20from efl.eina cimport EINA_LOG_DOM_DBG, EINA_LOG_DOM_INFO, EINA_LOG_DOM_WARN
21from efl.utils.logger cimport add_logger
22
23cdef int PY_EFL_EVAS_LOG_DOMAIN = add_logger(__name__).eina_log_domain
20 24
21EVAS_LAYER_MIN = enums.EVAS_LAYER_MIN 25EVAS_LAYER_MIN = enums.EVAS_LAYER_MIN
22EVAS_LAYER_MAX = enums.EVAS_LAYER_MAX 26EVAS_LAYER_MAX = enums.EVAS_LAYER_MAX
@@ -152,6 +156,7 @@ EVAS_ASPECT_CONTROL_BOTH = enums.EVAS_ASPECT_CONTROL_BOTH
152EVAS_SMART_CLASS_VERSION = enums.EVAS_SMART_CLASS_VERSION 156EVAS_SMART_CLASS_VERSION = enums.EVAS_SMART_CLASS_VERSION
153 157
154def init(): 158def init():
159 EINA_LOG_DOM_INFO(PY_EFL_EVAS_LOG_DOMAIN, "Initializing efl.evas", NULL)
155 # when changing these, also change __init__.py! 160 # when changing these, also change __init__.py!
156# if evas_object_event_callbacks_len != EVAS_CALLBACK_LAST: 161# if evas_object_event_callbacks_len != EVAS_CALLBACK_LAST:
157# raise SystemError("Number of object callbacks changed from %d to %d." % 162# raise SystemError("Number of object callbacks changed from %d to %d." %
@@ -163,6 +168,7 @@ def init():
163 168
164 169
165def shutdown(): 170def shutdown():
171 EINA_LOG_DOM_INFO(PY_EFL_EVAS_LOG_DOMAIN, "Shutting down efl.evas", NULL)
166 return evas_shutdown() 172 return evas_shutdown()
167 173
168 174
diff --git a/efl/evas/efl.evas_object_smart.pxi b/efl/evas/efl.evas_object_smart.pxi
index 0bd5f49..d9f249d 100644
--- a/efl/evas/efl.evas_object_smart.pxi
+++ b/efl/evas/efl.evas_object_smart.pxi
@@ -30,8 +30,14 @@ _install_metaclass(EvasSmartObjectMeta, ClippedSmartObject)
30 30
31 31
32cdef void _smart_object_delete(Evas_Object *o) with gil: 32cdef void _smart_object_delete(Evas_Object *o) with gil:
33 cdef SmartObject obj 33 cdef:
34 obj = <SmartObject>evas_object_data_get(o, "python-eo") 34 void *tmp
35 SmartObject obj
36 tmp = evas_object_data_get(o, "python-eo")
37 if tmp == NULL:
38 EINA_LOG_DOM_WARN(PY_EFL_EVAS_LOG_DOMAIN, "obj is NULL!", NULL)
39 return
40 obj = <SmartObject>tmp
35 41
36 try: 42 try:
37 obj._m_delete(obj) 43 obj._m_delete(obj)
@@ -110,8 +116,14 @@ cdef void _smart_object_delete(Evas_Object *o) with gil:
110 116
111cdef void _smart_object_move(Evas_Object *o, 117cdef void _smart_object_move(Evas_Object *o,
112 Evas_Coord x, Evas_Coord y) with gil: 118 Evas_Coord x, Evas_Coord y) with gil:
113 cdef SmartObject obj 119 cdef:
114 obj = <SmartObject>evas_object_data_get(o, "python-eo") 120 void *tmp
121 SmartObject obj
122 tmp = evas_object_data_get(o, "python-eo")
123 if tmp == NULL:
124 EINA_LOG_DOM_WARN(PY_EFL_EVAS_LOG_DOMAIN, "obj is NULL!", NULL)
125 return
126 obj = <SmartObject>tmp
115 if obj._m_move is not None: 127 if obj._m_move is not None:
116 try: 128 try:
117 obj._m_move(obj, x, y) 129 obj._m_move(obj, x, y)
@@ -121,8 +133,14 @@ cdef void _smart_object_move(Evas_Object *o,
121 133
122cdef void _smart_object_resize(Evas_Object *o, 134cdef void _smart_object_resize(Evas_Object *o,
123 Evas_Coord w, Evas_Coord h) with gil: 135 Evas_Coord w, Evas_Coord h) with gil:
124 cdef SmartObject obj 136 cdef:
125 obj = <SmartObject>evas_object_data_get(o, "python-eo") 137 void *tmp
138 SmartObject obj
139 tmp = evas_object_data_get(o, "python-eo")
140 if tmp == NULL:
141 EINA_LOG_DOM_WARN(PY_EFL_EVAS_LOG_DOMAIN, "obj is NULL!", NULL)
142 return
143 obj = <SmartObject>tmp
126 if obj._m_resize is not None: 144 if obj._m_resize is not None:
127 try: 145 try:
128 obj._m_resize(obj, w, h) 146 obj._m_resize(obj, w, h)
@@ -131,8 +149,14 @@ cdef void _smart_object_resize(Evas_Object *o,
131 149
132 150
133cdef void _smart_object_show(Evas_Object *o) with gil: 151cdef void _smart_object_show(Evas_Object *o) with gil:
134 cdef SmartObject obj 152 cdef:
135 obj = <SmartObject>evas_object_data_get(o, "python-eo") 153 void *tmp
154 SmartObject obj
155 tmp = evas_object_data_get(o, "python-eo")
156 if tmp == NULL:
157 EINA_LOG_DOM_WARN(PY_EFL_EVAS_LOG_DOMAIN, "obj is NULL!", NULL)
158 return
159 obj = <SmartObject>tmp
136 if obj._m_show is not None: 160 if obj._m_show is not None:
137 try: 161 try:
138 obj._m_show(obj) 162 obj._m_show(obj)
@@ -141,8 +165,14 @@ cdef void _smart_object_show(Evas_Object *o) with gil:
141 165
142 166
143cdef void _smart_object_hide(Evas_Object *o) with gil: 167cdef void _smart_object_hide(Evas_Object *o) with gil:
144 cdef SmartObject obj 168 cdef:
145 obj = <SmartObject>evas_object_data_get(o, "python-eo") 169 void *tmp
170 SmartObject obj
171 tmp = evas_object_data_get(o, "python-eo")
172 if tmp == NULL:
173 EINA_LOG_DOM_WARN(PY_EFL_EVAS_LOG_DOMAIN, "obj is NULL!", NULL)
174 return
175 obj = <SmartObject>tmp
146 if obj._m_hide is not None: 176 if obj._m_hide is not None:
147 try: 177 try:
148 obj._m_hide(obj) 178 obj._m_hide(obj)
@@ -152,8 +182,14 @@ cdef void _smart_object_hide(Evas_Object *o) with gil:
152 182
153cdef void _smart_object_color_set(Evas_Object *o, 183cdef void _smart_object_color_set(Evas_Object *o,
154 int r, int g, int b, int a) with gil: 184 int r, int g, int b, int a) with gil:
155 cdef SmartObject obj 185 cdef:
156 obj = <SmartObject>evas_object_data_get(o, "python-eo") 186 void *tmp
187 SmartObject obj
188 tmp = evas_object_data_get(o, "python-eo")
189 if tmp == NULL:
190 EINA_LOG_DOM_WARN(PY_EFL_EVAS_LOG_DOMAIN, "obj is NULL!", NULL)
191 return
192 obj = <SmartObject>tmp
157 if obj._m_color_set is not None: 193 if obj._m_color_set is not None:
158 try: 194 try:
159 obj._m_color_set(obj, r, g, b, a) 195 obj._m_color_set(obj, r, g, b, a)
@@ -162,9 +198,15 @@ cdef void _smart_object_color_set(Evas_Object *o,
162 198
163 199
164cdef void _smart_object_clip_set(Evas_Object *o, Evas_Object *clip) with gil: 200cdef void _smart_object_clip_set(Evas_Object *o, Evas_Object *clip) with gil:
165 cdef SmartObject obj 201 cdef:
166 cdef Object other 202 void *tmp
167 obj = <SmartObject>evas_object_data_get(o, "python-eo") 203 SmartObject obj
204 Object other
205 tmp = evas_object_data_get(o, "python-eo")
206 if tmp == NULL:
207 EINA_LOG_DOM_WARN(PY_EFL_EVAS_LOG_DOMAIN, "obj is NULL!", NULL)
208 return
209 obj = <SmartObject>tmp
168 other = object_from_instance(clip) 210 other = object_from_instance(clip)
169 if obj._m_clip_set is not None: 211 if obj._m_clip_set is not None:
170 try: 212 try:
@@ -174,8 +216,14 @@ cdef void _smart_object_clip_set(Evas_Object *o, Evas_Object *clip) with gil:
174 216
175 217
176cdef void _smart_object_clip_unset(Evas_Object *o) with gil: 218cdef void _smart_object_clip_unset(Evas_Object *o) with gil:
177 cdef SmartObject obj 219 cdef:
178 obj = <SmartObject>evas_object_data_get(o, "python-eo") 220 void *tmp
221 SmartObject obj
222 tmp = evas_object_data_get(o, "python-eo")
223 if tmp == NULL:
224 EINA_LOG_DOM_WARN(PY_EFL_EVAS_LOG_DOMAIN, "obj is NULL!", NULL)
225 return
226 obj = <SmartObject>tmp
179 if obj._m_clip_unset is not None: 227 if obj._m_clip_unset is not None:
180 try: 228 try:
181 obj._m_clip_unset(obj) 229 obj._m_clip_unset(obj)
@@ -184,8 +232,14 @@ cdef void _smart_object_clip_unset(Evas_Object *o) with gil:
184 232
185 233
186cdef void _smart_object_calculate(Evas_Object *o) with gil: 234cdef void _smart_object_calculate(Evas_Object *o) with gil:
187 cdef SmartObject obj 235 cdef:
188 obj = <SmartObject>evas_object_data_get(o, "python-eo") 236 void *tmp
237 SmartObject obj
238 tmp = evas_object_data_get(o, "python-eo")
239 if tmp == NULL:
240 EINA_LOG_DOM_WARN(PY_EFL_EVAS_LOG_DOMAIN, "obj is NULL!", NULL)
241 return
242 obj = <SmartObject>tmp
189 if obj._m_calculate is not None: 243 if obj._m_calculate is not None:
190 try: 244 try:
191 obj._m_calculate(obj) 245 obj._m_calculate(obj)
@@ -194,9 +248,15 @@ cdef void _smart_object_calculate(Evas_Object *o) with gil:
194 248
195 249
196cdef void _smart_object_member_add(Evas_Object *o, Evas_Object *clip) with gil: 250cdef void _smart_object_member_add(Evas_Object *o, Evas_Object *clip) with gil:
197 cdef SmartObject obj 251 cdef:
198 cdef Object other 252 void *tmp
199 obj = <SmartObject>evas_object_data_get(o, "python-eo") 253 SmartObject obj
254 Object other
255 tmp = evas_object_data_get(o, "python-eo")
256 if tmp == NULL:
257 EINA_LOG_DOM_WARN(PY_EFL_EVAS_LOG_DOMAIN, "obj is NULL!", NULL)
258 return
259 obj = <SmartObject>tmp
200 other = object_from_instance(clip) 260 other = object_from_instance(clip)
201 if obj._m_member_add is not None: 261 if obj._m_member_add is not None:
202 try: 262 try:
@@ -206,9 +266,15 @@ cdef void _smart_object_member_add(Evas_Object *o, Evas_Object *clip) with gil:
206 266
207 267
208cdef void _smart_object_member_del(Evas_Object *o, Evas_Object *clip) with gil: 268cdef void _smart_object_member_del(Evas_Object *o, Evas_Object *clip) with gil:
209 cdef SmartObject obj 269 cdef:
210 cdef Object other 270 void *tmp
211 obj = <SmartObject>evas_object_data_get(o, "python-eo") 271 SmartObject obj
272 Object other
273 tmp = evas_object_data_get(o, "python-eo")
274 if tmp == NULL:
275 EINA_LOG_DOM_WARN(PY_EFL_EVAS_LOG_DOMAIN, "obj is NULL!", NULL)
276 return
277 obj = <SmartObject>tmp
212 other = object_from_instance(clip) 278 other = object_from_instance(clip)
213 if obj._m_member_del is not None: 279 if obj._m_member_del is not None:
214 try: 280 try:
@@ -219,9 +285,16 @@ cdef void _smart_object_member_del(Evas_Object *o, Evas_Object *clip) with gil:
219 285
220cdef void _smart_callback(void *data, 286cdef void _smart_callback(void *data,
221 Evas_Object *o, void *event_info) with gil: 287 Evas_Object *o, void *event_info) with gil:
222 cdef SmartObject obj 288
223 cdef object event, ei 289 cdef:
224 obj = <SmartObject>evas_object_data_get(o, "python-eo") 290 void *tmp
291 SmartObject obj
292 object event, ei
293 tmp = evas_object_data_get(o, "python-eo")
294 if tmp == NULL:
295 EINA_LOG_DOM_WARN(PY_EFL_EVAS_LOG_DOMAIN, "obj is NULL!", NULL)
296 return
297 obj = <SmartObject>tmp
225 event = <object>data 298 event = <object>data
226 ei = <object>event_info 299 ei = <object>event_info
227 lst = tuple(obj._smart_callbacks[event]) 300 lst = tuple(obj._smart_callbacks[event])
diff --git a/examples/elementary/test.py b/examples/elementary/test.py
index 462885f..d99dadd 100755
--- a/examples/elementary/test.py
+++ b/examples/elementary/test.py
@@ -5,7 +5,9 @@ import logging
5elog = logging.getLogger("efl") 5elog = logging.getLogger("efl")
6elog.setLevel(logging.INFO) 6elog.setLevel(logging.INFO)
7 7
8elog_form = logging.Formatter("[%(name)s] %(levelname)s - %(message)s") 8elog_form = logging.Formatter(
9 "[%(name)s] %(levelname)s in %(funcName)s:%(lineno)d - %(message)s"
10 )
9elog_hdlr = logging.StreamHandler() 11elog_hdlr = logging.StreamHandler()
10elog_hdlr.setFormatter(elog_form) 12elog_hdlr.setFormatter(elog_form)
11 13
@@ -14,6 +16,9 @@ elog.addHandler(elog_hdlr)
14eolog = logging.getLogger("efl.eo") 16eolog = logging.getLogger("efl.eo")
15eolog.setLevel(logging.INFO) 17eolog.setLevel(logging.INFO)
16 18
19evaslog = logging.getLogger("efl.evas")
20evaslog.setLevel(logging.INFO)
21
17import os 22import os
18 23
19from efl.evas import EVAS_HINT_EXPAND, EVAS_HINT_FILL 24from efl.evas import EVAS_HINT_EXPAND, EVAS_HINT_FILL