Skip to content

Commit 43f34d6

Browse files
committed
maint: Merge stable to default.
2 parents 26f87e3 + 222f324 commit 43f34d6

File tree

5 files changed

+28
-0
lines changed

5 files changed

+28
-0
lines changed

libinterp/octave-value/cdef-object.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,13 @@ cdef_object_array::fill_empty_values (Array<cdef_object>& arr)
541541
}
542542
}
543543

544+
void
545+
cdef_object_array::break_closure_cycles (const std::shared_ptr<stack_frame>& frame)
546+
{
547+
for (octave_idx_type i = 0; i < m_array.numel (); i++)
548+
m_array(i).break_closure_cycles (frame);
549+
}
550+
544551
void
545552
cdef_object_scalar::break_closure_cycles (const std::shared_ptr<stack_frame>& frame)
546553
{

libinterp/octave-value/cdef-object.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,9 @@ class OCTINTERP_API cdef_object_array : public cdef_object_base
414414

415415
dim_vector dims () const { return m_array.dims (); }
416416

417+
OCTINTERP_API void
418+
break_closure_cycles (const std::shared_ptr<stack_frame>& frame);
419+
417420
bool is_valid () const { return true; }
418421

419422
bool is_array () const { return true; }
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
function fcn = cdef_array_break_cycles ()
2+
obj_array(1) = foo_value_class ();
3+
obj_array(2) = foo_value_class ();
4+
5+
function result = nested_func (x)
6+
result = obj_array;
7+
endfunction
8+
9+
fcn = @nested_func;
10+
endfunction

test/classdef/classdef.tst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,13 @@
219219
%!error <duplicate method> A = class_bug66930A ([1 2 3], 3);
220220
%!error <duplicate property> B = class_bug66930B ([1 2 3], 3);
221221

222+
## break closure cycles for classdef arrays
223+
%!test <*67749>
224+
%! fcn = cdef_array_break_cycles ();
225+
%! result = fcn ([]);
226+
%! assert (numel (result), 2);
227+
%! assert (class (result), "foo_value_class");
228+
222229
## duplicate definitions of methods in parent classes (bug #50011)
223230
%!error <method .* conflicting>
224231
%! cls_50011 = class_bug50011_1 ();

test/classdef/module.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ classdef_TEST_FILES = \
44
%reldir%/@class_bug67362/class_bug67362.m \
55
%reldir%/@class_bug67362/shared_name.m \
66
%reldir%/bug_60763.m \
7+
%reldir%/cdef_array_break_cycles.m \
78
%reldir%/class_bug50011_1.m \
89
%reldir%/class_bug50011_1A.m \
910
%reldir%/class_bug50011_1B.m \

0 commit comments

Comments
 (0)