[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [55738] trunk/blender/source/blender/ editors/sculpt_paint: Fix #34849: crash in operator search menu, due to brush stencil poll

Brecht Van Lommel brechtvanlommel at pandora.be
Tue Apr 2 20:19:35 CEST 2013


Revision: 55738
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=55738
Author:   blendix
Date:     2013-04-02 18:19:35 +0000 (Tue, 02 Apr 2013)
Log Message:
-----------
Fix #34849: crash in operator search menu, due to brush stencil poll
function not checking NULL pointer.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/sculpt_paint/paint_ops.c
    trunk/blender/source/blender/editors/sculpt_paint/paint_utils.c

Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_ops.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_ops.c	2013-04-02 18:19:16 UTC (rev 55737)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_ops.c	2013-04-02 18:19:35 UTC (rev 55738)
@@ -62,7 +62,7 @@
 {
 	/*int type = RNA_enum_get(op->ptr, "type");*/
 	Paint *paint = paint_get_active_from_context(C);
-	struct Brush *br = paint_brush(paint);
+	Brush *br = paint_brush(paint);
 	Main *bmain = CTX_data_main(C);
 
 	if (br)
@@ -94,7 +94,7 @@
 {
 	Scene *scene = CTX_data_scene(C);
 	Paint  *paint =  paint_get_active_from_context(C);
-	struct Brush  *brush =  paint_brush(paint);
+	Brush  *brush =  paint_brush(paint);
 	// Object *ob = CTX_data_active_object(C);
 	float scalar = RNA_float_get(op->ptr, "scalar");
 
@@ -176,10 +176,10 @@
 static int brush_reset_exec(bContext *C, wmOperator *UNUSED(op))
 {
 	Paint *paint = paint_get_active_from_context(C);
-	struct Brush *brush = paint_brush(paint);
+	Brush *brush = paint_brush(paint);
 	Object *ob = CTX_data_active_object(C);
 
-	if (!ob) return OPERATOR_CANCELLED;
+	if (!ob || !brush) return OPERATOR_CANCELLED;
 
 	if (ob->mode & OB_MODE_SCULPT)
 		BKE_brush_sculpt_reset(brush);
@@ -215,7 +215,7 @@
 /* generic functions for setting the active brush based on the tool */
 static Brush *brush_tool_cycle(Main *bmain, Brush *brush_orig, const int tool, const size_t tool_offset, const int ob_mode)
 {
-	struct Brush *brush;
+	Brush *brush;
 
 	if (!brush_orig && !(brush_orig = bmain->brush.first)) {
 		return NULL;
@@ -266,7 +266,7 @@
                                   const char *tool_name, int create_missing,
                                   int toggle)
 {
-	struct Brush *brush, *brush_orig = paint_brush(paint);
+	Brush *brush, *brush_orig = paint_brush(paint);
 
 	if (toggle)
 		brush = brush_tool_toggle(bmain, brush_orig, tool, tool_offset, ob_mode);
@@ -467,7 +467,7 @@
 static int stencil_control_invoke(bContext *C, wmOperator *op, const wmEvent *event)
 {
 	Paint *paint = paint_get_active_from_context(C);
-	Brush *br = paint->brush;
+	Brush *br = paint_brush(paint);
 	int mdiff[2];
 
 	StencilControlData *scd = MEM_mallocN(sizeof(StencilControlData), "stencil_control");
@@ -567,9 +567,9 @@
 static int stencil_control_poll(bContext *C)
 {
 	Paint *paint = paint_get_active_from_context(C);
-	Brush *br = paint->brush;
+	Brush *br = paint_brush(paint);
 
-	return br->mtex.brush_map_mode == MTEX_MAP_MODE_STENCIL;
+	return (br && br->mtex.brush_map_mode == MTEX_MAP_MODE_STENCIL);
 }
 
 static void BRUSH_OT_stencil_control(wmOperatorType *ot)

Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_utils.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_utils.c	2013-04-02 18:19:16 UTC (rev 55737)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_utils.c	2013-04-02 18:19:35 UTC (rev 55738)
@@ -381,8 +381,10 @@
 static int brush_curve_preset_exec(bContext *C, wmOperator *op)
 {
 	Brush *br = paint_brush(paint_get_active_from_context(C));
-	BKE_brush_curve_preset(br, RNA_enum_get(op->ptr, "shape"));
 
+	if(br)
+		BKE_brush_curve_preset(br, RNA_enum_get(op->ptr, "shape"));
+
 	return OPERATOR_FINISHED;
 }
 




More information about the Bf-blender-cvs mailing list