diff --git a/src/lib/element-tracker.hpp b/src/lib/element-tracker.hpp index 2a0515d08..2b72c0f1d 100644 --- a/src/lib/element-tracker.hpp +++ b/src/lib/element-tracker.hpp @@ -68,6 +68,7 @@ namespace lib { using lumiera::P; using std::tr1::function; + using util::isSameObject; /** * Registry for tracking object instances. @@ -229,6 +230,13 @@ namespace lib { getRegistry = RegistryLink(); // empty accessor function } + static bool + is_attached_to (Registry const& someRegistry) + { + return bool(getRegistry) + && isSameObject (someRegistry, getRegistry()); + } + protected: static RegistryLink getRegistry; }; diff --git a/src/proc/asset/struct.cpp b/src/proc/asset/struct.cpp index 7ed42b2f6..fbfaec89c 100644 --- a/src/proc/asset/struct.cpp +++ b/src/proc/asset/struct.cpp @@ -82,7 +82,7 @@ namespace asset { * instances and immediately creates a new one. * @param nameID (optional) an ID to use; if omitted an ID * will be default created, based on the kind of Asset. - * @throw error::Invalid in case of ID clash with an existing Asset + * @throw error::Invalid in case of ID clash with an existing Asset * @return an Struct smart ptr linked to the internally registered smart ptr * created as a side effect of calling the concrete Struct subclass ctor. */ diff --git a/src/proc/mobject/session/session-interface-modules.hpp b/src/proc/mobject/session/session-interface-modules.hpp index 46878a272..437bc5663 100644 --- a/src/proc/mobject/session/session-interface-modules.hpp +++ b/src/proc/mobject/session/session-interface-modules.hpp @@ -120,9 +120,12 @@ namespace session { inline SessionInterfaceModules::~SessionInterfaceModules() { - asset::Sequence::deactivateRegistryLink(); - asset::Timeline::deactivateRegistryLink(); - } + if (asset::Sequence::is_attached_to (sequenceRegistry_)) + asset::Sequence::deactivateRegistryLink(); + + if (asset::Timeline::is_attached_to (timelineRegistry_)) // as session dtor is invoked automatically (smart-ptr), + asset::Timeline::deactivateRegistryLink(); // another new session might already have grabbed + } // the Timeline / Sequence registration service. diff --git a/tests/43session.tests b/tests/43session.tests index 40a81d269..85242cd65 100644 --- a/tests/43session.tests +++ b/tests/43session.tests @@ -32,7 +32,7 @@ out: DummyMO\.[0-9]{3} END -PLANNED "SessionElementTracker_test" SessionElementTracker_test <timelines.size(); CHECK (0 < num_timelines); - PTimeline specialTimeline (asset::Struct::retrieve (Query ("id(testical)"))); + PTimeline specialTimeline (asset::Struct::retrieve.newInstance ("testical")); CHECK (specialTimeline); CHECK (num_timelines + 1 == sess->timelines.size()); CHECK (specialTimeline == sess->timelines[num_timelines]); // got appended at the end of the tracking table - CHECK (specialTimeline.use_count() == 4); // we, the AssetManager and the session /////TODO plus one for fake-configrules + CHECK (specialTimeline.use_count() == 3); // we, the AssetManager and the session - PTimeline anotherTimeline (asset::Struct::retrieve (Query ())); + PTimeline anotherTimeline (asset::Struct::retrieve.newInstance()); CHECK (num_timelines + 2 == sess->timelines.size()); CHECK (specialTimeline == sess->timelines[num_timelines]); CHECK (anotherTimeline == sess->timelines[num_timelines+1]); // new one got appended at the end @@ -212,7 +212,7 @@ namespace test { { 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 + aTimeline_in_session->detach(); // should be a no-op and not cause any invalid access } };