Fix: incorrect GPU ownership after IMB_dupImBuf
The IMB_dupImBuf() function does not copy the GPU texture as it might not be possible if the GPU context is not active, but it also was not clearing the pointer in the result ImBuf. This could potentially lead to situation when the texture gets freed via IMB_freeImBuf of either original or copied image buffer, leaving the other pointing to a freed GPU texture. It is not known whether it ever was an actual problem for artists, but it is nice to avoid such possibility. Pull Request: https://projects.blender.org/blender/blender/pulls/119469
This commit is contained in:
committed by
Sergey Sharybin
parent
2e7395e07b
commit
6aa21ed752
@@ -635,6 +635,10 @@ ImBuf *IMB_dupImBuf(const ImBuf *ibuf1)
|
||||
tbuf.display_buffer_flags = nullptr;
|
||||
tbuf.colormanage_cache = nullptr;
|
||||
|
||||
/* GPU textures can not be easily copied, as it is not guaranteed that this function is called
|
||||
* from within an active GPU context. */
|
||||
tbuf.gpu.texture = nullptr;
|
||||
|
||||
*ibuf2 = tbuf;
|
||||
|
||||
return ibuf2;
|
||||
|
||||
Reference in New Issue
Block a user