[Bf-blender-cvs] [01e2a532f55] master: Fix T92290: Linked Color Palette datablocks can not be used.
Bastien Montagne
noreply at git.blender.org
Fri Oct 22 14:59:46 CEST 2021
Commit: 01e2a532f55ee2de3bfd1c0d97d063976546a036
Author: Bastien Montagne
Date: Fri Oct 22 14:57:34 2021 +0200
Branches: master
https://developer.blender.org/rB01e2a532f55ee2de3bfd1c0d97d063976546a036
Fix T92290: Linked Color Palette datablocks can not be used.
* Forbid editing linked palettes.
* Make `color` RNA property of ColorPalette '`LIB_EXCEPTION`', so that
the color buttons in the palette template remain active on linked data.
NOTE: This incidently makes linked palettes' colors editable from RNA,
not from UI though, so think this is OK for now.
===================================================================
M source/blender/editors/sculpt_paint/paint_ops.c
M source/blender/makesrna/intern/rna_palette.c
===================================================================
diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c
index f08771292a8..c6b519f711f 100644
--- a/source/blender/editors/sculpt_paint/paint_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_ops.c
@@ -233,7 +233,8 @@ static bool palette_poll(bContext *C)
{
Paint *paint = BKE_paint_get_active_from_context(C);
- if (paint && paint->palette != NULL) {
+ if (paint && paint->palette != NULL && !ID_IS_LINKED(paint->palette) &&
+ !ID_IS_OVERRIDE_LIBRARY(paint->palette)) {
return true;
}
diff --git a/source/blender/makesrna/intern/rna_palette.c b/source/blender/makesrna/intern/rna_palette.c
index 67d6daf5a13..30604c7a3b8 100644
--- a/source/blender/makesrna/intern/rna_palette.c
+++ b/source/blender/makesrna/intern/rna_palette.c
@@ -37,12 +37,20 @@
# include "BKE_report.h"
static PaletteColor *rna_Palette_color_new(Palette *palette)
{
+ if (ID_IS_LINKED(palette) || ID_IS_OVERRIDE_LIBRARY(palette)) {
+ return NULL;
+ }
+
PaletteColor *color = BKE_palette_color_add(palette);
return color;
}
static void rna_Palette_color_remove(Palette *palette, ReportList *reports, PointerRNA *color_ptr)
{
+ if (ID_IS_LINKED(palette) || ID_IS_OVERRIDE_LIBRARY(palette)) {
+ return;
+ }
+
PaletteColor *color = color_ptr->data;
if (BLI_findindex(&palette->colors, color) == -1) {
@@ -58,6 +66,10 @@ static void rna_Palette_color_remove(Palette *palette, ReportList *reports, Poin
static void rna_Palette_color_clear(Palette *palette)
{
+ if (ID_IS_LINKED(palette) || ID_IS_OVERRIDE_LIBRARY(palette)) {
+ return;
+ }
+
BKE_palette_clear(palette);
}
@@ -141,6 +153,7 @@ static void rna_def_palettecolor(BlenderRNA *brna)
prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_range(prop, 0.0, 1.0);
RNA_def_property_float_sdna(prop, NULL, "rgb");
+ RNA_def_property_flag(prop, PROP_LIB_EXCEPTION);
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Color", "");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
More information about the Bf-blender-cvs
mailing list