Skip to content
Snippets Groups Projects
Commit 2ffcb731 authored by Utkarsh Ayachit's avatar Utkarsh Ayachit
Browse files

Fix order of representations in a view.

vtkView keeps representations provided to `AddRepresentation` call in an
internal datastructure. If a representation was comprised of other
internal representations and it called vtkView::AddRepresentation() then
the order in which the representations would get stored in the internal
datastructure did not match the order in which `AddRepresentation` was
called. Not a big deal, except in cases where the internal
representation expects the outer representation to have been updated (as
was was the case with #16832).

Fixed vtkView::AddRepresentation() to maintain the order in internal
datastructure to match the order in which AddRepresentation is called.

Fixes #16832.
parent d8fd4496
Branches fix_cm_16526
No related tags found
No related merge requests found
......@@ -186,6 +186,14 @@ void vtkView::AddRepresentation(vtkDataRepresentation* rep)
{
if (rep != NULL && !this->IsRepresentationPresent(rep))
{
// We add the representation to the internal data-structure before calling
// AddToView(). This ensures that if the `rep` itself calls
// AddRepresentation() for an internal representation, the internal
// representation gets added after the `rep` which makes more sense as it
// preserves the order for representations in which AddRepresentation() was
// called.
size_t index = this->Implementation->Representations.size();
this->Implementation->Representations.push_back(rep);
if (rep->AddToView(this))
{
rep->AddObserver(vtkCommand::SelectionChangedEvent, this->GetObserver());
......@@ -196,7 +204,11 @@ void vtkView::AddRepresentation(vtkDataRepresentation* rep)
rep->AddObserver(vtkCommand::UpdateEvent, this->GetObserver());
this->AddRepresentationInternal(rep);
this->Implementation->Representations.push_back(rep);
}
else
{
this->Implementation->Representations.erase(
this->Implementation->Representations.begin() + index);
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment