diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-06-07 22:33:48 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-06-08 12:15:40 +0300 |
commit | 0589a814ba0b6abc5323da69b92e2fd5f752065c (patch) | |
tree | 045e00f6b888594f225cea1ee0e335c03a11457f /source/blender | |
parent | 2ebaa6967675a201637dae26c5c67d1b5f8c3f26 (diff) |
Cycles: Fix crash doing render preview of external OSL script
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/include/ED_render.h | 2 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_icons.c | 2 | ||||
-rw-r--r-- | source/blender/editors/render/render_preview.c | 18 |
3 files changed, 15 insertions, 7 deletions
diff --git a/source/blender/editors/include/ED_render.h b/source/blender/editors/include/ED_render.h index 414126cac13..ba58ae60b15 100644 --- a/source/blender/editors/include/ED_render.h +++ b/source/blender/editors/include/ED_render.h @@ -74,7 +74,7 @@ void ED_preview_init_dbase(void); void ED_preview_free_dbase(void); void ED_preview_shader_job(const struct bContext *C, void *owner, struct ID *id, struct ID *parent, struct MTex *slot, int sizex, int sizey, int method); -void ED_preview_icon_render(struct Scene *scene, struct ID *id, unsigned int *rect, int sizex, int sizey); +void ED_preview_icon_render(struct Main *bmain, struct Scene *scene, struct ID *id, unsigned int *rect, int sizex, int sizey); void ED_preview_icon_job(const struct bContext *C, void *owner, struct ID *id, unsigned int *rect, int sizex, int sizey); void ED_preview_kill_jobs(struct wmWindowManager *wm, struct Main *bmain); diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index 492fd4c9a3a..ef246c5ac1f 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -995,7 +995,7 @@ static void icon_set_image( scene = CTX_data_scene(C); } /* Immediate version */ - ED_preview_icon_render(scene, id, prv_img->rect[size], prv_img->w[size], prv_img->h[size]); + ED_preview_icon_render(CTX_data_main(C), scene, id, prv_img->rect[size], prv_img->w[size], prv_img->h[size]); } } diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index 5112cd84d09..9ed0cec5545 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -161,6 +161,7 @@ typedef struct ShaderPreview { unsigned int *pr_rect; int pr_method; + Main *bmain; Main *pr_main; } ShaderPreview; @@ -171,6 +172,7 @@ typedef struct IconPreviewSize { } IconPreviewSize; typedef struct IconPreview { + Main *bmain; Scene *scene; void *owner; ID *id; @@ -261,12 +263,14 @@ static Scene *preview_get_scene(Main *pr_main) /* call this with a pointer to initialize preview scene */ /* call this with NULL to restore assigned ID pointers in preview scene */ -static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPreview *sp) +static Scene *preview_prepare_scene(Main *bmain, Scene *scene, ID *id, int id_type, ShaderPreview *sp) { Scene *sce; Base *base; Main *pr_main = sp->pr_main; - + + memcpy(pr_main->name, bmain->name, sizeof(pr_main->name)); + sce = preview_get_scene(pr_main); if (sce) { @@ -712,7 +716,7 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs } /* get the stuff from the builtin preview dbase */ - sce = preview_prepare_scene(sp->scene, id, idtype, sp); + sce = preview_prepare_scene(sp->bmain, sp->scene, id, idtype, sp); if (sce == NULL) return; if (!split || first) sprintf(name, "Preview %p", sp->owner); @@ -767,7 +771,7 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs } /* unassign the pointers, reset vars */ - preview_prepare_scene(sp->scene, NULL, GS(id->name), sp); + preview_prepare_scene(sp->bmain, sp->scene, NULL, GS(id->name), sp); /* XXX bad exception, end-exec is not being called in render, because it uses local main */ // if (idtype == ID_TE) { @@ -1075,6 +1079,7 @@ static void icon_preview_startjob_all_sizes(void *customdata, short *stop, short sp->pr_method = is_render ? PR_ICON_RENDER : PR_ICON_DEFERRED; sp->pr_rect = cur_size->rect; sp->id = ip->id; + sp->bmain = ip->bmain; if (is_render) { BLI_assert(ip->id); @@ -1135,12 +1140,13 @@ static void icon_preview_free(void *customdata) MEM_freeN(ip); } -void ED_preview_icon_render(Scene *scene, ID *id, unsigned int *rect, int sizex, int sizey) +void ED_preview_icon_render(Main *bmain, Scene *scene, ID *id, unsigned int *rect, int sizex, int sizey) { IconPreview ip = {NULL}; short stop = false, update = false; float progress = 0.0f; + ip.bmain = bmain; ip.scene = scene; ip.owner = id; ip.id = id; @@ -1171,6 +1177,7 @@ void ED_preview_icon_job(const bContext *C, void *owner, ID *id, unsigned int *r BLI_movelisttolist(&ip->sizes, &old_ip->sizes); /* customdata for preview thread */ + ip->bmain = CTX_data_main(C); ip->scene = CTX_data_scene(C); ip->owner = owner; ip->id = id; @@ -1212,6 +1219,7 @@ void ED_preview_shader_job(const bContext *C, void *owner, ID *id, ID *parent, M sp->id = id; sp->parent = parent; sp->slot = slot; + sp->bmain = CTX_data_main(C); /* hardcoded preview .blend for cycles/internal, this should be solved * once with custom preview .blend path for external engines */ |