summaryrefslogtreecommitdiff
path: root/src/lib/eo/eo.c
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2018-06-29 11:31:10 -0400
committerMike Blumenkrantz <zmike@samsung.com>2018-06-29 11:31:10 -0400
commit1332e0e0259e6291f34c2eaf317aa9452d19e316 (patch)
treed5d9755c0acdd16d4f07e8ef6a69e3ad7f815e45 /src/lib/eo/eo.c
parentcf23ec291d04818d29245c1bc65731ec9eeb0bd4 (diff)
eo: improve thread check during class construction
Summary: a common use case is for a class to be constructed during a thread+mainloop sync (e.g., ecore_thread_main_loop_begin() ecore_thread_main_loop_end()) and then naturally destroyed in the main thread during shutdown ref 023a9ca2ee32529849e770f057f58592956dee47 Reviewers: bu5hm4n, devilhorns Reviewed By: bu5hm4n Subscribers: cedric, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D6472
Diffstat (limited to 'src/lib/eo/eo.c')
-rw-r--r--src/lib/eo/eo.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c
index f2ee051..3fb7fd6 100644
--- a/src/lib/eo/eo.c
+++ b/src/lib/eo/eo.c
@@ -1298,8 +1298,7 @@ _eo_class_constructor(_Efl_Class *klass)
1298{ 1298{
1299 klass->constructed = EINA_TRUE; 1299 klass->constructed = EINA_TRUE;
1300 1300
1301 if (eina_thread_self() != _efl_object_main_thread) 1301 klass->construction_thread = eina_thread_self();
1302 CRI("Calling class constructor from non-main thread! This will crash later!");
1303 1302
1304 if (klass->desc->class_constructor) 1303 if (klass->desc->class_constructor)
1305 klass->desc->class_constructor(_eo_class_id_get(klass)); 1304 klass->desc->class_constructor(_eo_class_id_get(klass));
@@ -1309,9 +1308,12 @@ static void
1309eo_class_free(_Efl_Class *klass) 1308eo_class_free(_Efl_Class *klass)
1310{ 1309{
1311 void *data; 1310 void *data;
1311 Eina_Thread self = eina_thread_self();
1312 1312
1313 if (eina_thread_self() != _efl_object_main_thread) 1313 if ((self != _efl_object_main_thread) &&
1314 CRI("Calling class deconstructor from non-main thread! This will crash!"); 1314 (self != klass->construction_thread))
1315 CRI("Calling class deconstructor from thread that did not call constructor and is not main thread!\n"
1316 "This will probably crash!");
1315 1317
1316 if (klass->constructed) 1318 if (klass->constructed)
1317 { 1319 {