Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Development
openfoam
Commits
2ce1ca48
Commit
2ce1ca48
authored
Jun 03, 2019
by
mattijs
Committed by
Andrew Heather
Jun 03, 2019
Browse files
BUG: objectRegistry: two-pass deletion. See #1276.
parent
5dd6a04f
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/OpenFOAM/db/objectRegistry/objectRegistry.C
View file @
2ce1ca48
...
...
@@ -334,6 +334,14 @@ bool Foam::objectRegistry::checkOut(const word& key) const
void
Foam
::
objectRegistry
::
clear
()
{
// Free anything owned by the registry
// This needs to be done in two stages:
// - collect objects-to-be-removed
// - actually delete objects
// since the destructor of the regIOobject will actually delete its
// entry from the objectRegistry which messes up the iterator.
DynamicList
<
regIOobject
*>
owned
;
for
(
iterator
iter
=
begin
();
iter
!=
end
();
++
iter
)
{
regIOobject
*
ptr
=
iter
.
val
();
...
...
@@ -341,17 +349,25 @@ void Foam::objectRegistry::clear()
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
;
owned
.
append
(
ptr
);
}
}
for
(
regIOobject
*
objectPtr
:
owned
)
{
// Make sure that the destructor of the regIOobject does a checkout
objectPtr
->
release
();
delete
objectPtr
;
}
HashTable
<
regIOobject
*>::
clear
();
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment