diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-10-06 01:29:09 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-10-06 01:29:09 +0300 |
commit | 26dac33ce18f8a5655883b759d271da4a9b94982 (patch) | |
tree | 0811cf6aa44cc5a9da197728f31f939ecae1d0b6 /source/blender/editors/util | |
parent | 6d2b486e431dae57536a5a7d9b64c62144754363 (diff) |
Cleanup: simplify ED_imbuf_sample_poll
Access the space data directly from the area.
Also remove redundant NULL check.
Diffstat (limited to 'source/blender/editors/util')
-rw-r--r-- | source/blender/editors/util/ed_util_imbuf.c | 51 |
1 files changed, 26 insertions, 25 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; - } + ScrArea *area = CTX_wm_area(C); + if (area == 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)) { + 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; } - else if (sima->mode != SI_MODE_VIEW) { - return false; - } + case SPACE_SEQ: { + SpaceSeq *sseq = area->spacedata.first; - return true; - } - - if (sa && sa->spacetype == SPACE_SEQ) { - SpaceSeq *sseq = CTX_wm_space_seq(C); - - if (sseq->mainb != SEQ_DRAW_IMG_IMBUF) { - return false; + if (sseq->mainb != SEQ_DRAW_IMG_IMBUF) { + return false; + } + if (SEQ_editing_get(CTX_data_scene(C)) == NULL) { + return false; + } + return true; } - - return sseq && SEQ_editing_get(CTX_data_scene(C)) != NULL; } return false; |