diff --git a/interfaces/cython/cantera/_cantera.pxd b/interfaces/cython/cantera/_cantera.pxd index 47fb520bb..39c74c638 100644 --- a/interfaces/cython/cantera/_cantera.pxd +++ b/interfaces/cython/cantera/_cantera.pxd @@ -747,6 +747,7 @@ cdef class _SolutionBase: cdef int thermo_basis cdef np.ndarray _selected_species cdef object parent + cdef cbool is_slice cdef class ThermoPhase(_SolutionBase): cdef double _mass_factor(self) diff --git a/interfaces/cython/cantera/base.pyx b/interfaces/cython/cantera/base.pyx index a58dfe080..a40a578bb 100644 --- a/interfaces/cython/cantera/base.pyx +++ b/interfaces/cython/cantera/base.pyx @@ -9,7 +9,8 @@ cdef class _SolutionBase: # keep a reference to the parent to prevent the underlying # C++ objects from being deleted - self.parent = other + self.parent = origin + self.is_slice = True self.thermo = other.thermo self.kinetics = other.kinetics @@ -19,6 +20,8 @@ cdef class _SolutionBase: self._selected_species = other._selected_species.copy() return + self.is_slice = False + if infile or source: self._init_cti_xml(infile, phaseid, phases, source) elif thermo and species: @@ -128,7 +131,7 @@ cdef class _SolutionBase: def __dealloc__(self): # only delete the C++ objects if this is the parent object - if self.parent is None: + if not self.is_slice: del self.thermo del self.kinetics del self.transport