get the sesison element-tracker integration test to pass

This commit is contained in:
Fischlurch 2010-10-29 05:24:19 +02:00
parent 7c758b04db
commit 08d90be1b6
5 changed files with 20 additions and 9 deletions

View file

@ -68,6 +68,7 @@ namespace lib {
using lumiera::P; using lumiera::P;
using std::tr1::function; using std::tr1::function;
using util::isSameObject;
/** /**
* Registry for tracking object instances. * Registry for tracking object instances.
@ -229,6 +230,13 @@ namespace lib {
getRegistry = RegistryLink(); // empty accessor function getRegistry = RegistryLink(); // empty accessor function
} }
static bool
is_attached_to (Registry const& someRegistry)
{
return bool(getRegistry)
&& isSameObject (someRegistry, getRegistry());
}
protected: protected:
static RegistryLink getRegistry; static RegistryLink getRegistry;
}; };

View file

@ -82,7 +82,7 @@ namespace asset {
* instances and immediately creates a new one. * instances and immediately creates a new one.
* @param nameID (optional) an ID to use; if omitted an ID * @param nameID (optional) an ID to use; if omitted an ID
* will be default created, based on the kind of Asset. * 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 * @return an Struct smart ptr linked to the internally registered smart ptr
* created as a side effect of calling the concrete Struct subclass ctor. * created as a side effect of calling the concrete Struct subclass ctor.
*/ */

View file

@ -120,9 +120,12 @@ namespace session {
inline inline
SessionInterfaceModules::~SessionInterfaceModules() SessionInterfaceModules::~SessionInterfaceModules()
{ {
asset::Sequence::deactivateRegistryLink(); if (asset::Sequence::is_attached_to (sequenceRegistry_))
asset::Timeline::deactivateRegistryLink(); 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.

View file

@ -32,7 +32,7 @@ out: DummyMO\.[0-9]{3}
END END
PLANNED "SessionElementTracker_test" SessionElementTracker_test <<END TEST "SessionElementTracker_test" SessionElementTracker_test <<END
END END

View file

@ -181,13 +181,13 @@ namespace test {
uint num_timelines = sess->timelines.size(); uint num_timelines = sess->timelines.size();
CHECK (0 < num_timelines); CHECK (0 < num_timelines);
PTimeline specialTimeline (asset::Struct::retrieve (Query<Timeline> ("id(testical)"))); PTimeline specialTimeline (asset::Struct::retrieve.newInstance<Timeline> ("testical"));
CHECK (specialTimeline); CHECK (specialTimeline);
CHECK (num_timelines + 1 == sess->timelines.size()); CHECK (num_timelines + 1 == sess->timelines.size());
CHECK (specialTimeline == sess->timelines[num_timelines]); // got appended at the end of the tracking table 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<Timeline> ())); PTimeline anotherTimeline (asset::Struct::retrieve.newInstance<Timeline>());
CHECK (num_timelines + 2 == sess->timelines.size()); CHECK (num_timelines + 2 == sess->timelines.size());
CHECK (specialTimeline == sess->timelines[num_timelines]); CHECK (specialTimeline == sess->timelines[num_timelines]);
CHECK (anotherTimeline == sess->timelines[num_timelines+1]); // new one got appended at the end 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"); REQUIRE (1 < aTimeline_in_session.use_count(), "test object should still be attached to session");
Session::current.reset(); 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
} }
}; };