saveguard against deregistering from an alredy destroyed session
This commit is contained in:
parent
da45bb06f7
commit
d1dd3e2677
3 changed files with 29 additions and 0 deletions
|
|
@ -181,6 +181,7 @@ namespace lib {
|
|||
void
|
||||
detach()
|
||||
{
|
||||
if (!getRegistry) return;
|
||||
TAR& element = static_cast<TAR&> (*this);
|
||||
|
||||
getRegistry().remove(element);
|
||||
|
|
@ -222,6 +223,12 @@ namespace lib {
|
|||
establishRegistryLink (accessInstance);
|
||||
}
|
||||
|
||||
static void
|
||||
deactivateRegistryLink()
|
||||
{
|
||||
getRegistry = RegistryLink(); // empty accessor function
|
||||
}
|
||||
|
||||
protected:
|
||||
static RegistryLink getRegistry;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -101,6 +101,7 @@ namespace session {
|
|||
SequenceTracker sequenceRegistry_;
|
||||
|
||||
SessionInterfaceModules();
|
||||
~SessionInterfaceModules();
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -116,6 +117,14 @@ namespace session {
|
|||
asset::Sequence::setRegistryInstance (sequenceRegistry_);
|
||||
}
|
||||
|
||||
inline
|
||||
SessionInterfaceModules::~SessionInterfaceModules()
|
||||
{
|
||||
asset::Sequence::deactivateRegistryLink();
|
||||
asset::Timeline::deactivateRegistryLink();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}} // namespace mobject::session
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -200,6 +200,19 @@ namespace test {
|
|||
CHECK (num_timelines + 1 == sess->timelines.size());
|
||||
CHECK (anotherTimeline == sess->timelines[num_timelines]); // moved to the previous slot
|
||||
CHECK (specialTimeline.use_count() == 1); // we're holding the last reference
|
||||
|
||||
verify_cleanup (anotherTimeline);
|
||||
}
|
||||
|
||||
|
||||
/** @test ensure the asset cleanup doesn't interfere with session shutdown
|
||||
*/
|
||||
void
|
||||
verify_cleanup (PTimeline aTimeline_in_session)
|
||||
{
|
||||
REQUIRE (1 < aTimeline_in_session.use_count(), "test object should still be attached to session");
|
||||
Session::current.reset();
|
||||
aTimeline_in_session->detach(); // should be a no-op and not cause any invalid access
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue