Commit c775bd19 authored by Peter Eastman's avatar Peter Eastman
Browse files

Fixed error that required Context and Integrator to be deleted in a particular order

parent cd6af26e
......@@ -54,6 +54,7 @@ class ContextImpl;
class OPENMM_EXPORT Integrator {
public:
virtual ~Integrator() {
cleanup();
}
/**
* Get the size of each time step, in picoseconds. If this integrator uses variable time steps,
......@@ -92,6 +93,7 @@ public:
*/
virtual void step(int steps) = 0;
protected:
friend class Context;
friend class ContextImpl;
/**
* This will be called by the Context when it is created. It informs the Integrator
......@@ -103,7 +105,8 @@ protected:
* This will be called by the Context when it is destroyed to let the Integrator do any necessary
* cleanup. It will also get called again if the application calls reinitialize() on the Context.
*/
virtual void cleanup() = 0;
virtual void cleanup() {
};
/**
* Get the names of all Kernels used by this Integrator.
*/
......
......@@ -216,6 +216,7 @@ void Context::reinitialize() {
System& system = impl->getSystem();
Integrator& integrator = impl->getIntegrator();
Platform& platform = impl->getPlatform();
integrator.cleanup();
delete impl;
impl = new ContextImpl(*this, system, integrator, &platform, properties);
}
......
......@@ -122,7 +122,6 @@ ContextImpl::~ContextImpl() {
updateStateDataKernel = Kernel();
applyConstraintsKernel = Kernel();
virtualSitesKernel = Kernel();
integrator.cleanup();
platform->contextDestroyed(*this);
}
......
......@@ -255,6 +255,7 @@ CudaContext::~CudaContext() {
string errorMessage = "Error deleting Context";
if (contextIsValid)
CHECK_RESULT(cuCtxDestroy(context));
contextIsValid = false;
}
void CudaContext::initialize() {
......
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