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

Method onBeforeChangeLabel

src/App/FeaturePython.cpp:162–188  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

160}
161
162bool FeaturePythonImp::onBeforeChangeLabel(std::string& newLabel)
163{
164 if (py_onBeforeChangeLabel.isNone()) {
165 return false;
166 }
167
168 // Run the execute method of the proxy object.
169 Base::PyGILStateLocker lock;
170 try {
171 Py::Tuple args(2);
172 args.setItem(0, Py::Object(object->getPyObject(), true));
173 args.setItem(1, Py::String(newLabel));
174 Py::Object ret(Base::pyCall(py_onBeforeChangeLabel.ptr(), args.ptr()));
175 if (!ret.isNone()) {
176 if (!ret.isString()) {
177 throw Py::TypeError("onBeforeChangeLabel expects to return a string");
178 }
179 newLabel = ret.as_string();
180 return true;
181 }
182 }
183 catch (Py::Exception&) {
184 Base::PyException e; // extract the Python error text
185 e.reportException();
186 }
187 return false;
188}
189
190void FeaturePythonImp::onChanged(const Property* prop)
191{

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected