[Bf-blender-cvs] [9add7c35cc6] master: Fix (unreported) crash in outliner after recent changes to ID management core code.

Bastien Montagne noreply at git.blender.org
Wed Sep 22 14:37:05 CEST 2021


Commit: 9add7c35cc6818b28842dd1bcdd3081d35d7623b
Author: Bastien Montagne
Date:   Wed Sep 22 14:34:59 2021 +0200
Branches: master
https://developer.blender.org/rB9add7c35cc6818b28842dd1bcdd3081d35d7623b

Fix (unreported) crash in outliner after recent changes to ID management core  code.

Outliner tree building code abuse the `ID.newid` pointer to store non-ID
data. While this is bad and should be fixed at some point, for the time
being at the very least do not use ID BKE API to deal with this pointer
in that specific case, this needs its own proper code.

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

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

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

diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c
index c5ec656080a..5427ae31ac3 100644
--- a/source/blender/editors/space_outliner/outliner_tree.c
+++ b/source/blender/editors/space_outliner/outliner_tree.c
@@ -1864,6 +1864,15 @@ static void outliner_filter_tree(SpaceOutliner *space_outliner, ViewLayer *view_
       space_outliner, view_layer, &space_outliner->tree, search_string, exclude_filter);
 }
 
+static void outliner_clear_newid_from_main(Main *bmain)
+{
+  ID *id_iter;
+  FOREACH_MAIN_ID_BEGIN (bmain, id_iter) {
+    id_iter->newid = NULL;
+  }
+  FOREACH_MAIN_ID_END;
+}
+
 /* ======================================================= */
 /* Main Tree Building API */
 
@@ -1926,5 +1935,7 @@ void outliner_build_tree(Main *mainvar,
   outliner_filter_tree(space_outliner, view_layer);
   outliner_restore_scrolling_position(space_outliner, region, &focus);
 
-  BKE_main_id_newptr_and_tag_clear(mainvar);
+  /* `ID.newid` pointer is abused when building tree, DO NOT call #BKE_main_id_newptr_and_tag_clear
+   * as this expects valid IDs in this pointer, not random unknown data. */
+  outliner_clear_newid_from_main(mainvar);
 }



More information about the Bf-blender-cvs mailing list