[Bf-blender-cvs] [b6d890672c5] master: Fix crash in 'drag asset' case in new append code from yesterday.

Bastien Montagne noreply at git.blender.org
Wed Sep 15 18:47:42 CEST 2021


Commit: b6d890672c5fcc7a970d0475a9bdb0d44950ad50
Author: Bastien Montagne
Date:   Wed Sep 15 18:45:11 2021 +0200
Branches: master
https://developer.blender.org/rBb6d890672c5fcc7a970d0475a9bdb0d44950ad50

Fix crash in 'drag asset' case in new append code from yesterday.

Scene and related pointer parameter can be NULL in link/append code, in
which case there is no instantiation of new objects/collections/obdata.

Link code in blendloader was already checking that, new instantiation
code in WM area from yesterday did not.

Issue introduced by rB3be5ce4aad5e.

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

M	source/blender/windowmanager/intern/wm_files_link.c

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

diff --git a/source/blender/windowmanager/intern/wm_files_link.c b/source/blender/windowmanager/intern/wm_files_link.c
index 2416f5b50b3..7568c9989a8 100644
--- a/source/blender/windowmanager/intern/wm_files_link.c
+++ b/source/blender/windowmanager/intern/wm_files_link.c
@@ -383,6 +383,12 @@ static void wm_append_loose_data_instantiate(WMLinkAppendData *lapp_data,
                                              ViewLayer *view_layer,
                                              const View3D *v3d)
 {
+  if (scene == NULL) {
+    /* In some cases, like the asset drag&drop e.g., the caller code manages instantiation itself.
+     */
+    return;
+  }
+
   LinkNode *itemlink;
   Collection *active_collection = NULL;
   const bool do_obdata = (lapp_data->flag & FILE_OBDATA_INSTANCE) != 0;
@@ -1281,6 +1287,10 @@ static ID *wm_file_link_append_datablock_ex(Main *bmain,
   return id;
 }
 
+/*
+ * NOTE: `scene` (and related `view_layer` and `v3d`) pointers may be NULL, in which case no
+ * instantiation of linked objects, collections etc. will be performed.
+ */
 ID *WM_file_link_datablock(Main *bmain,
                            Scene *scene,
                            ViewLayer *view_layer,
@@ -1293,6 +1303,10 @@ ID *WM_file_link_datablock(Main *bmain,
       bmain, scene, view_layer, v3d, filepath, id_code, id_name, false);
 }
 
+/*
+ * NOTE: `scene` (and related `view_layer` and `v3d`) pointers may be NULL, in which case no
+ * instantiation of appended objects, collections etc. will be performed.
+ */
 ID *WM_file_append_datablock(Main *bmain,
                              Scene *scene,
                              ViewLayer *view_layer,



More information about the Bf-blender-cvs mailing list