Fix error with Main.eval_ctx.object_mode being unset

This made vertex/weight/sculpt crash.

Add BKE_workspace_update_object_mode which sets the object mode from the
workspace.

We may want to re-visit exactly when this is set, for now call within
wm_event_do_refresh_wm_and_depsgraph.
This commit is contained in:
Campbell Barton 2018-02-07 18:33:19 +11:00
parent 17f5d7f3c5
commit da128c12b5
3 changed files with 24 additions and 0 deletions

View File

@ -149,6 +149,11 @@ void BKE_workspace_update_tagged(struct EvaluationContext *eval_ctx,
struct WorkSpace *workspace,
struct Scene *scene);
void BKE_workspace_update_object_mode(
struct EvaluationContext *eval_ctx,
struct WorkSpace *workspace,
struct Scene *scene);
#undef GETTER_ATTRS
#undef SETTER_ATTRS

View File

@ -45,6 +45,8 @@
#include "DNA_screen_types.h"
#include "DNA_workspace_types.h"
#include "DEG_depsgraph.h"
#include "MEM_guardedalloc.h"
@ -521,3 +523,17 @@ void BKE_workspace_update_tagged(struct EvaluationContext *eval_ctx,
true);
BKE_scene_graph_update_tagged(eval_ctx, depsgraph, bmain, scene, view_layer);
}
void BKE_workspace_update_object_mode(
struct EvaluationContext *eval_ctx,
WorkSpace *workspace, Scene *scene)
{
ViewLayer *view_layer = BKE_workspace_view_layer_get(workspace, scene);
/* TODO(campbell): Investigate how this should work exactly,
* for now without this 'bmain->eval_ctx' is never set. */
{
Object *ob = view_layer->basact ? view_layer->basact->object : NULL;
eval_ctx->object_mode = ob ? (eObjectMode)ob->mode : OB_MODE_OBJECT;
}
}

View File

@ -339,6 +339,9 @@ void wm_event_do_refresh_wm_and_depsgraph(bContext *C)
scene->customdata_mask |= scene->customdata_mask_modal;
WorkSpace *workspace = WM_window_get_active_workspace(win);
BKE_workspace_update_object_mode(bmain->eval_ctx, workspace, scene);
BKE_workspace_update_tagged(bmain->eval_ctx, bmain, workspace, scene);
}
}