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:
authorLukas Stockner <lukas.stockner@freenet.de>2022-09-17 02:46:03 +0300
committerLukas Stockner <lukas.stockner@freenet.de>2022-09-17 17:21:44 +0300
commitf8a3ec48e4babf4a907b0350c5f7bd050343466f (patch)
treee12813b7fe4f9348f127422d93af07c3e95fff87
parentbdbf24772a0dd5edd65eb861e9347a44205c164b (diff)
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.
-rw-r--r--source/blender/blenkernel/intern/image.cc9
1 files changed, 4 insertions, 5 deletions
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;
}