ENH: force clearing of Time objectRegistry on destruction (#1276)

- the objectRegistry destructor seems to be called too late.
  Explicitly clear the objectRegistry within the Time destructor to
  ensure that it always happens.
This commit is contained in:
Mark Olesen
2019-04-10 11:30:31 +02:00
parent 335dfa14a5
commit 88e891cfb1
2 changed files with 13 additions and 1 deletions

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2004-2011, 2015-2018 OpenCFD Ltd. \\ / A nd | Copyright (C) 2004-2011, 2015-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2017 OpenFOAM Foundation | Copyright (C) 2011-2017 OpenFOAM Foundation
@ -727,6 +727,9 @@ Foam::Time::~Time()
// Clean up profiling // Clean up profiling
profiling::stop(*this); profiling::stop(*this);
// Ensure all owned objects are also cleaned up now
objectRegistry::clear();
} }

View File

@ -323,6 +323,14 @@ void Foam::objectRegistry::clear()
if (ptr && ptr->ownedByRegistry()) if (ptr && ptr->ownedByRegistry())
{ {
// TBD: may wish to have ptr->clearWatches();
if (objectRegistry::debug)
{
Pout<< "objectRegistry::clear : " << ptr->name()
<< " watches :" << flatOutput(ptr->watchIndices()) << nl;
}
delete ptr; delete ptr;
} }
} }
@ -350,6 +358,7 @@ bool Foam::objectRegistry::erase(const iterator& iter)
if (ptr && ptr->ownedByRegistry()) if (ptr && ptr->ownedByRegistry())
{ {
// TBD: may wish to have ptr->clearWatches();
delete ptr; delete ptr;
} }