Fix #31066: cycles keeps rendering in viewport after window closed.
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Thu, 26 Apr 2012 12:30:37 +0000 (12:30 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Thu, 26 Apr 2012 12:30:37 +0000 (12:30 +0000)
source/blender/editors/include/ED_render.h
source/blender/editors/render/render_update.c
source/blender/editors/screen/screen_edit.c

index 73bbd5ffef8da7e28f766dca5b4e001e421a3388..5392ef86ba7ae6dd237dbd0aa39eb243ff7b8ca4 100644 (file)
@@ -37,6 +37,7 @@ struct MTex;
 struct Render;
 struct RenderInfo;
 struct Scene;
+struct ScrArea;
 
 /* render_ops.c */
 
@@ -46,6 +47,7 @@ void ED_operatortypes_render(void);
 
 void ED_render_id_flush_update(struct Main *bmain, struct ID *id);
 void ED_render_engine_changed(struct Main *bmain);
+void ED_render_engine_area_exit(struct ScrArea *sa);
 void ED_render_scene_update(struct Main *bmain, struct Scene *scene, int updated);
 
 /* render_preview.c */
index 35b4126339e0486ffa41c3236101a2aa852b41de..48c35873304c19944c2f2d5279fb874f38a66315 100644 (file)
@@ -116,35 +116,40 @@ void ED_render_scene_update(Main *bmain, Scene *scene, int updated)
        CTX_free(C);
 }
 
-void ED_render_engine_changed(Main *bmain)
+void ED_render_engine_area_exit(ScrArea *sa)
 {
-       /* on changing the render engine type, clear all running render engines */
-       bScreen *sc;
-       ScrArea *sa;
+       /* clear all render engines in this area */
        ARegion *ar;
 
-       for (sc = bmain->screen.first; sc; sc = sc->id.next) {
-               for (sa = sc->areabase.first; sa; sa = sa->next) {
-                       if (sa->spacetype != SPACE_VIEW3D)
-                               continue;
+       if (sa->spacetype != SPACE_VIEW3D)
+               return;
 
-                       for (ar = sa->regionbase.first; ar; ar = ar->next) {
-                               RegionView3D *rv3d;
+       for (ar = sa->regionbase.first; ar; ar = ar->next) {
+               RegionView3D *rv3d;
 
-                               if (ar->regiontype != RGN_TYPE_WINDOW)
-                                       continue;
-                               
-                               rv3d = ar->regiondata;
+               if (ar->regiontype != RGN_TYPE_WINDOW)
+                       continue;
+               
+               rv3d = ar->regiondata;
 
-                               if (rv3d->render_engine) {
-                                       RE_engine_free(rv3d->render_engine);
-                                       rv3d->render_engine = NULL;
-                               }
-                       }
+               if (rv3d->render_engine) {
+                       RE_engine_free(rv3d->render_engine);
+                       rv3d->render_engine = NULL;
                }
        }
 }
 
+void ED_render_engine_changed(Main *bmain)
+{
+       /* on changing the render engine type, clear all running render engines */
+       bScreen *sc;
+       ScrArea *sa;
+
+       for (sc = bmain->screen.first; sc; sc = sc->id.next)
+               for (sa = sc->areabase.first; sa; sa = sa->next)
+                       ED_render_engine_area_exit(sa);
+}
+
 /***************************** Updates ***********************************
  * ED_render_id_flush_update gets called from DAG_id_tag_update, to do   *
  * editor level updates when the ID changes. when these ID blocks are in *
index 03d8b3d3e9ccaab645697b02ae74e7f27b27046f..cafa4527c20eb9f3aa8a781d978115a6d8e0b7f0 100644 (file)
@@ -1154,6 +1154,9 @@ void ED_area_exit(bContext *C, ScrArea *sa)
                        ED_fileselect_exit(C, (SpaceFile *)sl);
                }
        }
+       else if (sa->spacetype == SPACE_VIEW3D) {
+               ED_render_engine_area_exit(sa);
+       }
 
        CTX_wm_area_set(C, sa);
        for (ar= sa->regionbase.first; ar; ar= ar->next)