[Bf-blender-cvs] [2b60d7d09c5] master: Fix entering edit-mode when object mode and edit-data don't match

Campbell Barton noreply at git.blender.org
Thu Feb 25 06:14:54 CET 2021


Commit: 2b60d7d09c51716e8d98834061c1a61ed6b96cf5
Author: Campbell Barton
Date:   Thu Feb 25 15:38:57 2021 +1100
Branches: master
https://developer.blender.org/rB2b60d7d09c51716e8d98834061c1a61ed6b96cf5

Fix entering edit-mode when object mode and edit-data don't match

In rare cases, it's possible for an object to have edit-mode data
without it's Object.mode set to edit-mode.

This could happen with undo, part of fix for: T85974.

===================================================================

M	source/blender/editors/object/object_edit.c

===================================================================

diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index 4cf49d262ca..da14d4ef52a 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -718,20 +718,26 @@ bool ED_object_editmode_enter_ex(Main *bmain, Scene *scene, Object *ob, int flag
     return false;
   }
 
-  /* this checks actual object->data, for cases when other scenes have it in editmode context */
-  if (BKE_object_is_in_editmode(ob)) {
-    return true;
-  }
-
   if (BKE_object_obdata_is_libdata(ob)) {
     /* Ideally the caller should check this. */
     CLOG_WARN(&LOG, "Unable to enter edit-mode on library data for object '%s'", ob->id.name + 2);
     return false;
   }
 
-  ob->restore_mode = ob->mode;
+  if ((ob->mode & OB_MODE_EDIT) == 0) {
+    ob->restore_mode = ob->mode;
+
+    ob->mode = OB_MODE_EDIT;
+  }
 
-  ob->mode = OB_MODE_EDIT;
+  /* This checks actual `object->data`,
+   * for cases when other scenes have it in edit-mode context.
+   *
+   * It's important to run this after setting the object's mode (above), since in rare cases
+   * the object may have the edit-data but not it's object-mode set. See T85974. */
+  if (BKE_object_is_in_editmode(ob)) {
+    return true;
+  }
 
   if (ob->type == OB_MESH) {
     ok = true;



More information about the Bf-blender-cvs mailing list