+ expose onDocumentRestored to Python feature classes
This commit is contained in:
@@ -154,6 +154,35 @@ void FeaturePythonImp::onChanged(const Property* prop)
|
||||
}
|
||||
}
|
||||
|
||||
void FeaturePythonImp::onDocumentRestored()
|
||||
{
|
||||
// Run the execute method of the proxy object.
|
||||
Base::PyGILStateLocker lock;
|
||||
try {
|
||||
Property* proxy = object->getPropertyByName("Proxy");
|
||||
if (proxy && proxy->getTypeId() == PropertyPythonObject::getClassTypeId()) {
|
||||
Py::Object feature = static_cast<PropertyPythonObject*>(proxy)->getValue();
|
||||
if (feature.hasAttr(std::string("onDocumentRestored"))) {
|
||||
if (feature.hasAttr("__object__")) {
|
||||
Py::Callable method(feature.getAttr(std::string("onDocumentRestored")));
|
||||
Py::Tuple args;
|
||||
method.apply(args);
|
||||
}
|
||||
else {
|
||||
Py::Callable method(feature.getAttr(std::string("onDocumentRestored")));
|
||||
Py::Tuple args(1);
|
||||
args.setItem(0, Py::Object(object->getPyObject(), true));
|
||||
method.apply(args);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Py::Exception&) {
|
||||
Base::PyException e; // extract the Python error text
|
||||
e.ReportException();
|
||||
}
|
||||
}
|
||||
|
||||
PyObject *FeaturePythonImp::getPyObject(void)
|
||||
{
|
||||
// ref counter is set to 1
|
||||
|
||||
Reference in New Issue
Block a user