From 0db1f24f9a4d17cfcbd0862f29beac659bcf3e1d Mon Sep 17 00:00:00 2001 From: "Eunki, Hong" Date: Mon, 24 Oct 2022 22:08:23 +0900 Subject: [PATCH] Resolve C# retrieving string output lifecycle Change-Id: I95a1b865efa3c2c9171d6c5d810d953e2cd41b9a Signed-off-by: Eunki, Hong --- .../src/internal-visual-property-get-set-wrap.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/dali-csharp-binder/src/internal-visual-property-get-set-wrap.cpp b/dali-csharp-binder/src/internal-visual-property-get-set-wrap.cpp index 710d934..c35e7a2 100755 --- a/dali-csharp-binder/src/internal-visual-property-get-set-wrap.cpp +++ b/dali-csharp-binder/src/internal-visual-property-get-set-wrap.cpp @@ -186,6 +186,12 @@ extern "C" try { + // Copy inputed initialized string. + // Note : C# side inputed string reference count become reduced. + // So, If we want to keep life when we fail to get result, + // We should re-convert by SWIG_csharp_string_callback. + std::string temp = (*valString == nullptr) ? "" : *valString; + Dali::Toolkit::Internal::Control& internalControl = Dali::Toolkit::Internal::GetImplementation(*pControl); Dali::Toolkit::Visual::Base visualBase = Dali::Toolkit::DevelControl::GetVisual(internalControl, visualIndex); if(visualBase) @@ -196,13 +202,13 @@ extern "C" if(retValuePtr) { //typemap in - std::string temp = retValuePtr->Get(); - - //Typemap argout in c++ file. - //This will convert c++ string to c# string - *valString = SWIG_csharp_string_callback(temp.c_str()); + temp = retValuePtr->Get(); } } + + //Typemap argout in c++ file. + //This will convert c++ string to c# string + *valString = SWIG_csharp_string_callback(temp.c_str()); } CALL_CATCH_EXCEPTION((int)InternalPropertyReturnType::ERROR_UNKNOWN); -- 2.7.4