[Bf-blender-cvs] [b7432e3a2f3] uuid-undo-experiments: Merge branch 'uuid-undo-experiments-swap-reread-datablocks'.
Bastien Montagne
noreply at git.blender.org
Tue Mar 17 10:54:53 CET 2020
Commit: b7432e3a2f36e150123354792f5495eb842febfd
Author: Bastien Montagne
Date: Tue Mar 17 10:52:51 2020 +0100
Branches: uuid-undo-experiments
https://developer.blender.org/rBb7432e3a2f36e150123354792f5495eb842febfd
Merge branch 'uuid-undo-experiments-swap-reread-datablocks'.
No reasons anymore to keep several branches, we have the 'final' way to
go now.
===================================================================
M release/scripts/startup/bl_ui/space_userpref.py
M source/blender/blenkernel/BKE_lib_id.h
M source/blender/blenkernel/intern/blendfile.c
M source/blender/blenkernel/intern/lib_id.c
M source/blender/blenkernel/intern/scene.c
M source/blender/blenloader/intern/readblenentry.c
M source/blender/blenloader/intern/readfile.c
M source/blender/blenloader/intern/readfile.h
M source/blender/blenloader/intern/writefile.c
M source/blender/depsgraph/DEG_depsgraph.h
M source/blender/depsgraph/intern/depsgraph.cc
M source/blender/depsgraph/intern/depsgraph_tag.cc
M source/blender/editors/undo/memfile_undo.c
M source/blender/makesdna/DNA_ID.h
M source/blender/makesdna/DNA_userdef_types.h
M source/blender/makesrna/intern/rna_userdef.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py
index 6aa0f51c55c..2ca0e73bd74 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -2133,6 +2133,25 @@ class USERPREF_PT_experimental_virtual_reality(ExperimentalPanel, Panel):
"""
+class USERPREF_PT_experimental_system(ExperimentalPanel, Panel):
+ bl_label = "System"
+
+ def draw(self, context):
+ prefs = context.preferences
+ experimental = prefs.experimental
+
+ layout = self.layout
+ layout.use_property_split = True
+ layout.use_property_decorate = False
+
+ task = "T60695"
+ split = layout.split(factor=0.66)
+ col = split.split()
+ col.prop(experimental, "use_undo_speedup")
+ col = split.split()
+ col.operator("wm.url_open", text=task, icon='URL').url = self.url_prefix + task
+
+
# -----------------------------------------------------------------------------
# Class Registration
@@ -2222,6 +2241,8 @@ classes = (
# Popovers.
USERPREF_PT_ndof_settings,
+ USERPREF_PT_experimental_system,
+
# Add dynamically generated editor theme panels last,
# so they show up last in the theme section.
*ThemeGenericClassGenerator.generate_panel_classes_from_theme_areas(),
diff --git a/source/blender/blenkernel/BKE_lib_id.h b/source/blender/blenkernel/BKE_lib_id.h
index 27dd1e637f3..d23465a3f02 100644
--- a/source/blender/blenkernel/BKE_lib_id.h
+++ b/source/blender/blenkernel/BKE_lib_id.h
@@ -217,7 +217,10 @@ bool id_single_user(struct bContext *C,
bool BKE_id_copy_is_allowed(const struct ID *id);
bool BKE_id_copy(struct Main *bmain, const struct ID *id, struct ID **newid);
bool BKE_id_copy_ex(struct Main *bmain, const struct ID *id, struct ID **r_newid, const int flag);
+
void BKE_id_swap(struct Main *bmain, struct ID *id_a, struct ID *id_b);
+void BKE_id_full_swap(struct Main *bmain, struct ID *id_a, struct ID *id_b);
+
void id_sort_by_name(struct ListBase *lb, struct ID *id, struct ID *id_sorting_hint);
void BKE_lib_id_expand_local(struct Main *bmain, struct ID *id);
diff --git a/source/blender/blenkernel/intern/blendfile.c b/source/blender/blenkernel/intern/blendfile.c
index 913f9ea090c..3890bf4e7f8 100644
--- a/source/blender/blenkernel/intern/blendfile.c
+++ b/source/blender/blenkernel/intern/blendfile.c
@@ -374,7 +374,9 @@ static void setup_app_data(bContext *C,
* 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 . */
+ * refcounting.
+ * Now that we re-use (and do not liblink in readfile.c) most local datablocks as well, we have
+ * to recompute refcount for all local IDs too. */
BKE_main_id_refcount_recompute(bmain, false);
}
}
diff --git a/source/blender/blenkernel/intern/lib_id.c b/source/blender/blenkernel/intern/lib_id.c
index a7fa34d9d55..91b6a245d7a 100644
--- a/source/blender/blenkernel/intern/lib_id.c
+++ b/source/blender/blenkernel/intern/lib_id.c
@@ -597,7 +597,7 @@ bool BKE_id_copy(Main *bmain, const ID *id, ID **newid)
* Does a mere memory swap over the whole IDs data (including type-specific memory).
* \note Most internal ID data itself is not swapped (only IDProperties are).
*/
-void BKE_id_swap(Main *bmain, ID *id_a, ID *id_b)
+static void id_swap(Main *bmain, ID *id_a, ID *id_b, const bool do_full_id)
{
BLI_assert(GS(id_a->name) == GS(id_b->name));
@@ -651,17 +651,45 @@ void BKE_id_swap(Main *bmain, ID *id_a, ID *id_b)
#undef CASE_SWAP
- /* Restore original ID's internal data. */
- *id_a = id_a_back;
- *id_b = id_b_back;
+ if (!do_full_id) {
+ /* Restore original ID's internal data. */
+ *id_a = id_a_back;
+ *id_b = id_b_back;
- /* Exception: IDProperties. */
- id_a->properties = id_b_back.properties;
- id_b->properties = id_a_back.properties;
+ /* Exception: IDProperties. */
+ id_a->properties = id_b_back.properties;
+ id_b->properties = id_a_back.properties;
+ }
- /* Swap will have broken internal references to itself, restore them. */
- BKE_libblock_relink_ex(bmain, id_a, id_b, id_a, ID_REMAP_SKIP_NEVER_NULL_USAGE);
- BKE_libblock_relink_ex(bmain, id_b, id_a, id_b, ID_REMAP_SKIP_NEVER_NULL_USAGE);
+ if (bmain != NULL) {
+ /* Swap will have broken internal references to itself, restore them. */
+ BKE_libblock_relink_ex(bmain, id_a, id_b, id_a, ID_REMAP_SKIP_NEVER_NULL_USAGE);
+ BKE_libblock_relink_ex(bmain, id_b, id_a, id_b, ID_REMAP_SKIP_NEVER_NULL_USAGE);
+ }
+}
+
+/**
+ * Does a mere memory swap over the whole IDs data (including type-specific memory).
+ * \note Most internal ID data itself is not swapped (only IDProperties are).
+ *
+ * \param bmain May be NULL, in which case there will be no remapping of internal pointers to
+ * itself.
+ */
+void BKE_id_swap(Main *bmain, ID *id_a, ID *id_b)
+{
+ id_swap(bmain, id_a, id_b, false);
+}
+
+/**
+ * Does a mere memory swap over the whole IDs data (including type-specific memory).
+ * \note All internal ID data itself is also swapped.
+ *
+ * \param bmain May be NULL, in which case there will be no remapping of internal pointers to
+ * itself.
+ */
+void BKE_id_full_swap(Main *bmain, ID *id_a, ID *id_b)
+{
+ id_swap(bmain, id_a, id_b, true);
}
/** Does *not* set ID->newid pointer. */
@@ -2100,9 +2128,6 @@ void BLI_libblock_ensure_unique_name(Main *bmain, const char *name)
BKE_id_new_name_validate(lb, idtest, NULL);
bmain->is_memfile_undo_written = false;
}
-
- /* ID renaming requires an 'undo barrier'. */
- bmain->use_memfile_full_barrier = true;
}
/**
@@ -2114,9 +2139,6 @@ void BKE_libblock_rename(Main *bmain, ID *id, const char *name)
if (BKE_id_new_name_validate(lb, id, name)) {
bmain->is_memfile_undo_written = false;
}
-
- /* ID renaming requires an 'undo barrier'. */
- bmain->use_memfile_full_barrier = true;
}
/**
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 583d90a3c45..ff0232ed9aa 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -2192,7 +2192,9 @@ void BKE_scene_undo_depsgraphs_restore(Main *bmain, GHash *depsgraph_extract)
/* We steal the depsgraph back from our 'extract' storage to the scene. */
Depsgraph *depsgraph = *depsgraph_extract_ptr;
- DEG_graph_update_bmain_pointers(depsgraph, bmain, scene, view_layer);
+ DEG_graph_replace_owners(depsgraph, bmain, scene, view_layer);
+
+ DEG_graph_tag_relations_update(depsgraph);
*depsgraph_scene_ptr = depsgraph;
*depsgraph_extract_ptr = NULL;
diff --git a/source/blender/blenloader/intern/readblenentry.c b/source/blender/blenloader/intern/readblenentry.c
index dbcfee0b690..085e500f7e5 100644
--- a/source/blender/blenloader/intern/readblenentry.c
+++ b/source/blender/blenloader/intern/readblenentry.c
@@ -387,11 +387,7 @@ BlendFileData *BLO_read_from_memfile(Main *oldmain,
if ((params->skip_flags & BLO_READ_SKIP_UNDO_OLD_MAIN) == 0) {
/* Build idmap of old main (we only care about local data here, so we can do that after
* split_main() call. */
- blo_make_idmap_from_main(fd, old_mainlist.first);
-
- /* Create sibling mapping of libmap (i.e. old ID pointer values to new valid IDs), but for
- * the addresses from old main. */
- blo_make_undo_reused_libmap(fd);
+ blo_make_old_idmap_from_main(fd, old_mainlist.first);
}
/* makes lookup of existing images in old main */
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index af0eac0dd79..a94dc94b0f1 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -97,6 +97,7 @@
#include "BLI_endian_switch.h"
#include "BLI_blenlib.h"
+#include "BLI_linklist.h"
#include "BLI_math.h"
#include "BLI_threads.h"
#include "BLI_mempool.h"
@@ -1600,9 +1601,6 @@ void blo_filedata_free(FileData *fd)
if (fd->libmap && !(fd->flags & FD_FLAGS_NOT_MY_LIBMAP)) {
oldnewmap_free(fd->libmap);
}
- if (fd->libmap_undo_reused != NULL) {
- oldnewmap_free(fd->libmap_undo_reused);
- }
if (fd->old_idmap != NULL) {
BKE_main_idmap_destroy(fd->old_idmap);
}
@@ -2225,9 +2223,9 @@ void blo_add_library_pointer_map(ListBase *old_mainlist, FileData *fd)
fd->old_mainlist = old_mainlist;
}
-/* Build idmap of old main (we only care about local data here, so we can do that after
+/* Build a GSet of old main (we only care about local data here, so we can do that after
* split_main() call. */
-void blo_make_idmap_from_main(FileData *fd, Main *bmain)
+void blo_make_old_idmap_from_main(FileData *fd, Main *bmain)
{
if (fd->old_idmap != NULL) {
BKE_main_idmap_destroy(fd->old_idmap);
@@ -2235,13 +2233,6 @@ void blo_make_idmap_from_main(FileData *fd, Main *bmain)
fd->old_idmap = BKE_main_idmap_create(bmain, false, NULL, MAIN_IDMAP_TYPE_UUID);
}
-/* Create sibling mapping of libmap (i.e. old ID pointer values to new valid IDs), but for the
- * addresses from old main. */
-void blo_make_undo_reused_libmap(FileData *fd)
-{
- fd->libmap_undo_reused = oldnewmap_new();
-}
-
/** \} */
/* -------------------------------------------------------------------- */
@@ -2715,17 +2706,17 @@ static void direct_link_id_override_property_cb(FileData *fd, void *data)
link_list_ex(fd, &op->operations, direct_link_id_override_property_operation_cb);
}
-static void direct_link_id(FileData *fd, ID *id);
+static void direct_link_id(FileData *fd, ID *id, ID *id_old);
static void direct_link_nodetree(FileData *fd, bNodeTree *ntree);
static void direct_link_collection(FileData *fd, Collection *collection);
-static void direct_link_id_private_id(FileData *fd, ID *id)
+static void direct_link_id_private_id(FileData *fd, ID *id, ID *id_old)
{
/* Handle 'private IDs'. */
bNodeTree **nodetree = BKE_ntree_ptr_from_id(id);
if (nodetree != NU
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list