[Bf-blender-cvs] [9a12f97f264] master: Fix T72487: Painting on unitialized UDIM tile crashes

Lukas Stockner noreply at git.blender.org
Wed Dec 18 00:05:18 CET 2019


Commit: 9a12f97f264e725a350368a87f75181298e47ff3
Author: Lukas Stockner
Date:   Wed Dec 18 00:00:00 2019 +0100
Branches: master
https://developer.blender.org/rB9a12f97f264e725a350368a87f75181298e47ff3

Fix T72487: Painting on unitialized UDIM tile crashes

The UDIM commit accidentally removed the check for whether an ImBuf exists
before trying to paint on it.

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

M	source/blender/editors/sculpt_paint/paint_image_proj.c

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

diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c
index 6a67c469955..d649f5017eb 100644
--- a/source/blender/editors/sculpt_paint/paint_image_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.c
@@ -748,11 +748,7 @@ static bool project_paint_PickColor(const ProjPaintState *ps,
   iuser.tile = tile_number;
   ibuf = BKE_image_acquire_ibuf(ima, &iuser, NULL);
   if (ibuf == NULL) {
-    iuser.tile = 0;
-    ibuf = BKE_image_acquire_ibuf(ima, &iuser, NULL);
-    if (ibuf == NULL) {
-      return 0;
-    }
+    return false;
   }
 
   if (interp) {
@@ -3554,16 +3550,7 @@ static void project_bucket_init(const ProjPaintState *ps,
             break;
           }
         }
-        if (ibuf == NULL) {
-          /* Failed to find the specific tile, fall back to the primary tile. */
-          for (image_index = 0; image_index < ps->image_tot; image_index++) {
-            ProjPaintImage *projIma = &ps->projImages[image_index];
-            if ((projIma->ima == tpage) && (projIma->iuser.tile == 0)) {
-              ibuf = projIma->ibuf;
-              break;
-            }
-          }
-        }
+        BLI_assert(ibuf != NULL);
       }
       /* context switching done */
 
@@ -4454,11 +4441,19 @@ static void project_paint_prepare_all_faces(ProjPaintState *ps,
         }
 
         if (image_index == ps->image_tot) {
-          PrepareImageEntry *e = MEM_callocN(sizeof(PrepareImageEntry), "PrepareImageEntry");
-          e->ima = tpage;
-          e->tile = tile;
-          BLI_addtail(&used_images, e);
-          ps->image_tot++;
+          ImageUser iuser;
+          BKE_imageuser_default(&iuser);
+          iuser.tile = tile;
+          if (BKE_image_has_ibuf(tpage, &iuser)) {
+            PrepareImageEntry *e = MEM_callocN(sizeof(PrepareImageEntry), "PrepareImageEntry");
+            e->ima = tpage;
+            e->tile = tile;
+            BLI_addtail(&used_images, e);
+            ps->image_tot++;
+          }
+          else {
+            image_index = -1;
+          }
         }
 
         tpage_last = tpage;



More information about the Bf-blender-cvs mailing list