Core: Update expressions on property rename

This includes both expressions in generic containers and in
spreadsheets.
This commit is contained in:
Pieter Hijma
2025-05-18 15:16:31 +02:00
committed by Yorik van Havre
parent 3797e35dbc
commit 8c01d577e7
4 changed files with 35 additions and 0 deletions

View File

@@ -53,6 +53,8 @@ PropertyExpressionContainer::PropertyExpressionContainer()
inited = true;
GetApplication().signalRelabelDocument.connect(
PropertyExpressionContainer::slotRelabelDocument);
GetApplication().signalRenameDynamicProperty.connect(
PropertyExpressionContainer::slotRenameDynamicProperty);
}
_ExprContainers.insert(this);
}
@@ -75,6 +77,13 @@ void PropertyExpressionContainer::slotRelabelDocument(const App::Document& doc)
}
}
void PropertyExpressionContainer::slotRenameDynamicProperty(const App::Property& prop, const char* oldName)
{
for (auto container : _ExprContainers) {
container->onRenameDynamicProperty(prop, oldName);
}
}
///////////////////////////////////////////////////////////////////////////////////////
struct PropertyExpressionEngine::Private
@@ -1208,6 +1217,17 @@ void PropertyExpressionEngine::onRelabeledDocument(const App::Document& doc)
}
}
void PropertyExpressionEngine::onRenameDynamicProperty(const App::Property& prop, const char* oldName)
{
ObjectIdentifier oldNameId = ObjectIdentifier(prop.getContainer(), std::string(oldName));
ObjectIdentifier newNameId = ObjectIdentifier(prop);
const std::map<ObjectIdentifier, ObjectIdentifier> paths = {
{oldNameId, newNameId},
};
renameObjectIdentifiers(paths);
}
void PropertyExpressionEngine::getLinksTo(std::vector<App::ObjectIdentifier>& identifiers,
App::DocumentObject* obj,
const char* subname,