Use concept of parentObjectsOfType to avoid dynamic cast in application code.

p4#: 20887
This commit is contained in:
Magne Sjaastad
2013-03-13 13:51:26 +01:00
parent 3c446c4018
commit 973eb5c8f7
6 changed files with 38 additions and 59 deletions

View File

@@ -647,18 +647,18 @@ void RimUiTreeView::slotWriteInputProperty()
// Find input reservoir for this property
RimInputReservoir* inputReservoir = NULL;
{
std::vector<caf::PdmObject*> parentObjects;
inputProperty->parentObjects(parentObjects);
std::vector<RimInputPropertyCollection*> parentObjects;
inputProperty->parentObjectsOfType(parentObjects);
CVF_ASSERT(parentObjects.size() == 1);
RimInputPropertyCollection* inputPropertyCollection = dynamic_cast<RimInputPropertyCollection*>(parentObjects[0]);
RimInputPropertyCollection* inputPropertyCollection = parentObjects[0];
if (!inputPropertyCollection) return;
std::vector<caf::PdmObject*> parentObjects2;
inputPropertyCollection->parentObjects(parentObjects2);
std::vector<RimInputReservoir*> parentObjects2;
inputPropertyCollection->parentObjectsOfType(parentObjects2);
CVF_ASSERT(parentObjects2.size() == 1);
inputReservoir = dynamic_cast<RimInputReservoir*>(parentObjects2[0]);
inputReservoir = parentObjects2[0];
}
if (!inputReservoir) return;