[Bf-blender-cvs] [6a155646823] master: Fix T65420: Crash in file saved with edit mesh

Dalai Felinto noreply at git.blender.org
Sat Jun 8 00:17:49 CEST 2019


Commit: 6a155646823024569c129e8bdcb55fb2de9b958e
Author: Dalai Felinto
Date:   Fri Jun 7 17:15:52 2019 -0300
Branches: master
https://developer.blender.org/rB6a155646823024569c129e8bdcb55fb2de9b958e

Fix T65420: Crash in file saved with edit mesh

Reviewers: brecht, sergey

Differential Revision: https://developer.blender.org/D5041

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

M	source/blender/editors/util/ed_util.c

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

diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c
index df1906ea8a8..c23e004b306 100644
--- a/source/blender/editors/util/ed_util.c
+++ b/source/blender/editors/util/ed_util.c
@@ -54,6 +54,8 @@
 #include "BKE_workspace.h"
 #include "BKE_material.h"
 
+#include "DEG_depsgraph.h"
+
 #include "ED_armature.h"
 #include "ED_buttons.h"
 #include "ED_image.h"
@@ -115,61 +117,61 @@ void ED_editors_init(bContext *C)
    * e.g. linked objects we have to ensure that they are actually the
    * active object in this scene. */
   Object *obact = CTX_data_active_object(C);
-  if (obact != NULL) {
-    for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
-      int mode = ob->mode;
-      if (mode == OB_MODE_OBJECT) {
-        continue;
-      }
-      else if (BKE_object_has_mode_data(ob, mode)) {
-        continue;
+  for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
+    int mode = ob->mode;
+    if (mode == OB_MODE_OBJECT) {
+      continue;
+    }
+    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) */
+      continue;
+    }
+
+    ID *ob_data = ob->data;
+    ob->mode = OB_MODE_OBJECT;
+    DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE);
+    if (obact && (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 (ob->type == OB_GPENCIL) {
-        /* For multi-edit mode we may already have mode data.
-         * (grease pencil does not need it) */
-        continue;
+      else if (mode == OB_MODE_POSE) {
+        ED_object_posemode_enter_ex(bmain, ob);
       }
-
-      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, true, reports);
-            }
-            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 {
-              BLI_assert(0);
-            }
+      else if (mode & OB_MODE_ALL_SCULPT) {
+        if (obact == ob) {
+          if (mode == OB_MODE_SCULPT) {
+            ED_object_sculptmode_enter_ex(bmain, depsgraph, scene, ob, true, reports);
+          }
+          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 {
-            /* 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 {
-          /* TODO(campbell): avoid operator calls. */
-          if (obact == ob) {
-            ED_object_mode_toggle(C, mode);
+          /* 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);
+        }
+      }
     }
   }



More information about the Bf-blender-cvs mailing list