Unverified Commit 421eb42a authored by Peter Eastman's avatar Peter Eastman Committed by GitHub
Browse files

Fix memory error in PythonForce (#5182)

parent e688b86e
...@@ -12,6 +12,10 @@ namespace OpenMM { ...@@ -12,6 +12,10 @@ namespace OpenMM {
class ComputationWrapper : public PythonForceComputation { class ComputationWrapper : public PythonForceComputation {
public: public:
ComputationWrapper(PyObject* computation) : computation(computation) { ComputationWrapper(PyObject* computation) : computation(computation) {
Py_INCREF(computation);
}
~ComputationWrapper() {
Py_XDECREF(computation);
} }
void compute(const State& state, double& energy, void* forces, bool forcesAreDouble) const { void compute(const State& state, double& energy, void* forces, bool forcesAreDouble) const {
PyGILState_STATE gstate; PyGILState_STATE gstate;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment