[Bf-blender-cvs] [81472af] master: Remove deleted list for palette colors

Campbell Barton noreply at git.blender.org
Thu Mar 19 20:09:07 CET 2015


Commit: 81472aff2be5a8059e046436b4d1810659032716
Author: Campbell Barton
Date:   Fri Mar 20 06:07:22 2015 +1100
Branches: master
https://developer.blender.org/rB81472aff2be5a8059e046436b4d1810659032716

Remove deleted list for palette colors

was used because of UI memory access only.

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

M	source/blender/blenkernel/BKE_paint.h
M	source/blender/blenkernel/intern/paint.c
M	source/blender/blenloader/intern/readfile.c
M	source/blender/editors/interface/interface_handlers.c
M	source/blender/editors/interface/interface_templates.c
M	source/blender/makesdna/DNA_brush_types.h
M	source/blender/makesrna/intern/rna_palette.c

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

diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h
index 58c0b49..9076ead 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -102,9 +102,7 @@ void                 BKE_palette_free(struct Palette *palette);
 struct Palette      *BKE_palette_add(struct Main *bmain, const char *name);
 struct PaletteColor *BKE_palette_color_add(struct Palette *palette);
 bool                 BKE_palette_is_empty(const struct Palette *palette);
-void                 BKE_palette_color_remove_ex(struct Palette *palette, struct PaletteColor *color, bool use_free);
 void                 BKE_palette_color_remove(struct Palette *palette, struct PaletteColor *color);
-void                 BKE_palette_cleanup(struct Palette *palette);
 void                 BKE_palette_clear(struct Palette *palette);
 
 /* paint curves */
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index 2082066..c3c8838 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -314,7 +314,7 @@ void BKE_paint_curve_set(Brush *br, PaintCurve *pc)
 }
 
 /* remove colour from palette. Must be certain color is inside the palette! */
-void BKE_palette_color_remove_ex(Palette *palette, PaletteColor *color, bool use_free)
+void BKE_palette_color_remove(Palette *palette, PaletteColor *color)
 {
 	if (BLI_listbase_count_ex(&palette->colors, palette->active_color) == palette->active_color) {
 		palette->active_color--;
@@ -326,32 +326,15 @@ void BKE_palette_color_remove_ex(Palette *palette, PaletteColor *color, bool use
 		palette->active_color = 0;
 	}
 
-	if (use_free) {
-		MEM_freeN(color);
-	}
-	else {
-		BLI_addhead(&palette->deleted, color);
-	}
-}
-
-void BKE_palette_color_remove(Palette *palette, PaletteColor *color)
-{
-	BKE_palette_color_remove_ex(palette, color, false);
+	MEM_freeN(color);
 }
 
 void BKE_palette_clear(Palette *palette)
 {
 	BLI_freelistN(&palette->colors);
-	BLI_freelistN(&palette->deleted);
 	palette->active_color = 0;
 }
 
-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/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 6b4d45a..639ee64 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -1950,7 +1950,6 @@ static void direct_link_palette(FileData *fd, Palette *palette)
 {
 	/* palette itself has been read */
 	link_list(fd, &palette->colors);
-	BLI_listbase_clear(&palette->deleted);
 }
 
 static void lib_link_paint_curve(FileData *UNUSED(fd), Main *main)
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index a6ff5bb..71b7b95 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -4494,6 +4494,12 @@ static int ui_do_but_COLOR(bContext *C, uiBut *but, uiHandleButtonData *data, co
 			BKE_palette_color_remove(palette, color);
 
 			button_activate_state(C, but, BUTTON_STATE_EXIT);
+
+			/* this is risky. it works OK for now,
+			 * but if it gives trouble we should delay execution */
+			but->rnapoin = PointerRNA_NULL;
+			but->rnaprop = NULL;
+
 			return WM_UI_HANDLER_BREAK;
 		}
 	}
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index b3c31a1..7db734e 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -2398,9 +2398,6 @@ void uiTemplatePalette(uiLayout *layout, PointerRNA *ptr, const char *propname,
 
 	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 89c8316..dd66acf 100644
--- a/source/blender/makesdna/DNA_brush_types.h
+++ b/source/blender/makesdna/DNA_brush_types.h
@@ -151,7 +151,6 @@ typedef struct Palette
 
 	/* pointer to individual colours */
 	ListBase colors;
-	ListBase deleted;
 
 	int active_color;
 	int pad;
diff --git a/source/blender/makesrna/intern/rna_palette.c b/source/blender/makesrna/intern/rna_palette.c
index 7405df9..8cbb57f 100644
--- a/source/blender/makesrna/intern/rna_palette.c
+++ b/source/blender/makesrna/intern/rna_palette.c
@@ -55,7 +55,7 @@ static void rna_Palette_color_remove(Palette *palette, ReportList *reports, Poin
 		return;
 	}
 
-	BKE_palette_color_remove_ex(palette, color, true);
+	BKE_palette_color_remove(palette, color);
 
 	RNA_POINTER_INVALIDATE(color_ptr);
 }




More information about the Bf-blender-cvs mailing list