mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Check for valid pointer
p4#: 21235
This commit is contained in:
parent
dbc9869f61
commit
e70615d02a
@ -578,27 +578,29 @@ RimIdenticalGridCaseGroup* RimUiTreeModelPdm::addCaseGroup(const QModelIndex& it
|
|||||||
CVF_ASSERT(proj);
|
CVF_ASSERT(proj);
|
||||||
|
|
||||||
caf::PdmUiTreeItem* currentItem = getTreeItemFromIndex(itemIndex);
|
caf::PdmUiTreeItem* currentItem = getTreeItemFromIndex(itemIndex);
|
||||||
|
if (currentItem)
|
||||||
if (dynamic_cast<RimIdenticalGridCaseGroup*>(currentItem->dataObject().p()) ||
|
|
||||||
dynamic_cast<RimCase*>(currentItem->dataObject().p()))
|
|
||||||
{
|
{
|
||||||
QModelIndex rootIndex = itemIndex.parent();
|
if (dynamic_cast<RimIdenticalGridCaseGroup*>(currentItem->dataObject().p()) ||
|
||||||
caf::PdmUiTreeItem* rootTreeItem = currentItem->parent();
|
dynamic_cast<RimCase*>(currentItem->dataObject().p()))
|
||||||
|
{
|
||||||
|
QModelIndex rootIndex = itemIndex.parent();
|
||||||
|
caf::PdmUiTreeItem* rootTreeItem = currentItem->parent();
|
||||||
|
|
||||||
// New case group is inserted before the last item, the script item
|
// New case group is inserted before the last item, the script item
|
||||||
int position = rootTreeItem->childCount() - 1;
|
int position = rootTreeItem->childCount() - 1;
|
||||||
|
|
||||||
beginInsertRows(rootIndex, position, position);
|
beginInsertRows(rootIndex, position, position);
|
||||||
|
|
||||||
RimIdenticalGridCaseGroup* createdObject = new RimIdenticalGridCaseGroup;
|
RimIdenticalGridCaseGroup* createdObject = new RimIdenticalGridCaseGroup;
|
||||||
proj->caseGroups().push_back(createdObject);
|
proj->caseGroups().push_back(createdObject);
|
||||||
|
|
||||||
caf::PdmUiTreeItem* childItem = caf::UiTreeItemBuilderPdm::buildViewItems(rootTreeItem, position, createdObject);
|
caf::PdmUiTreeItem* childItem = caf::UiTreeItemBuilderPdm::buildViewItems(rootTreeItem, position, createdObject);
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
|
|
||||||
insertedModelIndex = index(position, 0, rootIndex);
|
insertedModelIndex = index(position, 0, rootIndex);
|
||||||
|
|
||||||
return createdObject;
|
return createdObject;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user