Fix image-space mask-transform crash w/o an image

This commit is contained in:
Campbell Barton 2016-04-20 09:37:51 +10:00
parent 2ca4d21976
commit 38442ae2dc
Notes: blender-bot 2024-03-25 12:30:38 +01:00
Referenced by issue #48310, Move Mask will be crash if no image loaded
1 changed files with 9 additions and 3 deletions

View File

@ -4494,13 +4494,17 @@ void BKE_image_get_size(Image *image, ImageUser *iuser, int *width, int *height)
ImBuf *ibuf = NULL;
void *lock;
ibuf = BKE_image_acquire_ibuf(image, iuser, &lock);
if (image != NULL) {
ibuf = BKE_image_acquire_ibuf(image, iuser, &lock);
}
if (ibuf && ibuf->x > 0 && ibuf->y > 0) {
*width = ibuf->x;
*height = ibuf->y;
}
else if (image->type == IMA_TYPE_R_RESULT && iuser != NULL && iuser->scene != NULL) {
else if (image != NULL && image->type == IMA_TYPE_R_RESULT &&
iuser != NULL && iuser->scene != NULL)
{
Scene *scene = iuser->scene;
*width = (scene->r.xsch * scene->r.size) / 100;
*height = (scene->r.ysch * scene->r.size) / 100;
@ -4514,7 +4518,9 @@ void BKE_image_get_size(Image *image, ImageUser *iuser, int *width, int *height)
*height = IMG_SIZE_FALLBACK;
}
BKE_image_release_ibuf(image, ibuf, lock);
if (image != NULL) {
BKE_image_release_ibuf(image, ibuf, lock);
}
}
void BKE_image_get_size_fl(Image *image, ImageUser *iuser, float size[2])