From 3b82ffff0229ff923b59601ddf643d2f7febb851 Mon Sep 17 00:00:00 2001 From: Eivind Kvedalen Date: Sun, 15 Oct 2017 12:46:53 +0200 Subject: [PATCH] When we are restoring, don't set the Label on object creation as it will be restored later. This is to avoid potential duplicate label conflicts. This fixes issue #3280. --- src/App/Document.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/App/Document.cpp b/src/App/Document.cpp index 8e4eac1cf2..cae5478ed5 100644 --- a/src/App/Document.cpp +++ b/src/App/Document.cpp @@ -1315,6 +1315,8 @@ void Document::Save (Base::Writer &writer) const void Document::Restore(Base::XMLReader &reader) { int i,Cnt; + Base::ObjectStatusLocker restoreBit(Status::Restoring, this); + reader.readElement("Document"); long scheme = reader.getAttributeAsInteger("SchemaVersion"); reader.DocumentSchema = scheme; @@ -2417,7 +2419,10 @@ DocumentObject * Document::addObject(const char* sType, const char* pObjectName, // insert in the adjacence list and referenc through the ConectionMap //_DepConMap[pcObject] = add_vertex(_DepList); - pcObject->Label.setValue( ObjectName ); + // If we are restoring, don't set the Label object now; it will be restored later. This is to avoid potential duplicate + // label conflicts later. + if (!d->StatusBits.test(Restoring)) + pcObject->Label.setValue( ObjectName ); // Call the object-specific initialization if (!d->undoing && !d->rollback && isNew) {