DAG: Add method hasRecord() and use it in Model::slotChangeObject

to avoid a possible failing assert().

Fixes #17572
This commit is contained in:
wmayer
2024-10-30 19:28:41 +01:00
committed by Yorik van Havre
parent 7e72d641df
commit 4143c551bb
3 changed files with 21 additions and 6 deletions

View File

@@ -308,15 +308,21 @@ void Model::slotChangeObject(const ViewProviderDocumentObject &VPDObjectIn, cons
//renaming of objects.
if (std::string("Label") == name)
{
const GraphLinkRecord &record = findRecord(&VPDObjectIn, *graphLink);
auto text = (*theGraph)[record.vertex].text.get();
text->setPlainText(QString::fromUtf8(record.DObject->Label.getValue()));
if (hasRecord(&VPDObjectIn, *graphLink))
{
const GraphLinkRecord &record = findRecord(&VPDObjectIn, *graphLink);
auto text = (*theGraph)[record.vertex].text.get();
text->setPlainText(QString::fromUtf8(record.DObject->Label.getValue()));
}
}
else if (propertyIn.isDerivedFrom(App::PropertyLinkBase::getClassTypeId()))
{
const GraphLinkRecord &record = findRecord(&VPDObjectIn, *graphLink);
boost::clear_vertex(record.vertex, *theGraph);
graphDirty = true;
if (hasRecord(&VPDObjectIn, *graphLink))
{
const GraphLinkRecord &record = findRecord(&VPDObjectIn, *graphLink);
boost::clear_vertex(record.vertex, *theGraph);
graphDirty = true;
}
}
}