Fix #33241: can't exit edit mode when object gets hidden via animation.
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Wed, 21 Nov 2012 03:33:34 +0000 (03:33 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Wed, 21 Nov 2012 03:33:34 +0000 (03:33 +0000)
source/blender/editors/object/object_edit.c
source/blender/editors/screen/screen_ops.c
source/blender/editors/space_view3d/space_view3d.c

index 4d6b9ed10bb1ce6720023762017fc1a01c881fda..d39e34824b94f92328d143f74152fa1105842eca 100644 (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 ||
index 6a9c24d2913b8f5c872e3be4f529b1fe22fb9f20..67d4af916aa21123f43b27687327fffa54fac5dd 100644 (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));
 }
 
index ec564e95c6595d5546ce190c59e6be39fcfac030..4964c0054ac8803eba05f6ff631ac2545a03d53c 100644 (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;
        }