diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2017-07-14 12:16:25 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2017-07-14 12:42:31 +0300 |
commit | b48694639af41518a0e8c73da20121eda1685765 (patch) | |
tree | a131a37aff6664a24f4f43f36b93f16ccb6e3005 /source/blender/blenkernel/intern | |
parent | 018df5a49a4c68ff8aea15cd7586d72e6c36f8e6 (diff) |
Workspace: Fix crash on preview, and sanitize placeholder functions
This commit effectively makes workspace switching useless as far as the
active scene layer goes.
The functions from the scene layer API to get the correct scene layer
from "context" were a placeholder to be addressed by the workspace
commit.
When workspace was merged, however G.main was used as a replacement to pass the
correct argument for the functions. As it turned out (surprise!) this
leads to crash on render preview.
We need to get rid of:
* BKE_scene_layer_context_active_ex_PLACEHOLDER
* BKE_scene_layer_context_active_PLACEHOLDER
And either use SceneLayer explicitly or replace it by:
* BKE_scene_layer_from_workspace_get
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/DerivedMesh.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/blendfile.c | 5 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/context.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/effect.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/layer.c | 50 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/scene.c | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/sequencer.c | 2 |
7 files changed, 29 insertions, 38 deletions
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 49a219691bc..a26fdd85d52 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -2683,7 +2683,7 @@ static void editbmesh_build_data(Scene *scene, Object *obedit, BMEditMesh *em, C static CustomDataMask object_get_datamask(const Scene *scene, Object *ob, bool *r_need_mapping) { /* TODO(sergey): Avoid this linear list lookup. */ - SceneLayer *sl = BKE_scene_layer_context_active(scene); + SceneLayer *sl = BKE_scene_layer_context_active_PLACEHOLDER(scene); Object *actob = sl->basact ? sl->basact->object : NULL; CustomDataMask mask = ob->customdata_mask; diff --git a/source/blender/blenkernel/intern/blendfile.c b/source/blender/blenkernel/intern/blendfile.c index 53f2462ee98..5f88c4aec0e 100644 --- a/source/blender/blenkernel/intern/blendfile.c +++ b/source/blender/blenkernel/intern/blendfile.c @@ -193,7 +193,7 @@ static void setup_app_data( } if (cur_render_layer == NULL) { /* fallback to scene layer */ - cur_render_layer = BKE_scene_layer_render_active(curscene); + cur_render_layer = BKE_scene_layer_from_scene_get(curscene); } if (track_undo_scene) { @@ -335,7 +335,8 @@ static void setup_app_data( if (mode == LOAD_UI_OFF && BLI_listbase_is_empty(&G.main->wm)) { /* XXX prevent crash in pdInitEffectors called through DEG_scene_relations_rebuild (see T51794). - * Can be removed once BKE_scene_layer_context_active_ex gets workspace passed. */ + * Can be removed once BKE_scene_layer_context_active_ex_PLACEHOLDER gets + * replaced by BKE_scene_layer_from_workspace_get. */ BLI_addhead(&G.main->wm, CTX_wm_manager(C)); BKE_scene_set_background(G.main, curscene); BLI_listbase_clear(&G.main->wm); diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c index ffccc59171c..176d0718799 100644 --- a/source/blender/blenkernel/intern/context.c +++ b/source/blender/blenkernel/intern/context.c @@ -916,7 +916,7 @@ SceneLayer *CTX_data_scene_layer(const bContext *C) return sl; } else { - return BKE_scene_layer_context_active_ex(CTX_data_main(C), CTX_data_scene(C)); + return BKE_scene_layer_context_active_ex_PLACEHOLDER(CTX_data_main(C), CTX_data_scene(C)); } } diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index 2213094cd0b..8380588776b 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -210,7 +210,7 @@ static void add_particles_to_effectors(ListBase **effectors, Scene *scene, Effec ListBase *pdInitEffectors(Scene *scene, Object *ob_src, ParticleSystem *psys_src, EffectorWeights *weights, bool for_simulation) { - SceneLayer *sl = BKE_scene_layer_context_active(scene); /* Can't get sl from the calling modifiers yet */ + SceneLayer *sl = BKE_scene_layer_context_active_PLACEHOLDER(scene); /* Can't get sl from the calling modifiers yet */ Base *base; unsigned int layer= ob_src->lay; ListBase *effectors = NULL; diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c index a0250ac8dfc..3342c198ee1 100644 --- a/source/blender/blenkernel/intern/layer.c +++ b/source/blender/blenkernel/intern/layer.c @@ -69,9 +69,9 @@ static void object_bases_iterator_next(BLI_Iterator *iter, const int flag); /** * Returns the SceneLayer to be used for rendering - * Most of the time BKE_scene_layer_context_active should be used instead + * Most of the time BKE_scene_layer_from_workspace_get should be used instead */ -SceneLayer *BKE_scene_layer_render_active(const Scene *scene) +SceneLayer *BKE_scene_layer_from_scene_get(const Scene *scene) { SceneLayer *sl = BLI_findlink(&scene->render_layers, scene->active_layer); BLI_assert(sl); @@ -81,37 +81,27 @@ SceneLayer *BKE_scene_layer_render_active(const Scene *scene) /** * Returns the SceneLayer to be used for drawing, outliner, and other context related areas. */ -SceneLayer *BKE_scene_layer_context_active_ex(const Main *bmain, const Scene *scene) -{ - /* XXX We should really pass the workspace as argument, but would require - * some bigger changes since it's often not available where we call this. - * Just working around this by getting active window from WM for now */ - for (wmWindowManager *wm = bmain->wm.first; wm; wm = wm->id.next) { - /* Called on startup, so 'winactive' may not be set, in that case fall back to first window. */ - wmWindow *win = wm->winactive ? wm->winactive : wm->windows.first; - const WorkSpace *workspace = BKE_workspace_active_get(win->workspace_hook); - SceneLayer *scene_layer = BKE_workspace_render_layer_get(workspace); - if (scene_layer != NULL) { - /* NOTE: We never have copy-on-written main database, but we might - * be passing copy-on-write version of scene here. For that case - * we always ensure we are returning copy-on-write version of scene - * layer as well. - */ - - /* TODO(sergey): This will make an extra lookup for case when we - * pass original scene, but this function is to be rewritten - * anyway. - */ - scene_layer = BLI_findstring(&scene->render_layers, scene_layer->name, offsetof(SceneLayer, name)); - } - return scene_layer; - } +SceneLayer *BKE_scene_layer_from_workspace_get(const struct WorkSpace *workspace) +{ + return BKE_workspace_render_layer_get(workspace); +} - return NULL; +/** + * This is a placeholder to know which areas of the code need to be addressed for the Workspace changes. + * Never use this, you should either use BKE_scene_layer_workspace_active or get SceneLayer explicitly. + */ +SceneLayer *BKE_scene_layer_context_active_ex_PLACEHOLDER(const Main *UNUSED(bmain), const Scene *scene) +{ + return BKE_scene_layer_from_scene_get(scene); } -SceneLayer *BKE_scene_layer_context_active(const Scene *scene) + +/** + * This is a placeholder to know which areas of the code need to be addressed for the Workspace changes. + * Never use this, you should either use BKE_scene_layer_workspace_active or get SceneLayer explicitly. + */ +SceneLayer *BKE_scene_layer_context_active_PLACEHOLDER(const Scene *scene) { - return BKE_scene_layer_context_active_ex(G.main, scene); + return BKE_scene_layer_from_scene_get(scene); } /** diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 7b103a3c56e..b27fecce26b 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -1774,7 +1774,7 @@ Base *_setlooper_base_step(Scene **sce_iter, Base *base) /* first time looping, return the scenes first base */ /* for the first loop we should get the layer from context */ - SceneLayer *sl = BKE_scene_layer_context_active((*sce_iter)); + SceneLayer *sl = BKE_scene_layer_context_active_PLACEHOLDER((*sce_iter)); /* TODO For first scene (non-background set), we should pass the render layer as argument. * In some cases we want it to be the workspace one, in other the scene one. */ TODO_LAYER; @@ -1789,7 +1789,7 @@ Base *_setlooper_base_step(Scene **sce_iter, Base *base) next_set: /* reached the end, get the next base in the set */ while ((*sce_iter = (*sce_iter)->set)) { - SceneLayer *sl = BKE_scene_layer_render_active((*sce_iter)); + SceneLayer *sl = BKE_scene_layer_from_scene_get((*sce_iter)); base = (Base *)sl->object_bases.first; if (base) { diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index bebd3d64b44..6ddce874449 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -3306,7 +3306,7 @@ static ImBuf *seq_render_scene_strip(const SeqRenderData *context, Sequence *seq BKE_scene_update_for_newframe(context->eval_ctx, context->bmain, scene); ibuf = sequencer_view3d_cb( /* set for OpenGL render (NULL when scrubbing) */ - scene, BKE_scene_layer_render_active(scene), camera, width, height, IB_rect, + scene, BKE_scene_layer_from_scene_get(scene), camera, width, height, IB_rect, context->scene->r.seq_prev_type, (context->scene->r.seq_flag & R_SEQ_SOLID_TEX) != 0, use_gpencil, use_background, scene->r.alphamode, |