Fix T56273: User count assert on re-saving a particular file.

new background image/clip of Camera ID was totally wrong, down the old,
broken 'way it used to be' instead of using new, more generic system.

Those ID pointers were not even added to library_query.c file, shame! xD
This commit is contained in:
Bastien Montagne 2018-08-08 11:54:58 +02:00
parent 3e0bf69bfd
commit 7a6d7d056b
Notes: blender-bot 2023-02-14 05:28:06 +01:00
Referenced by issue #56270, File crash when trying to save this one
Referenced by issue #56273, User count assert on re-saving a particular file
2 changed files with 9 additions and 18 deletions

View File

@ -108,16 +108,6 @@ void *BKE_camera_add(Main *bmain, const char *name)
void BKE_camera_copy_data(Main *UNUSED(bmain), Camera *cam_dst, const Camera *cam_src, const int flag)
{
BLI_duplicatelist(&cam_dst->bg_images, &cam_src->bg_images);
if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) {
for (CameraBGImage *bgpic = cam_dst->bg_images.first; bgpic; bgpic = bgpic->next) {
if (bgpic->source == CAM_BGIMG_SOURCE_IMAGE) {
id_us_plus((ID *)bgpic->ima);
}
else if (bgpic->source == CAM_BGIMG_SOURCE_MOVIE) {
id_us_plus((ID *)bgpic->clip);
}
}
}
}
Camera *BKE_camera_copy(Main *bmain, const Camera *cam)
@ -135,14 +125,6 @@ void BKE_camera_make_local(Main *bmain, Camera *cam, const bool lib_local)
/** Free (or release) any data used by this camera (does not free the camera itself). */
void BKE_camera_free(Camera *ca)
{
for (CameraBGImage *bgpic = ca->bg_images.first; bgpic; bgpic = bgpic->next) {
if (bgpic->source == CAM_BGIMG_SOURCE_IMAGE) {
id_us_min((ID *)bgpic->ima);
}
else if (bgpic->source == CAM_BGIMG_SOURCE_MOVIE) {
id_us_min((ID *)bgpic->clip);
}
}
BLI_freelistN(&ca->bg_images);
BKE_animdata_free((ID *)ca, false);

View File

@ -682,6 +682,15 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call
{
Camera *camera = (Camera *) id;
CALLBACK_INVOKE(camera->dof_ob, IDWALK_CB_NOP);
for (CameraBGImage *bgpic = camera->bg_images.first; bgpic; bgpic = bgpic->next) {
if (bgpic->source == CAM_BGIMG_SOURCE_IMAGE) {
CALLBACK_INVOKE(bgpic->ima, IDWALK_CB_USER);
}
else if (bgpic->source == CAM_BGIMG_SOURCE_MOVIE) {
CALLBACK_INVOKE(bgpic->clip, IDWALK_CB_USER);
}
}
break;
}