[Bf-blender-cvs] [038965c] soc-2013-paint: Do delayed cleanup of palette colors because they are still used still by the interface after deleting. Now just tagging for delete on next UI refresh.

Antony Riakiotakis noreply at git.blender.org
Tue May 20 09:51:20 CEST 2014


Commit: 038965c7917ffb741b3fc01a0481dbcf234c46ff
Author: Antony Riakiotakis
Date:   Mon May 19 23:44:46 2014 +0300
https://developer.blender.org/rB038965c7917ffb741b3fc01a0481dbcf234c46ff

Do delayed cleanup of palette colors because they are still used still
by the interface after deleting. Now just tagging for delete on next UI
refresh.

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

M	source/blender/blenkernel/BKE_paint.h
M	source/blender/blenkernel/intern/paint.c
M	source/blender/editors/interface/interface_templates.c
M	source/blender/makesdna/DNA_brush_types.h
M	source/blender/makesrna/intern/rna_sculpt_paint.c

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

diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h
index c7211e3..a495205 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -103,6 +103,7 @@ struct PaletteColor *BKE_palette_color_add(struct Palette *palette);
 struct PaletteColor *BKE_palette_color_get_last(struct Palette *palette);
 bool BKE_palette_is_empty(const struct Palette *palette);
 void BKE_palette_remove_color (struct Palette *palette, struct PaletteColor *colour);
+void BKE_palette_cleanup (struct Palette *palette);
 
 /* paint curves */
 struct PaintCurve *BKE_paint_curve_add(struct Main *bmain, const char *name);
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index cceb3fa..4dbf515 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -317,9 +317,15 @@ void BKE_paint_curve_set(Brush *br, PaintCurve *pc)
 void BKE_palette_remove_color(Palette *palette, PaletteColor *colour)
 {
 	BLI_remlink(&palette->colors, colour);
-	MEM_freeN(colour);
+	BLI_addhead(&palette->deleted, colour);
 }
 
+void BKE_palette_cleanup(Palette *palette)
+{
+	BLI_freelistN(&palette->deleted);
+}
+
+
 Palette *BKE_palette_add(Main *bmain, const char *name)
 {
 	Palette *palette;
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 2304fbb..a0cb150 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -61,6 +61,7 @@
 #include "BKE_object.h"
 #include "BKE_packedFile.h"
 #include "BKE_particle.h"
+#include "BKE_paint.h"
 #include "BKE_report.h"
 #include "BKE_sca.h"
 #include "BKE_screen.h"
@@ -2362,6 +2363,10 @@ void uiTemplatePalette(uiLayout *layout, PointerRNA *ptr, const char *propname,
 	block = uiLayoutGetBlock(layout);
 
 	palette = cptr.data;
+
+	/* first delete any pending colors */
+	BKE_palette_cleanup(palette);
+
 	color = palette->colors.first;
 
 	col = uiLayoutColumn(layout, true);
diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h
index 03f9c3d..6ace52f 100644
--- a/source/blender/makesdna/DNA_brush_types.h
+++ b/source/blender/makesdna/DNA_brush_types.h
@@ -151,6 +151,7 @@ typedef struct Palette
 
 	/* pointer to individual colours */
 	ListBase colors;
+	ListBase deleted;
 
 	int num_of_colours;
 	int pad;
diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c
index 59f1fa9..392756a 100644
--- a/source/blender/makesrna/intern/rna_sculpt_paint.c
+++ b/source/blender/makesrna/intern/rna_sculpt_paint.c
@@ -305,16 +305,19 @@ static void rna_def_palettecolor(BlenderRNA *brna)
 	RNA_def_property_range(prop, 0.0, 1.0);
 	RNA_def_property_float_sdna(prop, NULL, "rgb");
 	RNA_def_property_ui_text(prop, "Color", "");
+	RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
 
 	prop = RNA_def_property(srna, "strength", PROP_FLOAT, PROP_NONE);
 	RNA_def_property_range(prop, 0.0, 1.0);
 	RNA_def_property_float_sdna(prop, NULL, "value");
 	RNA_def_property_ui_text(prop, "Value", "");
+	RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
 
 	prop = RNA_def_property(srna, "weight", PROP_FLOAT, PROP_NONE);
 	RNA_def_property_range(prop, 0.0, 1.0);
 	RNA_def_property_float_sdna(prop, NULL, "value");
 	RNA_def_property_ui_text(prop, "Weight", "");
+	RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
 }
 
 
@@ -330,6 +333,7 @@ static void rna_def_palette(BlenderRNA *brna)
 	prop = RNA_def_property(srna, "colors", PROP_COLLECTION, PROP_NONE);
 	RNA_def_property_struct_type(prop, "PaletteColor");
 	RNA_def_property_ui_text(prop, "Palette Color", "Colors that are part of this palette");
+	RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
 }
 
 static void rna_def_paint_curve(BlenderRNA *brna)




More information about the Bf-blender-cvs mailing list