Commit: 008474521e41ac82009363487481bce901241832 Author: Dalai Felinto Date: Wed Sep 10 23:10:48 2014 +0200 Branches: multiview https://developer.blender.org/rB008474521e41ac82009363487481bce901241832
Fix unfreed memory when RenderResult were requested to be filled with all views =================================================================== M source/blender/render/extern/include/RE_pipeline.h M source/blender/render/intern/source/pipeline.c M source/blender/render/intern/source/render_result.c =================================================================== diff --git a/source/blender/render/extern/include/RE_pipeline.h b/source/blender/render/extern/include/RE_pipeline.h index 7f17281..fcb164b 100644 --- a/source/blender/render/extern/include/RE_pipeline.h +++ b/source/blender/render/extern/include/RE_pipeline.h @@ -208,8 +208,9 @@ void RE_FreeRenderResult(struct RenderResult *rr); struct RenderResult *RE_AcquireResultRead(struct Render *re); struct RenderResult *RE_AcquireResultWrite(struct Render *re); void RE_ReleaseResult(struct Render *re); +void RE_AcquireResultImageViews(struct Render *re, struct RenderResult *rr); +void RE_ReleaseResultImageViews(struct Render *re, struct RenderResult *rr); void RE_AcquireResultImage(struct Render *re, struct RenderResult *rr, const int view_id); -void RE_AcquireResultViews(struct Render *re, struct RenderResult *rr); void RE_ReleaseResultImage(struct Render *re); void RE_SwapResult(struct Render *re, struct RenderResult **rr); struct RenderStats *RE_GetStats(struct Render *re); diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 13e7743..b71f062 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -319,9 +319,10 @@ Scene *RE_GetScene(Render *re) return NULL; } -/* fill provided result struct with a COPY of thew views of what is done so far - * remember to free the RenderResult.views ListBase after using the renderresult */ -void RE_AcquireResultViews(Render *re, RenderResult *rr) +/* Same as RE_AcquireResultImage but creating the necessary views to store the result + * fill provided result struct with a copy of thew views of what is done so far the + * RenderResult.views ListBase needs to be freed after with RE_ReleaseResultViews */ +void RE_AcquireResultImageViews(Render *re, RenderResult *rr) { memset(rr, 0, sizeof(RenderResult)); @@ -364,13 +365,20 @@ void RE_AcquireResultViews(Render *re, RenderResult *rr) } } +/* clear temporary renderresult struct */ +void RE_ReleaseResultImageViews(Render *re, RenderResult *rr) +{ + if (re) { + if (rr) { + render_result_views_shallowdelete(rr); + } + BLI_rw_mutex_unlock(&re->resultmutex); + } +} + /* fill provided result struct with what's currently active or done */ void RE_AcquireResultImage(Render *re, RenderResult *rr, const int view_id) { - /* deal with special case separatedly */ - if (view_id == -1) - return RE_AcquireResultViews(re, rr); - memset(rr, 0, sizeof(RenderResult)); if (re) { @@ -3297,7 +3305,7 @@ static int do_write_image_or_movie(Render *re, Main *bmain, Scene *scene, bMovie double render_time; bool ok = true; - RE_AcquireResultImage(re, &rres, -1); + RE_AcquireResultImageViews(re, &rres); /* write movie or image */ if (BKE_imtype_is_movie(scene->r.im_format.imtype)) { @@ -3314,7 +3322,7 @@ static int do_write_image_or_movie(Render *re, Main *bmain, Scene *scene, bMovie ok = RE_WriteRenderViewsImage(re->reports, &rres, scene, true, name); } - RE_ReleaseResultImage(re); + RE_ReleaseResultImageViews(re, &rres); render_time = re->i.lastframetime; re->i.lastframetime = PIL_check_seconds_timer() - re->i.starttime; diff --git a/source/blender/render/intern/source/render_result.c b/source/blender/render/intern/source/render_result.c index e8fd13f..0f029e8 100644 --- a/source/blender/render/intern/source/render_result.c +++ b/source/blender/render/intern/source/render_result.c @@ -169,7 +169,7 @@ void render_result_views_shallowcopy(RenderResult *dst, RenderResult *src) for (rview = (RenderView *)src->views.first; rview; rview = rview->next) { RenderView *rv; - rv = MEM_callocN(sizeof(RenderView), "new render view"); + rv = MEM_mallocN(sizeof(RenderView), "new render view"); BLI_addtail(&dst->views, rv); BLI_strncpy(rv->name, rview->name, sizeof(rv->name)); _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs