Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntony Riakiotakis <kalast@gmail.com>2014-09-04 22:23:03 +0400
committerAntony Riakiotakis <kalast@gmail.com>2014-09-04 22:23:03 +0400
commit1871c08160b06dcff924ef723979c46a470992cf (patch)
treee5ebd039531820fe1ee7df229511f279b72c28cd /source/blender/editors/sculpt_paint/paint_image.c
parent84a7a578e2f14bf001582117faf7e099530d402a (diff)
Fix T41716, crash with image mode when painting without materials.
* As always, make sure all slots of the object have a material
Diffstat (limited to 'source/blender/editors/sculpt_paint/paint_image.c')
-rw-r--r--source/blender/editors/sculpt_paint/paint_image.c46
1 files changed, 24 insertions, 22 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c
index 8cef74e9392..2a79b111c6d 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -1358,21 +1358,22 @@ void paint_proj_mesh_data_ensure(bContext *C, Object *ob, wmOperator *op)
Main *bmain = CTX_data_main(C);
Brush *br = BKE_paint_brush(&imapaint->paint);
- if (imapaint->mode == IMAGEPAINT_MODE_MATERIAL) {
- /* no material, add one */
- if (ob->totcol == 0) {
- Material *ma = BKE_material_add(CTX_data_main(C), "Material");
- /* no material found, just assign to first slot */
- assign_material(ob, ma, 1, BKE_MAT_ASSIGN_USERPREF);
- proj_paint_add_slot(C, ma, NULL);
- }
- else {
- /* there may be material slots but they may be empty, check */
- int i;
-
- for (i = 1; i < ob->totcol + 1; i++) {
- Material *ma = give_current_material(ob, i);
- if (ma) {
+ /* no material, add one */
+ if (ob->totcol == 0) {
+ Material *ma = BKE_material_add(CTX_data_main(C), "Material");
+ /* no material found, just assign to first slot */
+ assign_material(ob, ma, 1, BKE_MAT_ASSIGN_USERPREF);
+ proj_paint_add_slot(C, ma, NULL);
+ }
+ else {
+ /* there may be material slots but they may be empty, check */
+ int i;
+
+ for (i = 1; i < ob->totcol + 1; i++) {
+ Material *ma = give_current_material(ob, i);
+
+ if (ma) {
+ if (imapaint->mode == IMAGEPAINT_MODE_MATERIAL) {
if (!ma->texpaintslot) {
/* refresh here just in case */
BKE_texpaint_slot_refresh_cache(scene, ma);
@@ -1399,16 +1400,17 @@ void paint_proj_mesh_data_ensure(bContext *C, Object *ob, wmOperator *op)
}
}
}
- else {
- Material *ma = BKE_material_add(CTX_data_main(C), "Material");
- /* no material found, just assign to first slot */
- assign_material(ob, ma, i, BKE_MAT_ASSIGN_USERPREF);
- proj_paint_add_slot(C, ma, NULL);
- }
+ }
+ else {
+ Material *ma = BKE_material_add(CTX_data_main(C), "Material");
+ /* no material found, just assign to first slot */
+ assign_material(ob, ma, i, BKE_MAT_ASSIGN_USERPREF);
+ proj_paint_add_slot(C, ma, NULL);
}
}
}
- else if (imapaint->mode == IMAGEPAINT_MODE_IMAGE) {
+
+ if (imapaint->mode == IMAGEPAINT_MODE_IMAGE) {
if (imapaint->canvas == NULL) {
int width;
int height;