crash fix for brush select when no object is active
authorCampbell Barton <ideasman42@gmail.com>
Tue, 24 Apr 2012 12:27:38 +0000 (12:27 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 24 Apr 2012 12:27:38 +0000 (12:27 +0000)
source/blender/editors/sculpt_paint/paint_ops.c

index 3bc3c7a92244b40b45aa41f6ff61870bc0c2979a..b5d6f20aa7984d10a853dae765460082c36757de 100644 (file)
@@ -254,12 +254,18 @@ static int brush_select_exec(bContext *C, wmOperator *op)
        size_t tool_offset;
 
        if (paint_mode == OB_MODE_ACTIVE) {
-               /* select current paint mode */
-               paint_mode = CTX_data_active_object(C)->mode &
-                            (OB_MODE_SCULPT |
-                             OB_MODE_VERTEX_PAINT |
-                             OB_MODE_WEIGHT_PAINT |
-                             OB_MODE_TEXTURE_PAINT);
+               Object *ob = CTX_data_active_object(C);
+               if (ob) {
+                       /* select current paint mode */
+                       paint_mode = ob->mode &
+                                    (OB_MODE_SCULPT |
+                                     OB_MODE_VERTEX_PAINT |
+                                     OB_MODE_WEIGHT_PAINT |
+                                     OB_MODE_TEXTURE_PAINT);
+               }
+               else {
+                       return OPERATOR_CANCELLED;
+               }
        }
 
        switch (paint_mode) {