Add context_destroyed to verifiables

Avoids destruction order fiasco as context can be destroyed before the
functions/verifiables
This commit is contained in:
Alexander Grund 2018-11-16 16:02:22 +01:00
parent 72518b6297
commit 3b81a8e6c0
4 changed files with 16 additions and 0 deletions

View file

@ -255,6 +255,11 @@ namespace detail
context_ = &c;
}
virtual void context_destroyed()
{
context_ = NULL;
}
friend std::ostream& operator<<(
std::ostream& s, const function_impl& impl )
{

View file

@ -22,6 +22,13 @@ namespace detail
class group
{
public:
~group()
{
for( verifiables_cit it = verifiables_.begin();
it != verifiables_.end(); ++it )
(*it)->context_destroyed();
}
void add( verifiable& v )
{
verifiables_.push_back( &v );

View file

@ -56,6 +56,8 @@ namespace detail
if( children_.empty() )
detail::root::inst().remove( *this );
}
virtual void context_destroyed()
{}
virtual void serialize( std::ostream& s, const verifiable& v ) const
{

View file

@ -25,6 +25,8 @@ namespace detail
virtual bool verify() const = 0;
virtual void reset() = 0;
virtual void context_destroyed() = 0;
};
}
} // mock