fix [#31661] Custom properties do no respect min/max values
authorCampbell Barton <ideasman42@gmail.com>
Fri, 26 Oct 2012 10:54:02 +0000 (10:54 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 26 Oct 2012 10:54:02 +0000 (10:54 +0000)
also renamed function added prev commit

release/scripts/startup/bl_operators/wm.py
source/blender/python/BPY_extern.h
source/blender/python/intern/bpy_interface.c
source/blender/render/intern/source/external_engine.c
source/blender/windowmanager/intern/wm.c

index ac72b39a04d34621b5d051fe3c0632c4152a4890..5cc041476c96a1758b358c79129a9360477263f8 100644 (file)
@@ -1124,9 +1124,15 @@ class WM_OT_properties_add(Operator):
 
             return prop_new
 
-        property = unique_name(item.keys())
+        prop = unique_name(item.keys())
+
+        item[prop] = 1.0
+
+        # not essential, but without this we get [#31661]
+        prop_ui = rna_idprop_ui_prop_get(item, prop)
+        prop_ui["soft_min"] = prop_ui["min"] = 0.0
+        prop_ui["soft_max"] = prop_ui["max"] = 1.0
 
-        item[property] = 1.0
         return {'FINISHED'}
 
 
index 53bd128562aa99d9d2705b1102839d2f2283ee6c..9bd45d2b759952a8d4e05073933c8413a9134b49 100644 (file)
@@ -80,7 +80,7 @@ int           BPY_button_exec(struct bContext *C, const char *expr, double *value, const
 int            BPY_string_exec(struct bContext *C, const char *expr);
 
 void   BPY_DECREF(void *pyob_ptr);     /* Py_DECREF() */
-void   BPY_RNA_DECREF_INVALIDATE(void *pyob_ptr);
+void   BPY_DECREF_RNA_INVALIDATE(void *pyob_ptr);
 int            BPY_context_member_get(struct bContext *C, const char *member, struct bContextDataResult *result);
 void   BPY_context_set(struct bContext *C);
 void   BPY_context_update(struct bContext *C);
index 39621fcf390f8ca759eaa8fc12f5b0ba7304446c..94cbee383ea584aa01d9a80d8e50d25c5a60c326 100644 (file)
@@ -510,7 +510,7 @@ void BPY_DECREF(void *pyob_ptr)
        PyGILState_Release(gilstate);
 }
 
-void BPY_RNA_DECREF_INVALIDATE(void *pyob_ptr)
+void BPY_DECREF_RNA_INVALIDATE(void *pyob_ptr)
 {
        PyGILState_STATE gilstate = PyGILState_Ensure();
        const int do_invalidate = (Py_REFCNT((PyObject *)pyob_ptr) > 1);
index 9647b100d2dd69e41ba76b55a10ffebceea5ba3d..94146467145c61e10b5b0a46023cc659c50483b8 100644 (file)
@@ -138,7 +138,7 @@ void RE_engine_free(RenderEngine *engine)
 {
 #ifdef WITH_PYTHON
        if (engine->py_instance) {
-               BPY_RNA_DECREF_INVALIDATE(engine->py_instance);
+               BPY_DECREF_RNA_INVALIDATE(engine->py_instance);
        }
 #endif
 
index fa00ec63b31446e0826163e6453d139dc7694f45..8fe387765ce0e3634d523f4e96f9175f290af839 100644 (file)
@@ -78,7 +78,7 @@ void WM_operator_free(wmOperator *op)
        if (op->py_instance) {
                /* do this first in case there are any __del__ functions or
                 * similar that use properties */
-               BPY_RNA_DECREF_INVALIDATE(op->py_instance);
+               BPY_DECREF_RNA_INVALIDATE(op->py_instance);
        }
 #endif