Fix T78136: Image editor - crash to desktop with changing the threshold for extract palette

Also fixed the same error in generate GPencil object from image.

The problem was the Render Result image hasn't  ibuf.
This commit is contained in:
Antonio Vazquez 2020-06-22 20:06:28 +02:00
parent 15dda0115c
commit 73d3f51c16
Notes: blender-bot 2023-10-13 01:54:23 +02:00
Referenced by issue #78136, Image editor - crash to desktop with changing the threshold for extract palette
3 changed files with 11 additions and 4 deletions

View File

@ -1813,7 +1813,7 @@ bool BKE_gpencil_from_image(SpaceImage *sima, bGPDframe *gpf, const float size,
ibuf = BKE_image_acquire_ibuf(image, &iuser, &lock);
if (ibuf->rect) {
if (ibuf && ibuf->rect) {
int img_x = ibuf->x;
int img_y = ibuf->y;

View File

@ -55,6 +55,7 @@
#include "BKE_global.h"
#include "BKE_gpencil.h"
#include "BKE_gpencil_geom.h"
#include "BKE_image.h"
#include "BKE_layer.h"
#include "BKE_main.h"
#include "BKE_material.h"
@ -1773,7 +1774,10 @@ static bool image_to_gpencil_poll(bContext *C)
{
SpaceLink *sl = CTX_wm_space_data(C);
if ((sl != NULL) && (sl->spacetype == SPACE_IMAGE)) {
return true;
SpaceImage *sima = CTX_wm_space_image(C);
Image *image = sima->image;
ImageUser iuser = sima->iuser;
return BKE_image_has_ibuf(image, &iuser);
}
return false;

View File

@ -304,7 +304,10 @@ static bool palette_extract_img_poll(bContext *C)
{
SpaceLink *sl = CTX_wm_space_data(C);
if ((sl != NULL) && (sl->spacetype == SPACE_IMAGE)) {
return true;
SpaceImage *sima = CTX_wm_space_image(C);
Image *image = sima->image;
ImageUser iuser = sima->iuser;
return BKE_image_has_ibuf(image, &iuser);
}
return false;
@ -326,7 +329,7 @@ static int palette_extract_img_exec(bContext *C, wmOperator *op)
ibuf = BKE_image_acquire_ibuf(image, &iuser, &lock);
if (ibuf->rect) {
if (ibuf && ibuf->rect) {
/* Extract all colors. */
for (int row = 0; row < ibuf->y; row++) {
for (int col = 0; col < ibuf->x; col++) {