[Bf-blender-cvs] [4f321a33739] master: Fix crash unlinking non-ID types in the outliner

Campbell Barton noreply at git.blender.org
Tue Jul 2 00:49:42 CEST 2019


Commit: 4f321a33739cdb43c3325696d5853cb251e45b1c
Author: Campbell Barton
Date:   Tue Jul 2 08:44:03 2019 +1000
Branches: master
https://developer.blender.org/rB4f321a33739cdb43c3325696d5853cb251e45b1c

Fix crash unlinking non-ID types in the outliner

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

M	source/blender/editors/space_outliner/outliner_tools.c

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

diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c
index e1e7bf49606..a618f8ef4c2 100644
--- a/source/blender/editors/space_outliner/outliner_tools.c
+++ b/source/blender/editors/space_outliner/outliner_tools.c
@@ -288,31 +288,33 @@ static void unlink_object_cb(bContext *C,
                              TreeStoreElem *tselem,
                              void *UNUSED(user_data))
 {
-  Main *bmain = CTX_data_main(C);
-  Object *ob = (Object *)tselem->id;
+  if (tsep && tsep->id) {
+    Main *bmain = CTX_data_main(C);
+    Object *ob = (Object *)tselem->id;
 
-  if (GS(tsep->id->name) == ID_OB) {
-    /* Parented objects need to find which collection to unlink from. */
-    TreeElement *te_parent = te->parent;
-    while (tsep && GS(tsep->id->name) == ID_OB) {
-      te_parent = te_parent->parent;
-      tsep = te_parent ? TREESTORE(te_parent) : NULL;
+    if (GS(tsep->id->name) == ID_OB) {
+      /* Parented objects need to find which collection to unlink from. */
+      TreeElement *te_parent = te->parent;
+      while (tsep && GS(tsep->id->name) == ID_OB) {
+        te_parent = te_parent->parent;
+        tsep = te_parent ? TREESTORE(te_parent) : NULL;
+      }
     }
-  }
 
-  if (tsep) {
-    if (GS(tsep->id->name) == ID_GR) {
-      Collection *parent = (Collection *)tsep->id;
-      BKE_collection_object_remove(bmain, parent, ob, true);
-      DEG_id_tag_update(&parent->id, ID_RECALC_COPY_ON_WRITE);
-      DEG_relations_tag_update(bmain);
-    }
-    else if (GS(tsep->id->name) == ID_SCE) {
-      Scene *scene = (Scene *)tsep->id;
-      Collection *parent = BKE_collection_master(scene);
-      BKE_collection_object_remove(bmain, parent, ob, true);
-      DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
-      DEG_relations_tag_update(bmain);
+    if (tsep && tsep->id) {
+      if (GS(tsep->id->name) == ID_GR) {
+        Collection *parent = (Collection *)tsep->id;
+        BKE_collection_object_remove(bmain, parent, ob, true);
+        DEG_id_tag_update(&parent->id, ID_RECALC_COPY_ON_WRITE);
+        DEG_relations_tag_update(bmain);
+      }
+      else if (GS(tsep->id->name) == ID_SCE) {
+        Scene *scene = (Scene *)tsep->id;
+        Collection *parent = BKE_collection_master(scene);
+        BKE_collection_object_remove(bmain, parent, ob, true);
+        DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
+        DEG_relations_tag_update(bmain);
+      }
     }
   }
 }



More information about the Bf-blender-cvs mailing list