[Bf-blender-cvs] [26b23231893] master: Fix memory leak when saving OpenEXR files
Sergey Sharybin
noreply at git.blender.org
Tue May 16 15:36:38 CEST 2017
Commit: 26b232318930739a73d88afc9aaca7992301f03a
Author: Sergey Sharybin
Date: Tue May 16 15:34:43 2017 +0200
Branches: master
https://developer.blender.org/rB26b232318930739a73d88afc9aaca7992301f03a
Fix memory leak when saving OpenEXR files
It is not a good idea to:
1. Duplicate metadata to self
2. Ignore the fact that something might have had metadata already.
Also moved metadata copy to a preparation function, so it is
never lost.
===================================================================
M source/blender/editors/space_image/image_ops.c
M source/blender/imbuf/intern/colormanagement.c
M source/blender/imbuf/intern/metadata.c
===================================================================
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index d00ebed5bcc..c2cfca295a4 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -1890,7 +1890,6 @@ static bool save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI
}
else {
colormanaged_ibuf = IMB_colormanagement_imbuf_for_write(ibuf, save_as_render, true, &imf->view_settings, &imf->display_settings, imf);
- IMB_metadata_copy(colormanaged_ibuf, ibuf);
ok = BKE_imbuf_write_as(colormanaged_ibuf, simopts->filepath, imf, save_copy);
save_imbuf_post(ibuf, colormanaged_ibuf);
}
diff --git a/source/blender/imbuf/intern/colormanagement.c b/source/blender/imbuf/intern/colormanagement.c
index cdb8f2c6fa2..a4d5da9993a 100644
--- a/source/blender/imbuf/intern/colormanagement.c
+++ b/source/blender/imbuf/intern/colormanagement.c
@@ -2065,6 +2065,10 @@ ImBuf *IMB_colormanagement_imbuf_for_write(ImBuf *ibuf, bool save_as_render, boo
}
}
+ if (colormanaged_ibuf != ibuf) {
+ IMB_metadata_copy(colormanaged_ibuf, ibuf);
+ }
+
return colormanaged_ibuf;
}
diff --git a/source/blender/imbuf/intern/metadata.c b/source/blender/imbuf/intern/metadata.c
index 134bbe88f15..d48aec0ba4c 100644
--- a/source/blender/imbuf/intern/metadata.c
+++ b/source/blender/imbuf/intern/metadata.c
@@ -81,7 +81,9 @@ bool IMB_metadata_get_field(struct ImBuf *img, const char *key, char *field, con
void IMB_metadata_copy(struct ImBuf *dimb, struct ImBuf *simb)
{
+ BLI_assert(dimb != simb);
if (simb->metadata) {
+ IDP_FreeProperty(dimb->metadata);
dimb->metadata = IDP_CopyProperty(simb->metadata);
}
}
More information about the Bf-blender-cvs
mailing list