[Bf-blender-cvs] [de27925aeab] master: Fix (unreported) inconsistent `name_map` during file reading.

Bastien Montagne noreply at git.blender.org
Thu Nov 24 17:09:25 CET 2022


Commit: de27925aeabf45e057734426626374450eb89740
Author: Bastien Montagne
Date:   Thu Nov 24 16:45:48 2022 +0100
Branches: master
https://developer.blender.org/rBde27925aeabf45e057734426626374450eb89740

Fix (unreported) inconsistent `name_map` during file reading.

Swapping some ID lists between Mains must invalidate the name_map cache.

Note that in theory, at least WM type could be ignored by name_map
cache, since it is a singleton. However, don't think it's worth adding
extra complication here, for really marginal benefits. The overhead of
rebuilding the name cache here is extremly small.

For some reason, this issue did not show so far in master, only appeared
in some branch work on improving (in)direct status of linked IDs... Go
figure.

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

M	source/blender/blenkernel/intern/blendfile.c
M	source/blender/windowmanager/intern/wm_files.c

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

diff --git a/source/blender/blenkernel/intern/blendfile.c b/source/blender/blenkernel/intern/blendfile.c
index 8b0d3f2e92e..fb50de47881 100644
--- a/source/blender/blenkernel/intern/blendfile.c
+++ b/source/blender/blenkernel/intern/blendfile.c
@@ -42,6 +42,7 @@
 #include "BKE_lib_id.h"
 #include "BKE_lib_override.h"
 #include "BKE_main.h"
+#include "BKE_main_namemap.h"
 #include "BKE_preferences.h"
 #include "BKE_report.h"
 #include "BKE_scene.h"
@@ -212,6 +213,12 @@ static void setup_app_data(bContext *C,
     SWAP(ListBase, bmain->wm, bfd->main->wm);
     SWAP(ListBase, bmain->workspaces, bfd->main->workspaces);
     SWAP(ListBase, bmain->screens, bfd->main->screens);
+    if (bmain->name_map != NULL) {
+      BKE_main_namemap_destroy(&bmain->name_map);
+    }
+    if (bfd->main->name_map != NULL) {
+      BKE_main_namemap_destroy(&bfd->main->name_map);
+    }
 
     /* In case of actual new file reading without loading UI, we need to regenerate the session
      * uuid of the UI-related datablocks we are keeping from previous session, otherwise their uuid
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index dd3f6db6297..af16f40ff92 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -206,6 +206,9 @@ static void wm_window_match_init(bContext *C, ListBase *wmlist)
   }
 
   BLI_listbase_clear(&G_MAIN->wm);
+  if (G_MAIN->name_map != NULL) {
+    BKE_main_namemap_destroy(&G_MAIN->name_map);
+  }
 
   /* reset active window */
   CTX_wm_window_set(C, active_win);



More information about the Bf-blender-cvs mailing list