diff --git a/Control/AthViews/src/SimpleView.cxx b/Control/AthViews/src/SimpleView.cxx index 40bf7b6badba085faa9384d3e362740a979dc4cd..62e7a649328c2ec041076347fb09b85f7c6e347c 100644 --- a/Control/AthViews/src/SimpleView.cxx +++ b/Control/AthViews/src/SimpleView.cxx @@ -3,6 +3,7 @@ */ #include <iostream> +#include <stdexcept> #include "AthViews/SimpleView.h" using namespace std; @@ -59,13 +60,17 @@ SG::DataProxy * SimpleView::proxy_exact( SG::sgkey_t sgkey ) const SG::DataProxy * SimpleView::proxy( const CLID& id, const std::string& key ) const { const std::string viewKey = m_name + "_" + key; - auto dp = m_store->proxy( id, viewKey ); - if ( dp != nullptr ) return dp; + auto local = m_store->proxy( id, viewKey ); + for ( auto parent: m_parents ) { - dp = parent->proxy( id, key ); - if ( dp ) return dp; + auto dp = parent->proxy( id, key ); + if ( dp and not local ) { + return dp; + } else if ( dp and local ) { + throw std::runtime_error("Duplicate object CLID:"+ std::to_string(id) + " key: " + key + " found in views: " + name()+ " and parent " + parent->name() ); + } // else search further } - return dp; // can be the nullptr still + return local; // can be the nullptr still } diff --git a/Control/AthViews/test/ViewLinking_test.cxx b/Control/AthViews/test/ViewLinking_test.cxx index a352b75a359cb0c6cbb38f12238d96b474063efd..007821a6752c648c1ca7b3075c5b122d1821deea 100644 --- a/Control/AthViews/test/ViewLinking_test.cxx +++ b/Control/AthViews/test/ViewLinking_test.cxx @@ -12,11 +12,13 @@ #include "TestTools/initGaudi.h" #include "TestTools/expect.h" +#include "TestTools/expect_exception.h" #include "AthViews/View.h" struct TestClass { int value = 0; }; + CLASS_DEF( TestClass , 16530831 , 1 ) using namespace SG; void testDataInView( StoreGateSvc* /*sg*/ , MsgStream& log ) { @@ -100,8 +102,7 @@ void testDataInView( StoreGateSvc* /*sg*/ , MsgStream& log ) { { SG::ReadHandle<TestClass> rh( "test1" ); rh.setProxyDict( childView ); - VALUE( rh.isValid() ) EXPECTED( true ); - VALUE( rh->value ) EXPECTED( 3 ); // if we have reached parentView the value would be 1 + EXPECT_EXCEPTION( std::runtime_error, rh.isValid() ); } log << MSG::INFO << "Hiding works as expected " << endmsg;