Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Poirier <theeth@yahoo.com>2010-01-28 00:19:39 +0300
committerMartin Poirier <theeth@yahoo.com>2010-01-28 00:19:39 +0300
commitfb7878a2c29338ee706b5add6a9a95b665616725 (patch)
tree6612060c1a0c88fb283cab4659755cd6f007afef /source/blender/makesrna
parent86a65890c469506717cef8e5fba48993d8e0379f (diff)
PROP_ENUM_NO_CONTEXT flag for rna properties, forcing enum item functions to be passed a null context (to return non-contextual items).
This is set on keymap item operator properties and macro definition operator properties to make them non-contextual (since the context at definition time is most likely not the same then at execution time, it's better to have all options visible). This removes some more errors in keymap export and import. This commit also sanitize some enum item function, making sure they can cope with null context and have usable defaults in that case.
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r--source/blender/makesrna/RNA_enum_types.h1
-rw-r--r--source/blender/makesrna/RNA_types.h3
-rw-r--r--source/blender/makesrna/intern/rna_access.c14
3 files changed, 15 insertions, 3 deletions
diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h
index 88be81fb691..14b2f0c561e 100644
--- a/source/blender/makesrna/RNA_enum_types.h
+++ b/source/blender/makesrna/RNA_enum_types.h
@@ -33,6 +33,7 @@ extern EnumPropertyItem id_type_items[];
/* use in cases where only dynamic types are used */
extern EnumPropertyItem DummyRNA_NULL_items[];
+extern EnumPropertyItem DummyRNA_DEFAULT_items[];
extern EnumPropertyItem object_mode_items[];
diff --git a/source/blender/makesrna/RNA_types.h b/source/blender/makesrna/RNA_types.h
index 5480ebcf844..960060691f0 100644
--- a/source/blender/makesrna/RNA_types.h
+++ b/source/blender/makesrna/RNA_types.h
@@ -187,7 +187,8 @@ typedef enum PropertyFlag {
PROP_RAW_ACCESS = 1<<13,
PROP_RAW_ARRAY = 1<<14,
PROP_FREE_POINTERS = 1<<15,
- PROP_DYNAMIC = 1<<17 /* for dynamic arrays, and retvals of type string */
+ PROP_DYNAMIC = 1<<17, /* for dynamic arrays, and retvals of type string */
+ PROP_ENUM_NO_CONTEXT = 1<<18 /* for enum that shouldn't be contextual */
} PropertyFlag;
typedef struct CollectionPropertyIterator {
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index d7517f6661c..b641f6b3105 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -943,15 +943,25 @@ EnumPropertyItem DummyRNA_NULL_items[] = {
{0, NULL, 0, NULL, NULL}
};
+/* Reuse for dynamic types with default value */
+EnumPropertyItem DummyRNA_DEFAULT_items[] = {
+ {0, "DEFAULT", 0, "Default", ""},
+ {0, NULL, 0, NULL, NULL}
+};
+
void RNA_property_enum_items(bContext *C, PointerRNA *ptr, PropertyRNA *prop, EnumPropertyItem **item, int *totitem, int *free)
{
EnumPropertyRNA *eprop= (EnumPropertyRNA*)rna_ensure_property(prop);
*free= 0;
- if(eprop->itemf && C) {
+ if(eprop->itemf && (C != NULL || (prop->flag & PROP_ENUM_NO_CONTEXT))) {
int tot= 0;
- *item= eprop->itemf(C, ptr, free);
+
+ if (prop->flag & PROP_ENUM_NO_CONTEXT)
+ *item= eprop->itemf(NULL, ptr, free);
+ else
+ *item= eprop->itemf(C, ptr, free);
if(totitem) {
if(*item) {