[Bf-blender-cvs] [91a29361a9a] temp-T97352-3d-texturing-seam-bleeding-b2: Fix T100330: Remove Render Slot not working for first slot

Lukas Stockner noreply at git.blender.org
Tue Sep 20 10:32:12 CEST 2022


Commit: 91a29361a9aff15c29b92d3e3fa2bf8b1d0c93d5
Author: Lukas Stockner
Date:   Sat Sep 17 01:46:03 2022 +0200
Branches: temp-T97352-3d-texturing-seam-bleeding-b2
https://developer.blender.org/rB91a29361a9aff15c29b92d3e3fa2bf8b1d0c93d5

Fix T100330: Remove Render Slot not working for first slot

This bug was caused by the weird ownership logic for render results.
Basically, the most recent render result is owned by the Render, while
all others are owned by the RenderSlots.
When a new render is started, the previous Render is handed over to its
slot, and the new slot is cleared. So far, so good.

However, when a slot is removed and happens to be the one with the most
recent render, this causes a complication.
The code handles this by making another slot the most recent one, along
with moving its result back to the Render, as if that had always been
the most recent one.

That works, unless there is no most recent render because you haven't
rendered anything yet. Unfortunately, there is no way to store "there
hasn't been a render yet", so the code still tries to perform this
handover but can't.
Previously, the code handled that case by just refusing to delete the
slot. However, this blocks users from deleting this slot.

But of course, if there hasn't been a render yet, the slots will not
contain anything yet, so this entire maneuver is pointless.
Therefore, the fix for the bug is to just skip it altogether if there
is no Render instead of failing the operation.

Technically, there is a weird corner case remaining, because Renders
are per-scene. Therefore, if a user renders images in one scene,
switches to a different scene, deletes a slot there and then switches
back, in some situations the result in the deleted slot might end up
in the next slot.
Unfortunately this is just a limitation of the weird split ownership
logic and can't just be worked around. The proper fix for this
probably would be to hand over ownership of the result from the Render
to the RenderSlot once the render is done, but this is quite complex.

Also fixes a crash when iuser->scene is NULL.

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

M	source/blender/blenkernel/intern/image.cc

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

diff --git a/source/blender/blenkernel/intern/image.cc b/source/blender/blenkernel/intern/image.cc
index 44e0e7be97b..000e51c0150 100644
--- a/source/blender/blenkernel/intern/image.cc
+++ b/source/blender/blenkernel/intern/image.cc
@@ -5567,15 +5567,14 @@ bool BKE_image_remove_renderslot(Image *ima, ImageUser *iuser, int slot)
       next_last_slot = current_slot;
     }
 
-    if (!iuser) {
+    if (iuser == nullptr || iuser->scene == nullptr) {
       return false;
     }
     Render *re = RE_GetSceneRender(iuser->scene);
-    if (!re) {
-      return false;
+    if (re != nullptr) {
+      RE_SwapResult(re, &current_last_slot->render);
+      RE_SwapResult(re, &next_last_slot->render);
     }
-    RE_SwapResult(re, &current_last_slot->render);
-    RE_SwapResult(re, &next_last_slot->render);
     current_last_slot = next_last_slot;
   }



More information about the Bf-blender-cvs mailing list