Skip to content

Commit b62b99d

Browse files
committed
[Python] Fix garbage collection error with Mixture objects (Cantera#2091)
Using shared_ptr route ensures ThermoPhase objects used by MultiPhase are still present when the MultiPhase destructor runs.
1 parent bab22d3 commit b62b99d

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

interfaces/cython/cantera/mixture.pxd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ cdef extern from "cantera/equil/MultiPhase.h" namespace "Cantera":
1010
cdef cppclass CxxThermoPhase "Cantera::ThermoPhase"
1111
cdef cppclass CxxMultiPhase "Cantera::MultiPhase":
1212
CxxMultiPhase()
13-
void addPhase(CxxThermoPhase*, double) except +translate_exception
13+
void addPhase(shared_ptr[CxxThermoPhase], double) except +translate_exception
1414
void init() except +translate_exception
1515
void updatePhases() except +translate_exception
1616

interfaces/cython/cantera/mixture.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ cdef class Mixture:
5757

5858
for phase,moles in phases:
5959
# Block species from being added to the phase as long as this object exists
60-
self.mix.addPhase(phase.thermo, moles)
60+
self.mix.addPhase(phase._base.get().thermo(), moles)
6161
self._phases.append(phase)
6262

6363
self.mix.init()

0 commit comments

Comments
 (0)