Fix #33241: can't exit edit mode when object gets hidden via animation.

This commit is contained in:
2012-11-21 03:33:34 +00:00
parent 3fd388fb06
commit f68b550587
3 changed files with 21 additions and 9 deletions

View File

@@ -550,7 +550,8 @@ static int editmode_toggle_poll(bContext *C)
if (ELEM(NULL, ob, ob->data) || ((ID *)ob->data)->lib)
return 0;
if (ob->restrictflag & OB_RESTRICT_VIEW)
/* if hidden but in edit mode, we still display */
if ((ob->restrictflag & OB_RESTRICT_VIEW) && !(ob->mode & OB_MODE_EDIT))
return 0;
return (ob->type == OB_MESH || ob->type == OB_ARMATURE ||

View File

@@ -293,29 +293,35 @@ int ED_operator_console_active(bContext *C)
return ed_spacetype_test(C, SPACE_CONSOLE);
}
static int ed_object_hidden(Object *ob)
{
/* if hidden but in edit mode, we still display, can happen with animation */
return ((ob->restrictflag & OB_RESTRICT_VIEW) && !(ob->mode & OB_MODE_EDIT));
}
int ED_operator_object_active(bContext *C)
{
Object *ob = ED_object_active_context(C);
return ((ob != NULL) && !(ob->restrictflag & OB_RESTRICT_VIEW));
return ((ob != NULL) && !ed_object_hidden(ob));
}
int ED_operator_object_active_editable(bContext *C)
{
Object *ob = ED_object_active_context(C);
return ((ob != NULL) && !(ob->id.lib) && !(ob->restrictflag & OB_RESTRICT_VIEW));
return ((ob != NULL) && !(ob->id.lib) && !ed_object_hidden(ob));
}
int ED_operator_object_active_editable_mesh(bContext *C)
{
Object *ob = ED_object_active_context(C);
return ((ob != NULL) && !(ob->id.lib) && !(ob->restrictflag & OB_RESTRICT_VIEW) &&
return ((ob != NULL) && !(ob->id.lib) && !ed_object_hidden(ob) &&
(ob->type == OB_MESH) && !(((ID *)ob->data)->lib));
}
int ED_operator_object_active_editable_font(bContext *C)
{
Object *ob = ED_object_active_context(C);
return ((ob != NULL) && !(ob->id.lib) && !(ob->restrictflag & OB_RESTRICT_VIEW) &&
return ((ob != NULL) && !(ob->id.lib) && !ed_object_hidden(ob) &&
(ob->type == OB_FONT));
}

View File

@@ -1119,16 +1119,21 @@ static int view3d_context(const bContext *C, const char *member, bContextDataRes
return 1;
}
else if (CTX_data_equals(member, "active_base")) {
if (scene->basact && (scene->basact->lay & lay))
if ((scene->basact->object->restrictflag & OB_RESTRICT_VIEW) == 0)
if (scene->basact && (scene->basact->lay & lay)) {
Object *ob = scene->basact->object;
/* if hidden but in edit mode, we still display, can happen with animation */
if ((ob->restrictflag & OB_RESTRICT_VIEW) == 0 || (ob->mode & OB_MODE_EDIT))
CTX_data_pointer_set(result, &scene->id, &RNA_ObjectBase, scene->basact);
}
return 1;
}
else if (CTX_data_equals(member, "active_object")) {
if (scene->basact && (scene->basact->lay & lay))
if ((scene->basact->object->restrictflag & OB_RESTRICT_VIEW) == 0)
if (scene->basact && (scene->basact->lay & lay)) {
Object *ob = scene->basact->object;
if ((ob->restrictflag & OB_RESTRICT_VIEW) == 0 || (ob->mode & OB_MODE_EDIT))
CTX_data_id_pointer_set(result, &scene->basact->object->id);
}
return 1;
}