From 26dac33ce18f8a5655883b759d271da4a9b94982 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 6 Oct 2021 09:29:09 +1100 Subject: [PATCH] Cleanup: simplify ED_imbuf_sample_poll Access the space data directly from the area. Also remove redundant NULL check. --- source/blender/editors/util/ed_util_imbuf.c | 55 +++++++++++---------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/source/blender/editors/util/ed_util_imbuf.c b/source/blender/editors/util/ed_util_imbuf.c index fcbc0807893..d57640e16dc 100644 --- a/source/blender/editors/util/ed_util_imbuf.c +++ b/source/blender/editors/util/ed_util_imbuf.c @@ -535,37 +535,38 @@ void ED_imbuf_sample_cancel(bContext *C, wmOperator *op) bool ED_imbuf_sample_poll(bContext *C) { - ScrArea *sa = CTX_wm_area(C); - - if (sa && sa->spacetype == SPACE_IMAGE) { - SpaceImage *sima = CTX_wm_space_image(C); - if (sima == NULL) { - return false; - } - - Object *obedit = CTX_data_edit_object(C); - if (obedit) { - /* Disable when UV editing so it doesn't swallow all click events - * (use for setting cursor). */ - if (ED_space_image_show_uvedit(sima, obedit)) { - return false; - } - } - else if (sima->mode != SI_MODE_VIEW) { - return false; - } - - return true; + ScrArea *area = CTX_wm_area(C); + if (area == NULL) { + return false; } - if (sa && sa->spacetype == SPACE_SEQ) { - SpaceSeq *sseq = CTX_wm_space_seq(C); - - if (sseq->mainb != SEQ_DRAW_IMG_IMBUF) { - return false; + switch (area->spacetype) { + case SPACE_IMAGE: { + SpaceImage *sima = area->spacedata.first; + Object *obedit = CTX_data_edit_object(C); + if (obedit) { + /* Disable when UV editing so it doesn't swallow all click events + * (use for setting cursor). */ + if (ED_space_image_show_uvedit(sima, obedit)) { + return false; + } + } + else if (sima->mode != SI_MODE_VIEW) { + return false; + } + return true; } + case SPACE_SEQ: { + SpaceSeq *sseq = area->spacedata.first; - return sseq && SEQ_editing_get(CTX_data_scene(C)) != NULL; + if (sseq->mainb != SEQ_DRAW_IMG_IMBUF) { + return false; + } + if (SEQ_editing_get(CTX_data_scene(C)) == NULL) { + return false; + } + return true; + } } return false;