Fix T99493: better syncing between Node Editor and Image Editor

Since {rBb0cb0a785475}, changing the active texture in the Node Editor
would also change the current image in the Image Editor.
While this was an overall improvement, this was not desired when the
image currently looked at was a `Render Result` or a `Viewer Node`
(artists usually want to keep focus on these).

With this patch, syncing the active texture change from the Node Editor
to the Image Editor will now only happen if the Image Editor's current
image is not a Render Result or a Viewer Node.

NOTE: Syncing the active paint slot to the Image Editor still happens
(even if the Image Editor's current image is not a Render Result or a
Viewer Node), behavior was not changed since this is a much more
explicit action while texture painting and probably desired in that
case.

Maniphest Tasks: T99493

Differential Revision: https://developer.blender.org/D15749
This commit is contained in:
Philipp Oeser 2022-08-22 10:07:03 +02:00
parent 5d67b52441
commit c76d7f7bde
Notes: blender-bot 2023-02-14 03:31:57 +01:00
Referenced by commit 62bd007646, Fix T100590: Crash when changing active image texture node
Referenced by issue #100590, Crash when changing active image texture node
Referenced by issue #99493, Don't affect Render Result when switching image editors to an active image
Referenced by issue #94456, Render result image is missing the pin button.
1 changed files with 13 additions and 6 deletions

View File

@ -729,19 +729,26 @@ void ED_node_set_active(
}
}
/* Sync to Image Editor. */
/* Sync to Image Editor under the following conditions:
* - current image is not pinned
* - current image is not a Render Result or ViewerNode (want to keep looking at these) */
Image *image = (Image *)node->id;
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) {
SpaceImage *sima = (SpaceImage *)sl;
if (!sima->pin) {
ED_space_image_set(bmain, sima, image, true);
}
if (sl->spacetype != SPACE_IMAGE) {
continue;
}
SpaceImage *sima = (SpaceImage *)sl;
if (sima->pin) {
continue;
}
if (ELEM(sima->image->type, IMA_TYPE_R_RESULT, IMA_TYPE_COMPOSITE)) {
continue;
}
ED_space_image_set(bmain, sima, image, true);
}
}
}