Does not rely on the pointervalue returned by getNameInDocument() to use as a DAG key.

In order to make getNameInDocument() always return a valid string,
we implement a getDagKey() method that shall be used instead of getNameInDocument()
when we want to use the pointer value as a "key" to identify the DocumentObject.
This commit is contained in:
André Caldas
2023-10-21 22:37:58 -03:00
committed by Chris Hennes
parent c6911695e7
commit 0cbc9cd66e
4 changed files with 14 additions and 3 deletions

View File

@@ -292,6 +292,15 @@ std::string DocumentObject::getFullLabel() const {
return name;
}
const char* DocumentObject::getDagKey() const
{
if(!pcNameInDocument)
{
return nullptr;
}
return pcNameInDocument->c_str();
}
const char *DocumentObject::getNameInDocument() const
{
// Note: It can happen that we query the internal name of an object even if it is not
@@ -808,7 +817,7 @@ DocumentObject *DocumentObject::getSubObject(const char *subname,
if(outList.size()!=_outListMap.size()) {
_outListMap.clear();
for(auto obj : outList)
_outListMap[obj->getNameInDocument()] = obj;
_outListMap[obj->getDagKey()] = obj;
}
auto it = _outListMap.find(name.c_str());
if(it != _outListMap.end())