diff options
-rw-r--r-- | source/blender/editors/include/ED_image.h | 2 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_ops.c | 3 | ||||
-rw-r--r-- | source/blender/editors/space_image/image_edit.c | 8 | ||||
-rw-r--r-- | source/blender/editors/space_image/image_ops.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_image/space_image.c | 7 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_space.c | 29 |
6 files changed, 30 insertions, 21 deletions
diff --git a/source/blender/editors/include/ED_image.h b/source/blender/editors/include/ED_image.h index 65ca181e160..01040949a0a 100644 --- a/source/blender/editors/include/ED_image.h +++ b/source/blender/editors/include/ED_image.h @@ -109,7 +109,7 @@ bool ED_space_image_show_uvedit(struct SpaceImage *sima, struct Object *obedit); bool ED_space_image_paint_curve(const struct bContext *C); -bool ED_space_image_check_show_maskedit(struct SpaceImage *sima, struct ViewLayer *view_layer); +bool ED_space_image_check_show_maskedit(struct SpaceImage *sima, struct Object *obedit); bool ED_space_image_maskedit_poll(struct bContext *C); bool ED_space_image_maskedit_mask_poll(struct bContext *C); bool ED_space_image_cursor_poll(struct bContext *C); diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 5730d8b2d03..6ed3ed4020c 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -623,7 +623,8 @@ bool ED_operator_mask(bContext *C) case SPACE_IMAGE: { SpaceImage *sima = area->spacedata.first; ViewLayer *view_layer = CTX_data_view_layer(C); - return ED_space_image_check_show_maskedit(sima, view_layer); + Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer); + return ED_space_image_check_show_maskedit(sima, obedit); } } } diff --git a/source/blender/editors/space_image/image_edit.c b/source/blender/editors/space_image/image_edit.c index 4eb4e6649d9..180f1fb183c 100644 --- a/source/blender/editors/space_image/image_edit.c +++ b/source/blender/editors/space_image/image_edit.c @@ -478,11 +478,10 @@ bool ED_space_image_show_uvedit(SpaceImage *sima, Object *obedit) } /* matches clip function */ -bool ED_space_image_check_show_maskedit(SpaceImage *sima, ViewLayer *view_layer) +bool ED_space_image_check_show_maskedit(SpaceImage *sima, Object *obedit) { /* check editmode - this is reserved for UV editing */ - Object *ob = OBACT(view_layer); - if (ob && ob->mode & OB_MODE_EDIT && ED_space_image_show_uvedit(sima, ob)) { + if (obedit && ED_space_image_show_uvedit(sima, obedit)) { return false; } @@ -495,7 +494,8 @@ bool ED_space_image_maskedit_poll(bContext *C) if (sima) { ViewLayer *view_layer = CTX_data_view_layer(C); - return ED_space_image_check_show_maskedit(sima, view_layer); + Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer); + return ED_space_image_check_show_maskedit(sima, obedit); } return false; diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 1a98ec0e7c1..f312981d0e1 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -899,7 +899,7 @@ static int image_view_selected_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; } } - else if (ED_space_image_check_show_maskedit(sima, view_layer)) { + else if (ED_space_image_check_show_maskedit(sima, obedit)) { if (!ED_mask_selected_minmax(C, min, max)) { return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index a806e3e25d1..aa3f6446d51 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -368,10 +368,9 @@ static void image_listener(wmWindow *win, ScrArea *area, wmNotifier *wmn, Scene } break; case NC_MASK: { - // Scene *scene = wmn->window->screen->scene; - /* ideally would check for: ED_space_image_check_show_maskedit(scene, sima) - * but we cant get the scene */ - if (sima->mode == SI_MODE_MASK) { + ViewLayer *view_layer = WM_window_get_active_view_layer(win); + Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer); + if (ED_space_image_check_show_maskedit(sima, obedit)) { switch (wmn->data) { case ND_SELECT: ED_area_tag_redraw(area); diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 21ba130f925..b30a8e4bbdc 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -1465,11 +1465,14 @@ static bool rna_SpaceImageEditor_show_paint_get(PointerRNA *ptr) static bool rna_SpaceImageEditor_show_uvedit_get(PointerRNA *ptr) { - SpaceImage *sima = (SpaceImage *)(ptr->data); + SpaceImage *sima = ptr->data; bScreen *screen = (bScreen *)ptr->owner_id; + Object *obedit = NULL; wmWindow *win = ED_screen_window_find(screen, G_MAIN->wm.first); - ViewLayer *view_layer = WM_window_get_active_view_layer(win); - Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer); + if (win != NULL) { + ViewLayer *view_layer = WM_window_get_active_view_layer(win); + obedit = OBEDIT_FROM_VIEW_LAYER(view_layer); + } return ED_space_image_show_uvedit(sima, obedit); } @@ -1477,22 +1480,28 @@ static bool rna_SpaceImageEditor_show_maskedit_get(PointerRNA *ptr) { SpaceImage *sima = (SpaceImage *)(ptr->data); bScreen *screen = (bScreen *)ptr->owner_id; + Object *obedit = NULL; wmWindow *win = ED_screen_window_find(screen, G_MAIN->wm.first); - ViewLayer *view_layer = WM_window_get_active_view_layer(win); - return ED_space_image_check_show_maskedit(sima, view_layer); + if (win != NULL) { + ViewLayer *view_layer = WM_window_get_active_view_layer(win); + obedit = OBEDIT_FROM_VIEW_LAYER(view_layer); + } + return ED_space_image_check_show_maskedit(sima, obedit); } static void rna_SpaceImageEditor_image_set(PointerRNA *ptr, PointerRNA value, struct ReportList *UNUSED(reports)) { - SpaceImage *sima = (SpaceImage *)(ptr->data); + BLI_assert(BKE_id_is_in_global_main(value.data)); + SpaceImage *sima = ptr->data; bScreen *screen = (bScreen *)ptr->owner_id; + Object *obedit = NULL; wmWindow *win = ED_screen_window_find(screen, G_MAIN->wm.first); - ViewLayer *view_layer = WM_window_get_active_view_layer(win); - Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer); - - BLI_assert(BKE_id_is_in_global_main(value.data)); + if (win != NULL) { + ViewLayer *view_layer = WM_window_get_active_view_layer(win); + obedit = OBEDIT_FROM_VIEW_LAYER(view_layer); + } ED_space_image_set(G_MAIN, sima, obedit, (Image *)value.data, false); } |