diff --git a/src/common/query/mockconfigrules.cpp b/src/common/query/mockconfigrules.cpp index ddc7bd57a..c8b9f774b 100644 --- a/src/common/query/mockconfigrules.cpp +++ b/src/common/query/mockconfigrules.cpp @@ -100,7 +100,7 @@ namespace lumiera item (answer_, "stream(default)") = item (answer_,"stream(video)"); // set up a default stream answer_->insert (entry_Struct ("pipe(master), stream(video)")); - item (answer_, "default(P)") = item(answer_,"pipe(master), stream(video)"); + item (answer_, "") = item(answer_,"pipe(master), stream(video)");// use as default } @@ -122,7 +122,7 @@ namespace lumiera } /** special case: create a new pipe for a specific stream ID */ bool - MockTable::fabricate_new_Pipe_for_stream (Query& q, string const& streamID) + MockTable::fabricate_just_new_Pipe (Query& q ) { typedef WrapReturn::Wrapper Ptr; @@ -147,6 +147,7 @@ namespace lumiera bool MockTable::set_new_mock_solution (Query& q, typename WrapReturn::Wrapper& obj) { + answer_->erase (q.asKey()); answer_->insert (entry (q, obj)); return true; } diff --git a/src/common/query/mockconfigrules.hpp b/src/common/query/mockconfigrules.hpp index dba328754..f5bea3264 100644 --- a/src/common/query/mockconfigrules.hpp +++ b/src/common/query/mockconfigrules.hpp @@ -111,7 +111,7 @@ namespace lumiera template bool detect_case (typename WrapReturn::Wrapper&, Query& q); bool fabricate_matching_new_Pipe (Query& q, string const& pipeID, string const& streamID); - bool fabricate_new_Pipe_for_stream (Query& q, string const& streamID); + bool fabricate_just_new_Pipe (Query& q); bool fabricate_ProcPatt_on_demand (Query& q, string const& streamID); template @@ -195,8 +195,8 @@ namespace lumiera if (!isnil(pipeID) && !isnil(streamID)) return fabricate_matching_new_Pipe (q, pipeID, streamID); - if (!candidate && !isnil(streamID)) - return fabricate_new_Pipe_for_stream (q, streamID); + if (!candidate && (!isnil(streamID) || !isnil(pipeID))) + return fabricate_just_new_Pipe (q); q.clear(); return false; diff --git a/tests/53session.tests b/tests/53session.tests index 64946fcf2..887cbdf4c 100644 --- a/tests/53session.tests +++ b/tests/53session.tests @@ -6,7 +6,8 @@ PLANNED "AddClip_test" AddClip_test <
  • retrieving a "default" object repeatedly
  • *
  • retrieving a more constrained "default" object
  • *
  • failure registers a new "default"
  • @@ -101,7 +105,7 @@ namespace asset ASSERT (pipe2 == pipe1); pipe2 = asset::Struct::create (Query ()); ASSERT (pipe2 == pipe1); - pipe2 = asset::Struct::create (Query ("default(X)")); + pipe2 = asset::Struct::create (Query ("default(P)")); ASSERT (pipe2 == pipe1); } @@ -144,12 +148,30 @@ namespace asset } + /** verify the defaults manager holds only weak refs, + * so if an object goes out of scope, any defaults entries + * are purged silently + */ void verifyRemoval (string pID) { Query query_for_pID ("pipe("+pID+")"); size_t hash; { PPipe pipe1 = Session::current->defaults (query_for_pID); +// +// this is fine but doesn't work as long as there is another entry in the mock table... +// ...for now we use hack to overwrite the reference in the mock table +// + ASSERT (3 == pipe1.use_count()); // that's the problem; it should be 2 + + QueryHandler& typeHandler = ConfigRules::instance(); + PPipe pipe2 = asset::Struct::create (pID, "quatsch"); + + typeHandler.resolve (pipe2, query_for_pID); // in the mock impl this has the side effect + ASSERT (pipe2); // of replacing the mock entry + //////////////////////////////////////////// so from now on the test works as intended.... + + ASSERT (2 == pipe1.use_count()); hash = pipe1->getID(); } // now AssetManager should hold the only ref