csharp: Fix test code memory handling
authorLauro Moura <lauromoura@expertisesolutions.com.br>
Tue, 23 Apr 2019 15:12:31 +0000 (12:12 -0300)
committerYeongjong Lee <yj34.lee@samsung.com>
Wed, 24 Apr 2019 05:24:47 +0000 (14:24 +0900)
Summary:
It was causing the test to crash when running in debug build.

Also some minor fixes cleaning up stuff when exiting.

Fixes T7792.

Reviewers: segfaultxavi, vitor.sousa

Reviewed By: segfaultxavi, vitor.sousa

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Maniphest Tasks: T7792

Differential Revision: https://phab.enlightenment.org/D8679

src/tests/efl_mono/dummy_test_object.eo
src/tests/efl_mono/libefl_mono_native_test.c

index a50c70e..b5436a6 100644 (file)
@@ -1412,6 +1412,7 @@ class Dummy.Test_Object extends Efl.Object implements Dummy.Test_Iface {
    }
    implements {
       Efl.Object.constructor;
+      Efl.Object.destructor;
       Efl.Object.provider_find;
       Dummy.Test_Iface.emit_nonconflicted;
       Dummy.Test_Iface.iface_prop { get; set; }
index 17ef506..52d9190 100644 (file)
@@ -162,6 +162,30 @@ _dummy_test_object_efl_object_constructor(Eo *obj, Dummy_Test_Object_Data *pd)
    return obj;
 }
 
+static void
+_dummy_test_object_efl_object_destructor(Eo *obj, Dummy_Test_Object_Data *pd)
+{
+   if (pd->stored_value)
+     {
+        eina_value_free(pd->stored_value);
+        pd->stored_value = NULL;
+     }
+
+   if (pd->promise)
+     {
+        eina_promise_reject(pd->promise, ECANCELED);
+        pd->promise = NULL;
+     }
+
+   if (pd->list_for_accessor)
+     {
+        eina_list_free(pd->list_for_accessor);
+        pd->list_for_accessor = NULL;
+     }
+
+   efl_destructor(efl_super(obj, DUMMY_TEST_OBJECT_CLASS));
+}
+
 Efl_Object *_dummy_test_object_return_object(Eo *obj, EINA_UNUSED Dummy_Test_Object_Data *pd)
 {
   return obj;
@@ -3700,11 +3724,11 @@ void _dummy_test_object_set_value_ptr_own(EINA_UNUSED Eo *obj, Dummy_Test_Object
 
 void _dummy_test_object_set_value(EINA_UNUSED Eo *obj, Dummy_Test_Object_Data *pd, Eina_Value value)
 {
-    if (pd->stored_value) {
-        eina_value_free(pd->stored_value);
-    } else {
-        pd->stored_value = eina_value_new(EINA_VALUE_TYPE_INT);
-    }
+    if (pd->stored_value)
+      eina_value_free(pd->stored_value);
+
+    pd->stored_value = eina_value_new(EINA_VALUE_TYPE_INT);
+
     eina_value_copy(&value, pd->stored_value);
 }
 
@@ -3922,7 +3946,6 @@ int _dummy_test_object_dummy_test_iface_iface_prop_get(EINA_UNUSED const Eo *obj
 
 Eo * _dummy_test_object_efl_object_provider_find(EINA_UNUSED const Eo *obj, Dummy_Test_Object_Data *pd, const Efl_Class *klass)
 {
-    EINA_LOG_ERR("klass: %p, NUMBERWRAPPER: %p", klass, DUMMY_NUMBERWRAPPER_CLASS);
     if (klass == DUMMY_NUMBERWRAPPER_CLASS)
         return pd->provider;
     else if (klass == DUMMY_TEST_IFACE_INTERFACE)
@@ -3932,13 +3955,11 @@ Eo * _dummy_test_object_efl_object_provider_find(EINA_UNUSED const Eo *obj, Dumm
 
 Efl_Object *_dummy_test_object_call_find_provider(Eo *obj, EINA_UNUSED Dummy_Test_Object_Data *pd, const Efl_Class *type)
 {
-    printf("CALLING FIND PROVIDER FROM C");
     return efl_provider_find(obj, type);
 }
 
 Efl_Object *_dummy_test_object_call_find_provider_for_iface(Eo *obj, EINA_UNUSED Dummy_Test_Object_Data *pd)
 {
-    printf("CALLING FIND PROVIDER FROM C");
     return efl_provider_find(obj, DUMMY_TEST_IFACE_INTERFACE);
 }