MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / onChanged

Method onChanged

src/App/DocumentObject.cpp:1016–1096  ·  view source on GitHub ↗

get called by the container when a Property was changed

Source from the content-addressed store, hash-verified

1014
1015/// get called by the container when a Property was changed
1016void DocumentObject::onChanged(const Property* prop)
1017{
1018 if (prop == &Label && _pDoc && _pDoc->containsObject(this) && oldLabel != Label.getStrValue()) {
1019 _pDoc->unregisterLabel(oldLabel);
1020 _pDoc->registerLabel(Label.getStrValue());
1021 }
1022
1023 if (isFreezed() && prop != &Visibility) {
1024 return;
1025 }
1026
1027 if (GetApplication().isClosingAll()) {
1028 return;
1029 }
1030
1031 if (!GetApplication().isRestoring() && !prop->testStatus(Property::PartialTrigger)
1032 && getDocument() && getDocument()->testStatus(Document::PartialDoc)) {
1033 static App::Document* warnedDoc;
1034 if (warnedDoc != getDocument()) {
1035 warnedDoc = getDocument();
1036 FC_WARN("Changes to partial loaded document will not be saved: " << getFullName() << '.'
1037 << prop->getName());
1038 }
1039 }
1040
1041 // Delay signaling view provider until the document object has handled the
1042 // change
1043 // if (_pDoc)
1044 // _pDoc->onChangedProperty(this,prop);
1045
1046 if (prop == &Label && _pDoc && oldLabel != Label.getStrValue()) {
1047 _pDoc->signalRelabelObject(*this);
1048 }
1049
1050 bool fineGrained = GetApplication().isFineGrainedRecomputeEnabled();
1051
1052 auto outputHasDeps = [this](const Property* prop) {
1053 return std::ranges::any_of(getInListProp(), [this, prop](const DepEdge& edge) {
1054 return edge.toObj == this && edge.toProp == prop->getName();
1055 });
1056 };
1057
1058 if (fineGrained) {
1059 // set object touched if it is not an output property unless it has dependencies
1060 if (!testStatus(ObjectStatus::NoTouch)
1061 && ((isOutputProperty(prop) && outputHasDeps(prop)) ||
1062 !isOutputProperty(prop))) {
1063 FC_TRACE("touch '" << getFullName() << "' on change of '" << prop->getName()
1064 << "'");
1065 setTouched(prop->getName());
1066 // must execute on document recompute
1067 if (!(prop->getType() & Prop_NoRecompute)) {
1068 StatusBits.set(ObjectStatus::Enforce);
1069 }
1070 }
1071 }
1072 else {
1073 // set object touched if it is not an output property

Callers

nothing calls this directly

Calls 15

isFreezedFunction · 0.85
getFullNameFunction · 0.85
onChangedFunction · 0.85
containsObjectMethod · 0.80
unregisterLabelMethod · 0.80
registerLabelMethod · 0.80
isClosingAllMethod · 0.80
isRestoringMethod · 0.80
onChangedPropertyMethod · 0.80
testStatusFunction · 0.70
getDocumentFunction · 0.50

Tested by

no test coverage detected