diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-10-04 16:30:00 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-10-04 16:30:00 +0400 |
commit | 8cdeba8d67a4af89d57bec21b313817311e65883 (patch) | |
tree | a139ca5c998a30106eed1285603031bd361f2e7c /source/blender | |
parent | 865fe764dc4d027ad80f03b30a6f741f46c3d675 (diff) |
Fix #36948: blender internal viewport render crashes holding shift+Z pressed
to quickly toggle it on/off.
Problem is accessing freed data, now the job is ended immediately. Fix based
on patch from Sergey and investigation from Bastien.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/include/ED_render.h | 2 | ||||
-rw-r--r-- | source/blender/editors/include/ED_view3d.h | 3 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/space_view3d.c | 20 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_view.c | 11 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_space.c | 15 |
5 files changed, 30 insertions, 21 deletions
diff --git a/source/blender/editors/include/ED_render.h b/source/blender/editors/include/ED_render.h index bdfbbbb9c74..518bee665ae 100644 --- a/source/blender/editors/include/ED_render.h +++ b/source/blender/editors/include/ED_render.h @@ -40,6 +40,7 @@ struct Scene; struct ScrArea; struct RegionView3D; struct RenderEngine; +struct View3D; /* render_ops.c */ @@ -51,6 +52,7 @@ 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); +void ED_render_view3d_shade_update(struct Main *bmain, struct View3D *v3d, struct ScrArea *sa); void ED_viewport_render_kill_jobs(const struct bContext *C, bool free_database); diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index ce9d3af3013..86abf29c308 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -336,4 +336,7 @@ void ED_view3d_operator_properties_viewmat_set(struct bContext *C, struct wmOper void ED_view3d_operator_properties_viewmat_get(struct wmOperator *op, int *winx, int *winy, float persmat[4][4]); #endif +/* render */ +void ED_view3d_shade_update(struct Main *bmain, struct View3D *v3d, struct ScrArea *sa); + #endif /* __ED_VIEW3D_H__ */ diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 6c61c2af816..58c0df6b6bd 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -44,6 +44,7 @@ #include "BKE_context.h" #include "BKE_icons.h" +#include "BKE_main.h" #include "BKE_object.h" #include "BKE_screen.h" @@ -258,6 +259,25 @@ void ED_view3d_check_mats_rv3d(struct RegionView3D *rv3d) } #endif +void ED_view3d_shade_update(Main *bmain, View3D *v3d, ScrArea *sa) +{ + wmWindowManager *wm = bmain->wm.first; + + if (v3d->drawtype != OB_RENDER) { + ARegion *ar; + + for (ar = sa->regionbase.first; ar; ar = ar->next) { + RegionView3D *rv3d = ar->regiondata; + + if (rv3d && rv3d->render_engine) { + WM_jobs_kill_type(wm, ar, WM_JOB_TYPE_RENDER_PREVIEW); + RE_engine_free(rv3d->render_engine); + rv3d->render_engine = NULL; + } + } + } +} + /* ******************** default callbacks for view3d space ***************** */ static SpaceLink *view3d_new(const bContext *C) diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 388d83d3208..74d72061995 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -1180,7 +1180,7 @@ static bool view3d_localview_init(Main *bmain, Scene *scene, ScrArea *sa, Report return ok; } -static void restore_localviewdata(ScrArea *sa, int free) +static void restore_localviewdata(Main *bmain, ScrArea *sa, int free) { ARegion *ar; View3D *v3d = sa->spacedata.first; @@ -1217,12 +1217,7 @@ static void restore_localviewdata(ScrArea *sa, int free) } } - if (v3d->drawtype != OB_RENDER) { - if (rv3d->render_engine) { - RE_engine_free(rv3d->render_engine); - rv3d->render_engine = NULL; - } - } + ED_view3d_shade_update(bmain, v3d, sa); } } } @@ -1237,7 +1232,7 @@ static bool view3d_localview_exit(Main *bmain, Scene *scene, ScrArea *sa) locallay = v3d->lay & 0xFF000000; - restore_localviewdata(sa, 1); /* 1 = free */ + restore_localviewdata(bmain, sa, 1); /* 1 = free */ /* for when in other window the layers have changed */ if (v3d->scenelock) v3d->lay = scene->lay; diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 4f1c4e212b7..d494d6ae1cb 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -406,23 +406,12 @@ static void rna_SpaceView3D_layer_update(Main *bmain, Scene *UNUSED(scene), Poin DAG_on_visible_update(bmain, FALSE); } -static void rna_SpaceView3D_viewport_shade_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) +static void rna_SpaceView3D_viewport_shade_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) { View3D *v3d = (View3D *)(ptr->data); ScrArea *sa = rna_area_from_space(ptr); - if (v3d->drawtype != OB_RENDER) { - ARegion *ar; - - for (ar = sa->regionbase.first; ar; ar = ar->next) { - RegionView3D *rv3d = ar->regiondata; - - if (rv3d && rv3d->render_engine) { - RE_engine_free(rv3d->render_engine); - rv3d->render_engine = NULL; - } - } - } + ED_view3d_shade_update(bmain, v3d, sa); } static void rna_SpaceView3D_matcap_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) |