diff --git a/src/gui/model/element-access.hpp b/src/gui/model/element-access.hpp index fe7d00560..7f9dfd6eb 100644 --- a/src/gui/model/element-access.hpp +++ b/src/gui/model/element-access.hpp @@ -151,7 +151,7 @@ namespace model { struct ElementAccess::TypeConverter : RawResult::Visitor { - Result result; + Result result{"not convertible"}; template using canCast = std::is_convertible; @@ -163,6 +163,8 @@ namespace model { { if (pb) result = *dynamic_cast (pb); + else + result = "access returns empty answer"; } }; @@ -175,10 +177,9 @@ namespace model { * @tparam TAR type of result element expected at the designated location * @return suitably converted direct (language) reference to the desired element * wrapped as _result proxy_ - * @throw error::Invalid when the designated element exists, but is not - * type or conversion compatible to the expected result type - * @note when access was not possible because the element does not exist, - * the result proxy is empty and convertible to `bool(false)` + * @note when access was not possible because either the element does not exist, + * or is not convertible to the desired target type, the result proxy is empty + * and convertible to `bool(false)` */ template inline ElementAccess::Result @@ -201,10 +202,7 @@ namespace model { TypeConverter converter; RawResult targetElm = performAccessTo (destination, limitCreation); targetElm.accept (converter); - if (converter.result.isValid()) - return converter.result; - else - return "In current UI, there is no element at location "+string(destination); + return converter.result; } diff --git a/tests/gui/ctrl/element-access-test.cpp b/tests/gui/ctrl/element-access-test.cpp index acbba4cfb..d283af9be 100644 --- a/tests/gui/ctrl/element-access-test.cpp +++ b/tests/gui/ctrl/element-access-test.cpp @@ -124,9 +124,6 @@ namespace test { fakeDirectory->expectedQuery = location; fakeDirectory->expectedAnswer = &dummyTab; - DummyWidget* duf = &dummyTab; - model::Tangible* luf{duf}; - static_assert (std::is_convertible::value, "lalü"); AccessAPI accessAPI; auto answer = accessAPI().access (location);