Skip to content

Commit

Permalink
Allow nested data models (#484)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dakror authored Jul 10, 2023
1 parent 0923969 commit 00c9541
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions Source/Core/Element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1963,6 +1963,10 @@ void Element::SetDataModel(DataModel* new_data_model)
if (data_model == new_data_model)
return;

// stop descent if a nested data model is encountered
if (data_model && new_data_model && data_model != new_data_model)
return;

if (data_model)
data_model->OnElementRemove(this);

Expand Down Expand Up @@ -2015,15 +2019,10 @@ void Element::SetParent(Element* _parent)
{
SetDataModel(parent->data_model);
}
else if (parent->data_model)
{
String name = it->second.Get<String>();
Log::Message(Log::LT_ERROR, "Nested data models are not allowed. Data model '%s' given in element %s.", name.c_str(),
GetAddress().c_str());
}
else if (Context* context = GetContext())
{
String name = it->second.Get<String>();

if (DataModel* model = context->GetDataModelPtr(name))
{
model->AttachModelRootElement(this);
Expand Down

0 comments on commit 00c9541

Please sign in to comment.