Merged changes in the trunk up to revision 52191.
[blender-staging.git] / source / blender / render / intern / source / pipeline.c
index aab7f442249f8cf6352ed55604b53fc7cf6ecb6c..23065e5bd84333939cb7f7cf6a3324799983ec42 100644 (file)
@@ -435,7 +435,10 @@ void RE_FreePersistentData(void)
        /* render engines can be kept around for quick re-render, this clears all */
        for (re = RenderGlobal.renderlist.first; re; re = re->next) {
                if (re->engine) {
-                       RE_engine_free(re->engine);
+                       /* if engine is currently rendering, just tag it to be freed when render is finished */
+                       if (!(re->engine->flag & RE_ENGINE_RENDERING))
+                               RE_engine_free(re->engine);
+
                        re->engine = NULL;
                }
        }