[Bf-blender-cvs] [99c1075e3b6] blender2.8: Paint: fix for creating duplicate brushes

Campbell Barton noreply at git.blender.org
Tue Nov 6 22:45:24 CET 2018


Commit: 99c1075e3b60554303a46f662e54be1ca615b027
Author: Campbell Barton
Date:   Tue Nov 6 21:15:17 2018 +1100
Branches: blender2.8
https://developer.blender.org/rB99c1075e3b60554303a46f662e54be1ca615b027

Paint: fix for creating duplicate brushes

Setting the tool added a brush if none was found
but wasn't checking for existing brushes.

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

M	source/blender/windowmanager/intern/wm_toolsystem.c

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

diff --git a/source/blender/windowmanager/intern/wm_toolsystem.c b/source/blender/windowmanager/intern/wm_toolsystem.c
index 093b014957e..8cf8eac5145 100644
--- a/source/blender/windowmanager/intern/wm_toolsystem.c
+++ b/source/blender/windowmanager/intern/wm_toolsystem.c
@@ -259,9 +259,15 @@ static void toolsystem_ref_link(bContext *C, WorkSpace *workspace, bToolRef *tre
 						struct Brush *brush = BKE_paint_toolslots_brush_get(paint, slot_index);
 						if (brush == NULL) {
 							/* Could make into a function. */
-							brush = BKE_brush_add(bmain, items[i].name, paint->runtime.ob_mode);
-							char *tool_type = (char *)POINTER_OFFSET(brush, paint->runtime.tool_offset);
-							*tool_type = slot_index;
+							brush = (struct Brush *)BKE_libblock_find_name(bmain, ID_BR, items[i].name);
+							if (brush && slot_index == *(char *)POINTER_OFFSET(brush, paint->runtime.tool_offset)) {
+								/* pass */
+							}
+							else {
+								brush = BKE_brush_add(bmain, items[i].name, paint->runtime.ob_mode);
+								char *tool_type = (char *)POINTER_OFFSET(brush, paint->runtime.tool_offset);
+								*tool_type = slot_index;
+							}
 							BKE_paint_brush_set(paint, brush);
 						}
 						BKE_paint_brush_set(paint, brush);



More information about the Bf-blender-cvs mailing list