From 289a4e3aaa26dead4d4374568b135ccd655dd897 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Andre Date: Fri, 10 Nov 2017 17:18:12 +0900 Subject: [PATCH] cxx: Only give a single ref to unparented objects On instantiation objects get either one or two refs: - with a parent, they will have 2 refs, one for C++, one for the parent. - without a parent, they get a single ref, the one for C++ This will break the existing C++ examples, which I will fix in later patches. Note that the window is a strange object which can be created with no parent but internally reparents itself to an object it creates (oh so ugly). --- src/bindings/cxx/eo_cxx/eo_cxx_interop.hh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/bindings/cxx/eo_cxx/eo_cxx_interop.hh b/src/bindings/cxx/eo_cxx/eo_cxx_interop.hh index 72c435e4d7..662e5a7d55 100644 --- a/src/bindings/cxx/eo_cxx/eo_cxx_interop.hh +++ b/src/bindings/cxx/eo_cxx/eo_cxx_interop.hh @@ -846,8 +846,9 @@ inline void do_eo_add(Eo*& object, P const& parent , Efl_Class const* klass , typename std::enable_if< eo::is_eolian_object

::value>::type* = 0) { - object = ::_efl_add_internal_start(__FILE__, __LINE__, klass, parent._eo_ptr(), EINA_TRUE, EINA_FALSE); - object = ::_efl_add_end(object, EINA_TRUE, EINA_FALSE); + bool is_ref = (parent._eo_ptr() != nullptr); + object = ::_efl_add_internal_start(__FILE__, __LINE__, klass, parent._eo_ptr(), is_ref, EINA_FALSE); + object = ::_efl_add_end(object, is_ref, EINA_FALSE); } template @@ -871,9 +872,10 @@ void do_eo_add(Eo*& object, P const& parent, Efl_Class const* klass , F&& f , typename std::enable_if< eo::is_eolian_object

::value>::type* = 0) { - object = ::_efl_add_internal_start(__FILE__, __LINE__, klass, parent._eo_ptr(), EINA_TRUE, EINA_FALSE); + bool is_ref = (parent._eo_ptr() != nullptr); + object = ::_efl_add_internal_start(__FILE__, __LINE__, klass, parent._eo_ptr(), is_ref, EINA_FALSE); ::efl::eolian::call_lambda(std::forward(f), proxy); - object = ::_efl_add_end(object, EINA_TRUE, EINA_FALSE); + object = ::_efl_add_end(object, is_ref, EINA_FALSE); } template