summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib/eo/eo_private.h11
-rw-r--r--src/tests/eo/suite/eo_test_class_behaviour_errors.c34
2 files changed, 40 insertions, 5 deletions
diff --git a/src/lib/eo/eo_private.h b/src/lib/eo/eo_private.h
index 7ea5014..a238618 100644
--- a/src/lib/eo/eo_private.h
+++ b/src/lib/eo/eo_private.h
@@ -279,21 +279,22 @@ _eo_unref(_Eo_Object *obj)
279 --(obj->refcount); 279 --(obj->refcount);
280 if (obj->refcount == 0) 280 if (obj->refcount == 0)
281 { 281 {
282 if (obj->del_triggered) 282 if (obj->destructed)
283 { 283 {
284 ERR("Object %p deletion already triggered. You wrongly call eo_unref() within a destructor.", obj); 284 ERR("Object %p already destructed.", _eo_id_get(obj));
285 return; 285 return;
286 } 286 }
287 obj->del_triggered = EINA_TRUE;
288 287
289 if (obj->destructed) 288 if (obj->del_triggered)
290 { 289 {
291 ERR("Object %p already destructed.", obj); 290 ERR("Object %p deletion already triggered. You wrongly call eo_unref() within a destructor.", _eo_id_get(obj));
292 return; 291 return;
293 } 292 }
293 obj->del_triggered = EINA_TRUE;
294 294
295 _eo_del_internal(__FILE__, __LINE__, obj); 295 _eo_del_internal(__FILE__, __LINE__, obj);
296 296
297 obj->del_triggered = EINA_FALSE;
297#ifdef EO_DEBUG 298#ifdef EO_DEBUG
298 /* If for some reason it's not empty, clear it. */ 299 /* If for some reason it's not empty, clear it. */
299 while (obj->xrefs) 300 while (obj->xrefs)
diff --git a/src/tests/eo/suite/eo_test_class_behaviour_errors.c b/src/tests/eo/suite/eo_test_class_behaviour_errors.c
index 300f3fa..a54a2f2 100644
--- a/src/tests/eo/suite/eo_test_class_behaviour_errors.c
+++ b/src/tests/eo/suite/eo_test_class_behaviour_errors.c
@@ -57,7 +57,41 @@ START_TEST(eo_destructor_unref)
57} 57}
58END_TEST 58END_TEST
59 59
60START_TEST(eo_destructor_double_del)
61{
62 eo_init();
63 eina_log_print_cb_set(eo_test_print_cb, &ctx);
64
65 static Eo_Class_Description class_desc = {
66 EO_VERSION,
67 "Simple",
68 EO_CLASS_TYPE_REGULAR,
69 EO_CLASS_DESCRIPTION_NOOPS(),
70 NULL,
71 0,
72 NULL,
73 NULL
74 };
75
76 klass = eo_class_new(&class_desc, SIMPLE_CLASS, NULL);
77 fail_if(!klass);
78
79 Eo *obj = eo_add(klass, NULL);
80 eo_manual_free_set(obj, EINA_TRUE);
81 fail_if(!obj);
82
83 TEST_EO_ERROR("_eo_unref", "Object %p already destructed.");
84 eo_del(obj);
85 eo_del(obj);
86
87 eina_log_print_cb_set(eina_log_print_cb_stderr, NULL);
88
89 eo_shutdown();
90}
91END_TEST
92
60void eo_test_class_behaviour_errors(TCase *tc) 93void eo_test_class_behaviour_errors(TCase *tc)
61{ 94{
62 tcase_add_test(tc, eo_destructor_unref); 95 tcase_add_test(tc, eo_destructor_unref);
96 tcase_add_test(tc, eo_destructor_double_del);
63} 97}