Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-01-29 15:43:11 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-01-29 15:53:37 +0300
commit475a07cd0c67c4a72bb042ee5eb2af730bddb9cd (patch)
tree63300f6ec632f59a18ceef437c9114b9e3981b27 /source
parent3b6e4cf7cec8845cf839f10d241c1dcc81eb98b2 (diff)
Fix duplicate brushes from recent startup files
Default versioning caused duplicates when the startup was re-saved. See c305759762aa3
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/BKE_blender_version.h2
-rw-r--r--source/blender/blenkernel/BKE_library.h3
-rw-r--r--source/blender/blenkernel/intern/library.c31
-rw-r--r--source/blender/blenloader/intern/versioning_280.c5
4 files changed, 40 insertions, 1 deletions
diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h
index 8924a938911..2ecf5c45a6c 100644
--- a/source/blender/blenkernel/BKE_blender_version.h
+++ b/source/blender/blenkernel/BKE_blender_version.h
@@ -28,7 +28,7 @@
* and keep comment above the defines.
* Use STRINGIFY() rather than defining with quotes */
#define BLENDER_VERSION 280
-#define BLENDER_SUBVERSION 42
+#define BLENDER_SUBVERSION 43
/* Several breakages with 280, e.g. collections vs layers */
#define BLENDER_MINVERSION 280
#define BLENDER_MINSUBVERSION 0
diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h
index 27f6435e20d..9c358c7177f 100644
--- a/source/blender/blenkernel/BKE_library.h
+++ b/source/blender/blenkernel/BKE_library.h
@@ -195,6 +195,9 @@ void BKE_main_id_clear_newpoins(struct Main *bmain);
void BKE_main_lib_objects_recalc_all(struct Main *bmain);
+/* Only for repairing files via versioning, avoid for general use. */
+void BKE_main_id_repair_duplicate_names_listbase(struct ListBase *lb);
+
#define MAX_ID_FULL_NAME (64 + 64 + 3 + 1) /* 64 is MAX_ID_NAME - 2 */
#define MAX_ID_FULL_NAME_UI (MAX_ID_FULL_NAME + 3) /* Adds 'keycode' two letters at begining. */
void BKE_id_full_name_get(char name[MAX_ID_FULL_NAME], const struct ID *id);
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index 7392dc23119..1583f47adac 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -999,6 +999,37 @@ void BKE_main_id_flag_all(Main *bmain, const int flag, const bool value)
}
}
+void BKE_main_id_repair_duplicate_names_listbase(ListBase *lb)
+{
+ int lb_len = 0;
+ for (ID *id = lb->first; id; id = id->next) {
+ if (id->lib == NULL) {
+ lb_len += 1;
+ }
+ }
+ if (lb_len <= 1) {
+ return;
+ }
+
+ /* Fill an array because renaming sorts. */
+ ID **id_array = MEM_mallocN(sizeof(*id_array) * lb_len, __func__);
+ GSet *gset = BLI_gset_str_new_ex(__func__, lb_len);
+ int i = 0;
+ for (ID *id = lb->first; id; id = id->next) {
+ if (id->lib == NULL) {
+ id_array[i] = id;
+ i++;
+ }
+ }
+ for (i = 0; i < lb_len; i++) {
+ if (!BLI_gset_add(gset, id_array[i]->name + 2)) {
+ new_id(lb, id_array[i], NULL);
+ }
+ }
+ BLI_gset_free(gset, NULL);
+ MEM_freeN(id_array);
+}
+
void BKE_main_lib_objects_recalc_all(Main *bmain)
{
Object *ob;
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index 7c9f627c3f7..c5c234580e6 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -2783,6 +2783,11 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 43)) {
+ ListBase *lb = which_libbase(bmain, ID_BR);
+ BKE_main_id_repair_duplicate_names_listbase(lb);
+ }
+
{
/* Versioning code until next subversion bump goes here. */
}