Object: avoid calling operators in ED_editors_init

Don't call operator when entering sculpt modes.
This commit is contained in:
Campbell Barton
2019-01-16 11:46:55 +11:00
parent 976917e8cf
commit 5861e1fa28

View File

@@ -90,6 +90,7 @@
void ED_editors_init(bContext *C)
{
struct Depsgraph *depsgraph = CTX_data_depsgraph(C);
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
wmWindowManager *wm = CTX_wm_manager(C);
@@ -111,43 +112,65 @@ void ED_editors_init(bContext *C)
if (obact != NULL) {
for (Object *ob = bmain->object.first; ob; ob = ob->id.next) {
int mode = ob->mode;
if (mode == OB_MODE_OBJECT) {
/* pass */
continue;
}
else if (!BKE_object_has_mode_data(ob, mode)) {
else if (BKE_object_has_mode_data(ob, mode)) {
continue;
}
else if (ob->type == OB_GPENCIL) {
/* For multi-edit mode we may already have mode data.
* (grease pencil does not need it)
*/
if (ob->type != OB_GPENCIL) {
ID *data = ob->data;
ob->mode = OB_MODE_OBJECT;
if ((ob->type == obact->type) && !ID_IS_LINKED(ob) && !(data && ID_IS_LINKED(data))) {
if (mode == OB_MODE_EDIT) {
ED_object_editmode_enter_ex(bmain, scene, ob, 0);
* (grease pencil does not need it) */
continue;
}
ID *ob_data = ob->data;
ob->mode = OB_MODE_OBJECT;
if ((ob->type == obact->type) &&
!ID_IS_LINKED(ob) &&
!(ob_data && ID_IS_LINKED(ob_data)))
{
if (mode == OB_MODE_EDIT) {
ED_object_editmode_enter_ex(bmain, scene, ob, 0);
}
else if (mode == OB_MODE_POSE) {
ED_object_posemode_enter_ex(bmain, ob);
}
else if (mode & OB_MODE_ALL_SCULPT) {
if (obact == ob) {
if (mode == OB_MODE_SCULPT) {
ED_object_sculptmode_enter_ex(bmain, depsgraph, scene, ob, reports);
}
else if (mode == OB_MODE_POSE) {
ED_object_posemode_enter_ex(bmain, ob);
else if (mode == OB_MODE_VERTEX_PAINT) {
ED_object_vpaintmode_enter_ex(bmain, depsgraph, wm, scene, ob);
}
else if (mode == OB_MODE_WEIGHT_PAINT) {
ED_object_wpaintmode_enter_ex(bmain, depsgraph, wm, scene, ob);
}
else {
if (obact == ob) {
ED_object_mode_toggle(C, mode);
}
else {
/* Create data for non-active objects which need it for
* mode-switching but don't yet support multi-editing. */
if (mode & OB_MODE_ALL_SCULPT) {
ob->mode = mode;
BKE_object_sculpt_data_create(ob);
}
}
BLI_assert(0);
}
}
else {
/* Create data for non-active objects which need it for
* mode-switching but don't yet support multi-editing. */
if (mode & OB_MODE_ALL_SCULPT) {
ob->mode = mode;
BKE_object_sculpt_data_create(ob);
}
}
}
else {
/* TODO(campbell): avoid operator calls. */
if (obact == ob) {
ED_object_mode_toggle(C, mode);
}
}
}
}
}
/* image editor paint mode */
if (scene) {
ED_space_image_paint_update(bmain, wm, scene);