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

Method onBeforeChange

src/App/FeaturePython.cpp:131–160  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

129
130
131void FeaturePythonImp::onBeforeChange(const Property* prop)
132{
133 if (py_onBeforeChange.isNone()) {
134 return;
135 }
136
137 // Run the execute method of the proxy object.
138 Base::PyGILStateLocker lock;
139 try {
140 const char* prop_name = object->getPropertyName(prop);
141 if (!prop_name) {
142 return;
143 }
144 if (has__object__) {
145 Py::Tuple args(1);
146 args.setItem(0, Py::String(prop_name));
147 Base::pyCall(py_onBeforeChange.ptr(), args.ptr());
148 }
149 else {
150 Py::Tuple args(2);
151 args.setItem(0, Py::Object(object->getPyObject(), true));
152 args.setItem(1, Py::String(prop_name));
153 Base::pyCall(py_onBeforeChange.ptr(), args.ptr());
154 }
155 }
156 catch (Py::Exception&) {
157 Base::PyException e; // extract the Python error text
158 e.reportException();
159 }
160}
161
162bool FeaturePythonImp::onBeforeChangeLabel(std::string& newLabel)
163{

Callers

nothing calls this directly

Calls 8

pyCallFunction · 0.85
isNoneMethod · 0.80
StringClass · 0.70
ObjectClass · 0.70
getPropertyNameMethod · 0.45
ptrMethod · 0.45
getPyObjectMethod · 0.45
reportExceptionMethod · 0.45

Tested by

no test coverage detected