From: Cedric Delamarre Date: Fri, 29 May 2015 09:10:48 +0000 (+0200) Subject: struct clone fixed. X-Git-Tag: 6.0.0-alpha-1~233 X-Git-Url: http://gitweb.scilab.org/?p=scilab.git;a=commitdiff_plain;h=dc9ef985efc777e393d03a94dfe59b1b7bdfee9e struct clone fixed. * A struct cloned must have all SingleStruct reference set to 1 because we cant increase reference of SingleStruct when we do it on a Struct. z.y = 42; y.o = z; // here z is cloned, after extraction of z(1), two Struct // contain the same SingleStruct with ref = 1 because of extraction without copy. // When the temporary Struct "z(1)" is deleted, the SingleStruct is deleted too. z(1).x=12; Change-Id: I3b90752cdae7cdfe172bed30d8ad67959dc787f6 --- diff --git a/scilab/modules/ast/src/cpp/types/struct.cpp b/scilab/modules/ast/src/cpp/types/struct.cpp index 14de9c8..3fde4f6 100644 --- a/scilab/modules/ast/src/cpp/types/struct.cpp +++ b/scilab/modules/ast/src/cpp/types/struct.cpp @@ -93,12 +93,8 @@ Struct::Struct(Struct *_oStructCopyMe) create(_oStructCopyMe->getDimsArray(), _oStructCopyMe->getDims(), &pIT, NULL); for (int i = 0 ; i < getSize() ; i++) { - m_pRealData[i] = NULL; - } - - for (int i = 0 ; i < getSize() ; i++) - { pIT[i] = _oStructCopyMe->get(i)->clone(); + pIT[i]->IncreaseRef(); } #ifndef NDEBUG Inspector::addItem(this);