Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App: Do not use stuff from Part module here (PyObject *PropertyContainerPy::getCustomAttributes) #6857

Open
luzpaz opened this issue May 9, 2022 · 5 comments
Labels
Coding: C++ Coding issue related to C++ Refactor PRs that only refactor code

Comments

@luzpaz
Copy link
Contributor

luzpaz commented May 9, 2022

///FIXME: For v0.20: Do not use stuff from Part module here!
else if(Base::streq(attr,"Shape") && getPropertyContainerPtr()->isDerivedFrom(App::DocumentObject::getClassTypeId())) {
// Special treatment of Shape property
static PyObject *_getShape = nullptr;
if(!_getShape) {
_getShape = Py_None;
PyObject *mod = PyImport_ImportModule("Part");
if(!mod) {
PyErr_Clear();
} else {
Py::Object pyMod = Py::asObject(mod);
if(pyMod.hasAttr("getShape"))
_getShape = Py::new_reference_to(pyMod.getAttr("getShape"));
}
}
if(_getShape != Py_None) {
Py::Tuple args(1);
args.setItem(0,Py::Object(const_cast<PropertyContainerPy*>(this)));
auto res = PyObject_CallObject(_getShape, args.ptr());
if(!res)
PyErr_Clear();
else {
Py::Object pyres(res,true);
if(pyres.hasAttr("isNull")) {
Py::Callable func(pyres.getAttr("isNull"));
if(!func.apply().isTrue())
return Py::new_reference_to(res);
}
}
}
}

@luzpaz luzpaz added Refactor PRs that only refactor code Coding: C++ Coding issue related to C++ labels May 9, 2022
@luzpaz luzpaz changed the title App: For v0.20: Do not use stuff from Part module here (PyObject *PropertyContainerPy::getCustomAttributes) App: For v0.20: Do not use stuff from Part module here (PyObject *PropertyContainerPy::getCustomAttributes) May 9, 2022
@donovaly donovaly added this to the 0.20 milestone May 11, 2022
@donovaly
Copy link
Member

Why is this for 0.20? Is there a regression or potential memory leak?

@donovaly
Copy link
Member

@wwmayer could you have a quick look if you agree we must do something for 0.20 here?

@wwmayer
Copy link
Contributor

wwmayer commented May 15, 2022

It's fine to postpone to v0.21. It's not urgent but at some point it must be fixed.

@donovaly donovaly removed this from the 0.20 milestone May 15, 2022
@donovaly
Copy link
Member

Thanks.

@donovaly donovaly changed the title App: For v0.20: Do not use stuff from Part module here (PyObject *PropertyContainerPy::getCustomAttributes) App: Do not use stuff from Part module here (PyObject *PropertyContainerPy::getCustomAttributes) May 15, 2022
@luzpaz
Copy link
Contributor Author

luzpaz commented May 15, 2022

Why is this for 0.20? Is there a regression or potential memory leak?

Just for completion: the comment on line 569 says so: ///FIXME: For v0.20: Do not use stuff from Part module here! hence the original title of the ticket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Coding: C++ Coding issue related to C++ Refactor PRs that only refactor code
Projects
None yet
Development

No branches or pull requests

3 participants