Fix broken 'replace object in collection' code.
Code was not handling properly the case where the new object that should replace the old one in given collection is already in the collection. In such case, remove the old object from the collection, but do not attempt to add the new one again.
This commit is contained in:
@@ -1469,11 +1469,16 @@ bool BKE_collection_object_replace(Main *bmain,
|
||||
return false;
|
||||
}
|
||||
|
||||
id_us_min(&cob->ob->id);
|
||||
cob->ob = ob_new;
|
||||
id_us_plus(&cob->ob->id);
|
||||
if (!BLI_ghash_haskey(collection->runtime.gobject_hash, ob_new)) {
|
||||
id_us_min(&cob->ob->id);
|
||||
cob->ob = ob_new;
|
||||
id_us_plus(&cob->ob->id);
|
||||
|
||||
BLI_ghash_insert(collection->runtime.gobject_hash, cob->ob, cob);
|
||||
BLI_ghash_insert(collection->runtime.gobject_hash, cob->ob, cob);
|
||||
}
|
||||
else {
|
||||
collection_object_remove_no_gobject_hash(bmain, collection, cob, false);
|
||||
}
|
||||
|
||||
if (BKE_collection_is_in_scene(collection)) {
|
||||
BKE_main_collection_sync(bmain);
|
||||
|
||||
Reference in New Issue
Block a user