Fix memory leak in sample tool
When there was no image buffer, sample leaked memory.
This commit is contained in:
parent
b74f2c7d74
commit
c4f733a76c
|
@ -312,7 +312,6 @@ static void sequencer_sample_apply(bContext *C, wmOperator *op, const wmEvent *e
|
|||
float fx, fy;
|
||||
|
||||
if (ibuf == NULL) {
|
||||
IMB_freeImBuf(ibuf);
|
||||
info->draw = 0;
|
||||
return;
|
||||
}
|
||||
|
@ -387,13 +386,19 @@ static void sequencer_sample_apply(bContext *C, wmOperator *op, const wmEvent *e
|
|||
static void ed_imbuf_sample_apply(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
{
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
|
||||
if (sa && sa->spacetype == SPACE_IMAGE) {
|
||||
image_sample_apply(C, op, event);
|
||||
if (sa == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (sa && sa->spacetype == SPACE_SEQ) {
|
||||
sequencer_sample_apply(C, op, event);
|
||||
switch (sa->spacetype) {
|
||||
case SPACE_IMAGE: {
|
||||
image_sample_apply(C, op, event);
|
||||
break;
|
||||
}
|
||||
case SPACE_SEQ: {
|
||||
sequencer_sample_apply(C, op, event);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -477,9 +482,29 @@ void ED_imbuf_sample_exit(bContext *C, wmOperator *op)
|
|||
int ED_imbuf_sample_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
{
|
||||
ARegion *region = CTX_wm_region(C);
|
||||
ImageSampleInfo *info;
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
if (sa) {
|
||||
switch (sa->spacetype) {
|
||||
case SPACE_IMAGE: {
|
||||
SpaceImage *sima = sa->spacedata.first;
|
||||
if (region->regiontype == RGN_TYPE_WINDOW) {
|
||||
if (ED_space_image_show_cache_and_mval_over(sima, region, event->mval)) {
|
||||
return OPERATOR_PASS_THROUGH;
|
||||
}
|
||||
}
|
||||
if (!ED_space_image_has_buffer(sima)) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SPACE_SEQ: {
|
||||
/* Sequencer checks could be added. */
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
info = MEM_callocN(sizeof(ImageSampleInfo), "ImageSampleInfo");
|
||||
ImageSampleInfo *info = MEM_callocN(sizeof(ImageSampleInfo), "ImageSampleInfo");
|
||||
|
||||
info->art = region->type;
|
||||
info->draw_handle = ED_region_draw_cb_activate(
|
||||
|
@ -487,21 +512,6 @@ int ED_imbuf_sample_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
|||
info->sample_size = RNA_int_get(op->ptr, "size");
|
||||
op->customdata = info;
|
||||
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
|
||||
if (sa && sa->spacetype == SPACE_IMAGE) {
|
||||
SpaceImage *sima = CTX_wm_space_image(C);
|
||||
if (region->regiontype == RGN_TYPE_WINDOW) {
|
||||
if (ED_space_image_show_cache_and_mval_over(sima, region, event->mval)) {
|
||||
return OPERATOR_PASS_THROUGH;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ED_space_image_has_buffer(sima)) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
}
|
||||
|
||||
ed_imbuf_sample_apply(C, op, event);
|
||||
|
||||
WM_event_add_modal_handler(C, op);
|
||||
|
|
Loading…
Reference in New Issue