From 1d71f82033f1ec3ad51195cfa64c59fcf0cd6ccc Mon Sep 17 00:00:00 2001 From: Edward Date: Tue, 8 Nov 2022 14:28:44 +0100 Subject: Texture Paint: sync adding a new texture slot to the Image Editor When changing the texture paint slot index or activating a Texture Node, the texture displayed in the Image Editor changes accordingly. This patch syncs the Image Editor when a new texture paint slot was added, which currently is not the case. Also deduplicates some code. --- source/blender/editors/space_image/image_edit.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'source/blender/editors/space_image/image_edit.c') diff --git a/source/blender/editors/space_image/image_edit.c b/source/blender/editors/space_image/image_edit.c index 0122e509c3b..68b1a9e4466 100644 --- a/source/blender/editors/space_image/image_edit.c +++ b/source/blender/editors/space_image/image_edit.c @@ -67,6 +67,30 @@ void ED_space_image_set(Main *bmain, SpaceImage *sima, Image *ima, bool automati WM_main_add_notifier(NC_SPACE | ND_SPACE_IMAGE, NULL); } +void ED_space_image_sync(struct Main *bmain, struct Image *image, bool ignore_render_viewer) +{ + wmWindowManager *wm = (wmWindowManager *)bmain->wm.first; + LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { + const bScreen *screen = WM_window_get_active_screen(win); + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { + if (sl->spacetype != SPACE_IMAGE) { + continue; + } + SpaceImage *sima = (SpaceImage *)sl; + if (sima->pin) { + continue; + } + if (ignore_render_viewer && sima->image && + ELEM(sima->image->type, IMA_TYPE_R_RESULT, IMA_TYPE_COMPOSITE)) { + continue; + } + ED_space_image_set(bmain, sima, image, true); + } + } + } +} + void ED_space_image_auto_set(const bContext *C, SpaceImage *sima) { if (sima->mode != SI_MODE_UV || sima->pin) { -- cgit v1.2.3