Add locked keyword argument to DocumentObject::addProperty
This commit is contained in:
committed by
Kacper Donat
parent
01effaaab0
commit
257ea040f8
@@ -91,21 +91,21 @@ PyObject* DocumentObjectPy::addProperty(PyObject* args, PyObject* kwd)
|
||||
{
|
||||
char *sType, *sName = nullptr, *sGroup = nullptr, *sDoc = nullptr;
|
||||
short attr = 0;
|
||||
std::string sDocStr;
|
||||
PyObject *ro = Py_False, *hd = Py_False;
|
||||
PyObject *ro = Py_False, *hd = Py_False, *lk = Py_False;
|
||||
PyObject* enumVals = nullptr;
|
||||
const std::array<const char*, 9> kwlist {"type",
|
||||
const std::array<const char*, 10> kwlist {"type",
|
||||
"name",
|
||||
"group",
|
||||
"doc",
|
||||
"attr",
|
||||
"read_only",
|
||||
"hidden",
|
||||
"locked",
|
||||
"enum_vals",
|
||||
nullptr};
|
||||
if (!Base::Wrapped_ParseTupleAndKeywords(args,
|
||||
kwd,
|
||||
"ss|sethO!O!O",
|
||||
"ss|sethO!O!O!O",
|
||||
kwlist,
|
||||
&sType,
|
||||
&sName,
|
||||
@@ -117,23 +117,22 @@ PyObject* DocumentObjectPy::addProperty(PyObject* args, PyObject* kwd)
|
||||
&ro,
|
||||
&PyBool_Type,
|
||||
&hd,
|
||||
&PyBool_Type,
|
||||
&lk,
|
||||
&enumVals)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (sDoc) {
|
||||
sDocStr = sDoc;
|
||||
PyMem_Free(sDoc);
|
||||
}
|
||||
|
||||
Property* prop = getDocumentObjectPtr()->addDynamicProperty(sType,
|
||||
sName,
|
||||
sGroup,
|
||||
sDocStr.c_str(),
|
||||
sDoc,
|
||||
attr,
|
||||
Base::asBoolean(ro),
|
||||
Base::asBoolean(hd));
|
||||
|
||||
prop->setStatus(Property::LockDynamic, Base::asBoolean(lk));
|
||||
|
||||
// enum support
|
||||
auto* propEnum = dynamic_cast<App::PropertyEnumeration*>(prop);
|
||||
if (propEnum && enumVals) {
|
||||
|
||||
Reference in New Issue
Block a user