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
4 changed files with 8 additions and 12 deletions

@ -3611,7 +3611,9 @@ bool BKE_image_has_loaded_ibuf(Image *image)
return has_loaded_ibuf; 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 *BKE_image_get_ibuf_with_name(Image *image, const char *name)
{ {
ImBuf *ibuf = NULL; ImBuf *ibuf = NULL;
@ -3635,7 +3637,8 @@ ImBuf *BKE_image_get_ibuf_with_name(Image *image, const char *name)
return ibuf; 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 * TODO(sergey): This is actually "get first entry from the cache", which is
* not so much predictable. But using first loaded image buffer * not so much predictable. But using first loaded image buffer

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

@ -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; return 1;
} }

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