[Bf-blender-cvs] [8a73b03fddb] readfile-rework-refcount-handling: Fix crash on undo case.
Bastien Montagne
noreply at git.blender.org
Fri Feb 14 14:55:44 CET 2020
Commit: 8a73b03fddbcb822433621015546d5e8e8402932
Author: Bastien Montagne
Date: Fri Feb 14 14:53:46 2020 +0100
Branches: readfile-rework-refcount-handling
https://developer.blender.org/rB8a73b03fddbcb822433621015546d5e8e8402932
Fix crash on undo case.
We cannot use libquery too early in undo case, because of all the black
magic we perform over our data-blocks there...
===================================================================
M source/blender/blenkernel/intern/blendfile.c
M source/blender/blenloader/intern/readfile.c
===================================================================
diff --git a/source/blender/blenkernel/intern/blendfile.c b/source/blender/blenkernel/intern/blendfile.c
index 5cbcb09f293..efab2039dc3 100644
--- a/source/blender/blenkernel/intern/blendfile.c
+++ b/source/blender/blenkernel/intern/blendfile.c
@@ -364,6 +364,16 @@ static void setup_app_data(bContext *C,
/* TODO(sergey): Can this be also move above? */
RE_FreeAllPersistentData();
}
+
+ if (mode == LOAD_UNDO) {
+ /* In undo/redo case, we do a whole lot of magic tricks to avoid having to re-read linked
+ * data-blocks from libraries (since those are not supposed to change). Unfortunately, that
+ * means that we do not reset their user count, however we do increase that one when doing
+ * lib_link on local IDs using linked ones.
+ * There is no real way to predict amount of changes here, so we have to fully redo
+ * refcounting . */
+ BKE_main_id_refcount_recompute(bmain, false);
+ }
}
static void setup_app_blend_file_data(bContext *C,
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 9a9611e6542..d3e1eaa3801 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -9527,7 +9527,11 @@ static void lib_link_all(FileData *fd, Main *bmain)
FOREACH_MAIN_ID_END;
TIMEIT_START(readfile_refcount_recomp);
- BKE_main_id_refcount_recompute(bmain, false);
+ /* We cannot do that here in undo case, we play too much with IDs from different memory realms,
+ * and Main database is in pretty bad state currently. */
+ if (fd->memfile == NULL) {
+ BKE_main_id_refcount_recompute(bmain, false);
+ }
TIMEIT_END(readfile_refcount_recomp);
/* Check for possible cycles in scenes' 'set' background property. */
More information about the Bf-blender-cvs
mailing list