Fix BKE_id_move_to_same_lib behavior with invalid parameters.
* Early return in case the given `id` is already in the same library as its target `owner_id` (in addition to both being local data). * Assert with message AND return in case the given `id` is a linked ID from a different library. The second point somewhat mitigates the severity of #130194.
This commit is contained in:
@@ -861,8 +861,14 @@ ID *BKE_id_copy_for_use_in_bmain(Main *bmain, const ID *id)
|
||||
|
||||
void BKE_id_move_to_same_lib(Main &bmain, ID &id, const ID &owner_id)
|
||||
{
|
||||
BLI_assert(id.lib == nullptr);
|
||||
if (owner_id.lib == nullptr) {
|
||||
if (owner_id.lib == id.lib) {
|
||||
/* `id` is already in the target library, nothing to do. */
|
||||
return;
|
||||
}
|
||||
if (ID_IS_LINKED(&id)) {
|
||||
BLI_assert_msg(false, "Only local IDs can be moved into a library");
|
||||
/* Protect release builds against errors in calling code, as continuing here can lead to
|
||||
* critical Main data-base corruption. */
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user