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.
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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__ */
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -335,6 +335,7 @@ void ED_view3D_background_image_remove(struct View3D *v3d, struct BGpic *bgpic)
|
||||
void ED_view3D_background_image_clear(struct View3D *v3d) {STUB_ASSERT(0);}
|
||||
void ED_view3d_update_viewmat(struct Scene *scene, struct View3D *v3d, struct ARegion *ar, float viewmat[4][4], float winmat[4][4]) {STUB_ASSERT(0);}
|
||||
float ED_view3d_grid_scale(struct Scene *scene, struct View3D *v3d, const char **grid_unit) {STUB_ASSERT(0); return 0.0f;}
|
||||
void ED_view3d_shade_update(struct Main *bmain, struct View3D *v3d, struct ScrArea *sa) {STUB_ASSERT(0);}
|
||||
void view3d_apply_mat4(float mat[4][4], float *ofs, float *quat, float *dist) {STUB_ASSERT(0);}
|
||||
int text_file_modified(struct Text *text) {STUB_ASSERT(0); return 0;}
|
||||
void ED_node_shader_default(struct bContext *C, struct ID *id) {STUB_ASSERT(0);}
|
||||
|
||||
Reference in New Issue
Block a user