diff --git a/src/App/DocumentObject.cpp b/src/App/DocumentObject.cpp index 2950697434..708b6ea3b9 100644 --- a/src/App/DocumentObject.cpp +++ b/src/App/DocumentObject.cpp @@ -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()) diff --git a/src/App/DocumentObject.h b/src/App/DocumentObject.h index a274a60c0c..b9b745ad54 100644 --- a/src/App/DocumentObject.h +++ b/src/App/DocumentObject.h @@ -132,6 +132,8 @@ public: DocumentObject(); ~DocumentObject() override; + /// returns a value that uniquely identifies this DocumentObject. + const char* getDagKey() const; /// returns the name which is set in the document for this object (not the name property!) const char *getNameInDocument() const; /// Return the object ID that is unique within its owner document diff --git a/src/App/Link.cpp b/src/App/Link.cpp index a63cd4bf8f..4328a2ebe1 100644 --- a/src/App/Link.cpp +++ b/src/App/Link.cpp @@ -468,7 +468,7 @@ void LinkBaseExtension::setOnChangeCopyObject( } } - const char *key = flags.testFlag(OnChangeCopyOptions::ApplyAll) ? "*" : parent->getNameInDocument(); + const char *key = flags.testFlag(OnChangeCopyOptions::ApplyAll) ? "*" : parent->getDagKey(); if (external) prop->setValue(key, exclude ? "" : "+"); else diff --git a/src/Gui/ViewProviderLink.cpp b/src/Gui/ViewProviderLink.cpp index c121fe91b2..61a68d6465 100644 --- a/src/Gui/ViewProviderLink.cpp +++ b/src/Gui/ViewProviderLink.cpp @@ -225,7 +225,7 @@ public: } const char *getLinkedName() const { - return pcLinked->getObject()->getNameInDocument(); + return pcLinked->getObject()->getDagKey(); } const char *getLinkedLabel() const {