Fix T38045: Clone stamp crashes

Issue seems to be caused by thread-unsafe IMB_freeImBuf.
Now use generic BKE_image_release_ibuf to de-reference
image buffer which was acquired from image datablock.
This commit is contained in:
Sergey Sharybin 2014-01-03 23:00:53 +06:00
parent 56a531eb29
commit 0dabf824fb
Notes: blender-bot 2023-02-14 11:24:02 +01:00
Referenced by issue #38045, clone stamp crashes
4 changed files with 8 additions and 12 deletions

View File

@ -3611,7 +3611,9 @@ bool BKE_image_has_loaded_ibuf(Image *image)
return has_loaded_ibuf;
}
/* References the result, IMB_freeImBuf is to be called to de-reference. */
/* References the result, BKE_image_release_ibuf is to be called to de-reference.
* Use lock=NULL when calling BKE_image_release_ibuf().
*/
ImBuf *BKE_image_get_ibuf_with_name(Image *image, const char *name)
{
ImBuf *ibuf = NULL;
@ -3635,7 +3637,8 @@ ImBuf *BKE_image_get_ibuf_with_name(Image *image, const char *name)
return ibuf;
}
/* References the result, IMB_freeImBuf is to be called to de-reference.
/* References the result, BKE_image_release_ibuf is to be called to de-reference.
* Use lock=NULL when calling BKE_image_release_ibuf().
*
* TODO(sergey): This is actually "get first entry from the cache", which is
* not so much predictable. But using first loaded image buffer

View File

@ -250,7 +250,6 @@ void ED_image_undo_restore(bContext *C, ListBase *lb)
for (tile = lb->first; tile; tile = tile->next) {
short use_float;
bool need_release = true;
/* find image based on name, pointer becomes invalid with global undo */
if (ima && strcmp(tile->idname, ima->id.name) == 0) {
@ -269,7 +268,6 @@ void ED_image_undo_restore(bContext *C, ListBase *lb)
* matched file name in list of already loaded images */
BKE_image_release_ibuf(ima, ibuf, NULL);
need_release = false;
ibuf = BKE_image_get_ibuf_with_name(ima, tile->ibufname);
}
@ -300,12 +298,7 @@ void ED_image_undo_restore(bContext *C, ListBase *lb)
ibuf->userflags |= IB_MIPMAP_INVALID; /* force mipmap recreatiom */
ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID;
if (need_release) {
BKE_image_release_ibuf(ima, ibuf, NULL);
}
else {
IMB_freeImBuf(ibuf);
}
BKE_image_release_ibuf(ima, ibuf, NULL);
}
IMB_freeImBuf(tmpibuf);

View File

@ -598,7 +598,7 @@ static bool project_paint_PickColor(const ProjPaintState *ps, const float pt[2],
}
}
}
IMB_freeImBuf(ibuf);
BKE_image_release_ibuf(ima, ibuf, NULL);
return 1;
}

View File

@ -187,7 +187,7 @@ void GPU_render_text(MTFace *tface, int mode,
}
glPopMatrix();
IMB_freeImBuf(first_ibuf);
BKE_image_release_ibuf(ima, first_ibuf, NULL);
}
}