[Bf-blender-cvs] [26dac33ce18] master: Cleanup: simplify ED_imbuf_sample_poll
Campbell Barton
noreply at git.blender.org
Wed Oct 6 00:34:07 CEST 2021
Commit: 26dac33ce18f8a5655883b759d271da4a9b94982
Author: Campbell Barton
Date: Wed Oct 6 09:29:09 2021 +1100
Branches: master
https://developer.blender.org/rB26dac33ce18f8a5655883b759d271da4a9b94982
Cleanup: simplify ED_imbuf_sample_poll
Access the space data directly from the area.
Also remove redundant NULL check.
===================================================================
M source/blender/editors/util/ed_util_imbuf.c
===================================================================
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;
More information about the Bf-blender-cvs
mailing list