Fix duplicate brushes from recent startup files
Default versioning caused duplicates when the startup was re-saved.
See c305759762
This commit is contained in:
parent
3b6e4cf7ce
commit
475a07cd0c
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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. */
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue