Fix memory leak in sample tool
When there was no image buffer, sample leaked memory.
This commit is contained in:
@@ -312,7 +312,6 @@ static void sequencer_sample_apply(bContext *C, wmOperator *op, const wmEvent *e
|
|||||||
float fx, fy;
|
float fx, fy;
|
||||||
|
|
||||||
if (ibuf == NULL) {
|
if (ibuf == NULL) {
|
||||||
IMB_freeImBuf(ibuf);
|
|
||||||
info->draw = 0;
|
info->draw = 0;
|
||||||
return;
|
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)
|
static void ed_imbuf_sample_apply(bContext *C, wmOperator *op, const wmEvent *event)
|
||||||
{
|
{
|
||||||
ScrArea *sa = CTX_wm_area(C);
|
ScrArea *sa = CTX_wm_area(C);
|
||||||
|
if (sa == NULL) {
|
||||||
if (sa && sa->spacetype == SPACE_IMAGE) {
|
return;
|
||||||
image_sample_apply(C, op, event);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sa && sa->spacetype == SPACE_SEQ) {
|
switch (sa->spacetype) {
|
||||||
sequencer_sample_apply(C, op, event);
|
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)
|
int ED_imbuf_sample_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||||
{
|
{
|
||||||
ARegion *region = CTX_wm_region(C);
|
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->art = region->type;
|
||||||
info->draw_handle = ED_region_draw_cb_activate(
|
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");
|
info->sample_size = RNA_int_get(op->ptr, "size");
|
||||||
op->customdata = info;
|
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);
|
ed_imbuf_sample_apply(C, op, event);
|
||||||
|
|
||||||
WM_event_add_modal_handler(C, op);
|
WM_event_add_modal_handler(C, op);
|
||||||
|
Reference in New Issue
Block a user