[Cython] Fixed premature garbage collection of Reactor objects

This commit is contained in:
Ray Speth 2013-05-29 00:11:03 +00:00
parent 62dfdcfb01
commit 574bad76af
2 changed files with 10 additions and 0 deletions

View file

@ -564,9 +564,13 @@ cdef class Wall:
cdef WallSurface right_surface
cdef object _velocity_func
cdef object _heat_flux_func
cdef ReactorBase _left_reactor
cdef ReactorBase _right_reactor
cdef str name
cdef class FlowDevice:
cdef CxxFlowDevice* dev
cdef Func1 _rate_func
cdef str name
cdef ReactorBase _upstream
cdef ReactorBase _downstream

View file

@ -399,6 +399,9 @@ cdef class Wall:
left._add_wall(self)
right._add_wall(self)
self.wall.install(deref(left.rbase), deref(right.rbase))
# Keep references to prevent premature garbage collection
self._left_reactor = left
self._right_reactor = right
property left:
""" The left surface of this wall. """
@ -532,6 +535,9 @@ cdef class FlowDevice:
upstream._add_outlet(self)
downstream._add_inlet(self)
self.dev.install(deref(upstream.rbase), deref(downstream.rbase))
# Keep references to prevent premature garbage collection
self._upstream = upstream
self._downstream = downstream
def mdot(self, double t):
"""