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:
authorNathan Craddock <nzcraddock@gmail.com>2020-11-13 08:51:55 +0300
committerNathan Craddock <nzcraddock@gmail.com>2020-11-14 06:36:35 +0300
commit9b54c81414801446940fdc32d8fa1ab267d55c90 (patch)
tree78c86fa471c50e84c04e6e588b4b11c9f7c518a5
parent0633a89e1827f42d46e8497754355ef324616945 (diff)
Collections: Prevent setting scene collection color tag from rna
It should not be possible to set the scene collection's color tag through rna. Also adds a missing notifier for setting the collection color tag from python.
-rw-r--r--source/blender/makesrna/intern/rna_collection.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/source/blender/makesrna/intern/rna_collection.c b/source/blender/makesrna/intern/rna_collection.c
index 546a3428033..da364eda6ba 100644
--- a/source/blender/makesrna/intern/rna_collection.c
+++ b/source/blender/makesrna/intern/rna_collection.c
@@ -344,6 +344,31 @@ static void rna_Collection_flag_update(Main *bmain, Scene *scene, PointerRNA *pt
WM_main_add_notifier(NC_SCENE | ND_OB_SELECT, scene);
}
+static int rna_Collection_color_tag_get(struct PointerRNA *ptr)
+{
+ Collection *collection = (Collection *)ptr->data;
+
+ return collection->color_tag;
+}
+
+static void rna_Collection_color_tag_set(struct PointerRNA *ptr, int value)
+{
+ Collection *collection = (Collection *)ptr->data;
+
+ if (collection->flag & COLLECTION_IS_MASTER) {
+ return;
+ }
+
+ collection->color_tag = value;
+}
+
+static void rna_Collection_color_tag_update(Main *UNUSED(bmain),
+ Scene *scene,
+ PointerRNA *UNUSED(ptr))
+{
+ WM_main_add_notifier(NC_SCENE | ND_LAYER_CONTENT, scene);
+}
+
#else
/* collection.objects */
@@ -494,9 +519,11 @@ void RNA_def_collections(BlenderRNA *brna)
prop = RNA_def_property(srna, "color_tag", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "color_tag");
+ RNA_def_property_enum_funcs(
+ prop, "rna_Collection_color_tag_get", "rna_Collection_color_tag_set", NULL);
RNA_def_property_enum_items(prop, rna_enum_collection_color_items);
RNA_def_property_ui_text(prop, "Collection Color", "Color tag for a collection");
- RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, NULL);
+ RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_Collection_color_tag_update");
RNA_define_lib_overridable(false);
}