diff --git a/src/App/DocumentObject.cpp b/src/App/DocumentObject.cpp index 07d1cc326..b9a0a969e 100644 --- a/src/App/DocumentObject.cpp +++ b/src/App/DocumentObject.cpp @@ -182,6 +182,12 @@ void DocumentObject::setDocument(App::Document* doc) void DocumentObject::onBeforeChange(const Property* prop) { + + // Store current name in oldLabel, to be able to easily retrieve old name of document object later + // when renaming expressions. + if (prop == &Label) + oldLabel = static_cast(&Label)->getStrValue(); + if (_pDoc) _pDoc->onBeforeChangeProperty(this,prop); } @@ -191,6 +197,10 @@ void DocumentObject::onChanged(const Property* prop) { if (_pDoc) _pDoc->onChangedProperty(this,prop); + + if (prop == &Label && _pDoc) + _pDoc->signalRenamedObject(*this); + if (prop->getType() & Prop_Output) return; // set object touched diff --git a/src/App/DocumentObject.h b/src/App/DocumentObject.h index 22b096cc2..aa6c2ccdd 100644 --- a/src/App/DocumentObject.h +++ b/src/App/DocumentObject.h @@ -160,6 +160,8 @@ public: virtual void Save (Base::Writer &writer) const; + const std::string & getOldLabel() const { return oldLabel; } + protected: /** get called by the document to recompute this feature * Normaly this method get called in the processing of @@ -205,6 +207,9 @@ protected: // attributes /// pointer to the document this object belongs to App::Document* _pDoc; + /// Old label; used for renaming expressions + std::string oldLabel; + // pointer to the document name string (for performance) const std::string *pcNameInDocument; };