App: support of method unsetupObject in Python feature classes

This commit is contained in:
wmayer
2023-02-08 15:02:11 +01:00
committed by abdullahtahiriyo
parent 3623dbd862
commit 38e02e6f36
2 changed files with 28 additions and 0 deletions

View File

@@ -232,6 +232,28 @@ void FeaturePythonImp::onDocumentRestored()
}
}
void FeaturePythonImp::unsetupObject()
{
_FC_PY_CALL_CHECK(unsetupObject, return);
// Run the execute method of the proxy object.
Base::PyGILStateLocker lock;
try {
if (has__object__) {
Base::pyCall(py_unsetupObject.ptr());
}
else {
Py::Tuple args(1);
args.setItem(0, Py::Object(object->getPyObject(), true));
Base::pyCall(py_unsetupObject.ptr(), args.ptr());
}
}
catch (Py::Exception&) {
Base::PyException e; // extract the Python error text
e.ReportException();
}
}
bool FeaturePythonImp::getSubObject(DocumentObject *&ret, const char *subname,
PyObject **pyObj, Base::Matrix4D *_mat, bool transform, int depth) const
{

View File

@@ -53,6 +53,7 @@ public:
bool onBeforeChangeLabel(std::string &newLabel);
void onChanged(const Property* prop);
void onDocumentRestored();
void unsetupObject();
std::string getViewProviderName();
PyObject *getPyObject();
@@ -94,6 +95,7 @@ private:
FC_PY_ELEMENT(onBeforeChangeLabel)\
FC_PY_ELEMENT(onChanged)\
FC_PY_ELEMENT(onDocumentRestored)\
FC_PY_ELEMENT(unsetupObject)\
FC_PY_ELEMENT(getViewProviderName)\
FC_PY_ELEMENT(getSubObject)\
FC_PY_ELEMENT(getSubObjects)\
@@ -341,6 +343,10 @@ protected:
imp->onDocumentRestored();
FeatureT::onDocumentRestored();
}
void unsetupObject() override {
imp->unsetupObject();
FeatureT::unsetupObject();
}
public:
FeaturePythonT(const FeaturePythonT&) = delete;