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.
This commit is contained in:
parent
bdbf24772a
commit
f8a3ec48e4
Notes:
blender-bot
2023-02-14 07:25:51 +01:00
Referenced by issue #100749, Blender LTS: Maintenance Task 3.3 Referenced by issue #100330, Remove Render Slot not working for first slot
|
@ -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, ¤t_last_slot->render);
|
||||
RE_SwapResult(re, &next_last_slot->render);
|
||||
}
|
||||
RE_SwapResult(re, ¤t_last_slot->render);
|
||||
RE_SwapResult(re, &next_last_slot->render);
|
||||
current_last_slot = next_last_slot;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue