From d23d3d7ac1d18ec3efef38f64c3b5e4aca42daf2 Mon Sep 17 00:00:00 2001 From: Florian Foinant-Willig Date: Thu, 24 Apr 2025 14:46:37 +0200 Subject: [PATCH] Add `locked` keyword to Document::addProperty --- src/App/Document.pyi | 3 ++- src/App/DocumentPyImp.cpp | 10 +++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/App/Document.pyi b/src/App/Document.pyi index fee4ee35ef..bd7e59f86e 100644 --- a/src/App/Document.pyi +++ b/src/App/Document.pyi @@ -215,9 +215,10 @@ class Document(PropertyContainer): attr: int = 0, read_only: bool = False, hidden: bool = False, + locked: bool = False, ) -> "Document": """ - addProperty(type: string, name: string, group="", doc="", attr=0, read_only=False, hidden=False) -- Add a generic property. + addProperty(type: string, name: string, group="", doc="", attr=0, read_only=False, hidden=False, locked=False) -- Add a generic property. """ ... diff --git a/src/App/DocumentPyImp.cpp b/src/App/DocumentPyImp.cpp index 1c7d8a03fe..cb6d47a29e 100644 --- a/src/App/DocumentPyImp.cpp +++ b/src/App/DocumentPyImp.cpp @@ -49,20 +49,21 @@ PyObject* DocumentPy::addProperty(PyObject* args, PyObject* kwd) char* 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; - static const std::array kwlist {"type", + static const std::array 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, @@ -74,6 +75,8 @@ PyObject* DocumentPy::addProperty(PyObject* args, PyObject* kwd) &ro, &PyBool_Type, &hd, + &PyBool_Type, + &lk, &enumVals)) { return nullptr; } @@ -90,6 +93,7 @@ PyObject* DocumentPy::addProperty(PyObject* args, PyObject* kwd) attr, Base::asBoolean(ro), Base::asBoolean(hd)); + prop->setStatus(Property::LockDynamic, Base::asBoolean(lk)); // enum support auto* propEnum = dynamic_cast(prop);