[Bf-blender-cvs] [5544ded] master: Fix ImBuf leaked by Image from View operator
Nicholas Bishop
noreply at git.blender.org
Mon Feb 9 12:03:16 CET 2015
Commit: 5544ded2b513a41caa1673aea3dfbbc5b56380be
Author: Nicholas Bishop
Date: Mon Feb 9 12:02:59 2015 +0100
Branches: master
https://developer.blender.org/rB5544ded2b513a41caa1673aea3dfbbc5b56380be
Fix ImBuf leaked by Image from View operator
Running this operator and and closing Blender gives this:
Error: Not freed memory blocks: 2
ImBuf_struct len: 2480 0x69ba4f8
imb_addrectImBuf len: 1048576 0x6ccc2d8
Fixed with added call to IMB_freeImBuf in BKE_image_add_from_imbuf.
Could be fixed in the operator instead, but I think the BKE function
is the correct place since the comment says it should take ownership
of the ImBuf.
Reviewers: sergey
Reviewed By: sergey
Differential Revision: https://developer.blender.org/D1084
===================================================================
M source/blender/blenkernel/intern/image.c
M source/blender/editors/sculpt_paint/paint_image_proj.c
===================================================================
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index 748d0d1..131a19b 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -803,7 +803,9 @@ Image *BKE_image_add_generated(Main *bmain, unsigned int width, unsigned int hei
return ima;
}
-/* creates an image image owns the imbuf passed */
+/* Create an image image from ibuf. The refcount of ibuf is increased,
+ * caller should take care to drop its reference by calling
+ * IMB_freeImBuf if needed. */
Image *BKE_image_add_from_imbuf(ImBuf *ibuf)
{
/* on save, type is changed to FILE in editsima.c */
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c
index ff82688..098477e 100644
--- a/source/blender/editors/sculpt_paint/paint_image_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.c
@@ -5136,6 +5136,9 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op)
image = BKE_image_add_from_imbuf(ibuf);
+ /* Drop reference to ibuf so that the image owns it */
+ IMB_freeImBuf(ibuf);
+
if (image) {
/* now for the trickyness. store the view projection here!
* re-projection will reuse this */
More information about the Bf-blender-cvs
mailing list