SingleStruct clone and fieldExp corrected. 27/15327/3
Cedric Delamarre [Tue, 7 Oct 2014 09:45:56 +0000 (11:45 +0200)]
st.name = "test"
a=st(1).name // ref must be 2
a=st(1).name // ref must stay to 2

Change-Id: If04c085d7ee0d992735550aba0b5f0cda5584cb7

scilab/modules/ast/src/cpp/ast/runvisitor.cpp
scilab/modules/ast/src/cpp/types/singlestruct.cpp

index 708f607..8e5ab5d 100644 (file)
@@ -193,6 +193,8 @@ void RunVisitorT<T>::visitprivate(const FieldExp &e)
         os_swprintf(szError, bsiz, _W("Attempt to reference field of non-structure array.\n").c_str());
         throw ScilabError(szError, 999, e.getLocation());
     }
+
+    pValue->killMe();
 }
 
 template <class T>
index f0aa2ad..c2d8b83 100644 (file)
@@ -50,7 +50,8 @@ SingleStruct::SingleStruct(SingleStruct *_oSingleStructCopyMe)
     for (iterFieldData = Data.begin(); iterFieldData != Data.end() ; iterFieldData++, iterFieldName++)
     {
         m_wstFields.push_back(*iterFieldName);
-        m_Data.push_back((*iterFieldData)->clone());
+        m_Data.push_back(*iterFieldData);
+        m_Data.back()->IncreaseRef();
     }
 }