[Bf-blender-cvs] [d3bcbe10c20] blender-v2.91-release: PyAPI: add Struct.is_property_set(..., ghost) option

Campbell Barton noreply at git.blender.org
Wed Nov 4 08:11:20 CET 2020


Commit: d3bcbe10c20e8b418659d8fdca98fd6b4bfecdfe
Author: Campbell Barton
Date:   Wed Nov 4 18:06:34 2020 +1100
Branches: blender-v2.91-release
https://developer.blender.org/rBd3bcbe10c20e8b418659d8fdca98fd6b4bfecdfe

PyAPI: add Struct.is_property_set(..., ghost) option

This exposes the use_ghost argument to RNA_property_is_set_ex.

===================================================================

M	source/blender/python/intern/bpy_rna.c

===================================================================

diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index d6ab76dac60..cd0ec44e2ad 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -3604,20 +3604,30 @@ static PyObject *pyrna_struct_values(BPy_PropertyRNA *self)
 }
 
 PyDoc_STRVAR(pyrna_struct_is_property_set_doc,
-             ".. method:: is_property_set(property)\n"
+             ".. method:: is_property_set(property, ghost=True)\n"
              "\n"
              "   Check if a property is set, use for testing operator properties.\n"
              "\n"
+             "   :arg ghost: Used for operators that re-run with previous settings.\n"
+             "      In this case the property is not marked as set,\n"
+             "      yet the value from the previous execution is used.\n"
+             "\n"
+             "      In rare cases you may want to set this option to false.\n"
+             "\n"
+             "   :type ghost: boolean\n"
              "   :return: True when the property has been set.\n"
              "   :rtype: boolean\n");
-static PyObject *pyrna_struct_is_property_set(BPy_StructRNA *self, PyObject *args)
+static PyObject *pyrna_struct_is_property_set(BPy_StructRNA *self, PyObject *args, PyObject *kw)
 {
   PropertyRNA *prop;
   const char *name;
+  bool use_ghost = false;
 
   PYRNA_STRUCT_CHECK_OBJ(self);
 
-  if (!PyArg_ParseTuple(args, "s:is_property_set", &name)) {
+  static const char *_keywords[] = {"", "ghost", NULL};
+  static _PyArg_Parser _parser = {"s|$O&:is_property_set", _keywords, 0};
+  if (!_PyArg_ParseTupleAndKeywordsFast(args, kw, &_parser, &name, PyC_ParseBool, &use_ghost)) {
     return NULL;
   }
 
@@ -3629,7 +3639,7 @@ static PyObject *pyrna_struct_is_property_set(BPy_StructRNA *self, PyObject *arg
     return NULL;
   }
 
-  return PyBool_FromLong(RNA_property_is_set(&self->ptr, prop));
+  return PyBool_FromLong(RNA_property_is_set_ex(&self->ptr, prop, use_ghost));
 }
 
 PyDoc_STRVAR(pyrna_struct_property_unset_doc,
@@ -5654,7 +5664,7 @@ static struct PyMethodDef pyrna_struct_methods[] = {
 
     {"is_property_set",
      (PyCFunction)pyrna_struct_is_property_set,
-     METH_VARARGS,
+     METH_VARARGS | METH_KEYWORDS,
      pyrna_struct_is_property_set_doc},
     {"property_unset",
      (PyCFunction)pyrna_struct_property_unset,



More information about the Bf-blender-cvs mailing list