diff --git a/app/actions/image-actions.c b/app/actions/image-actions.c index 6f188efcc9..9b6e0bd88d 100644 --- a/app/actions/image-actions.c +++ b/app/actions/image-actions.c @@ -381,6 +381,7 @@ void image_actions_update (GimpActionGroup *group, gpointer data) { + Gimp *gimp = action_data_get_gimp (data); GimpImage *image = action_data_get_image (data); gboolean is_indexed = FALSE; gboolean is_u8_gamma = FALSE; @@ -394,6 +395,12 @@ image_actions_update (GimpActionGroup *group, gboolean profile = FALSE; gboolean s_bpc = FALSE; + if (gimp) + { + GimpContext *context = gimp_get_user_context (gimp); + + g_return_if_fail (context && image == gimp_context_get_image (context)); + } #define SET_LABEL(action,label) \ gimp_action_group_set_action_label (group, action, (label)) #define SET_SENSITIVE(action,condition) \ diff --git a/app/display/gimpimagewindow.c b/app/display/gimpimagewindow.c index 13785c5ec8..d2df29ea54 100644 --- a/app/display/gimpimagewindow.c +++ b/app/display/gimpimagewindow.c @@ -1986,10 +1986,29 @@ gimp_image_window_hide_tooltip (GimpUIManager *manager, static gboolean gimp_image_window_update_ui_manager_idle (GimpImageWindow *window) { - GimpImageWindowPrivate *private = GIMP_IMAGE_WINDOW_GET_PRIVATE (window); + GimpImageWindowPrivate *private = GIMP_IMAGE_WINDOW_GET_PRIVATE (window); + GimpImage *active_image = NULL; + GimpContext *context; gimp_assert (private->active_shell != NULL); + context = gimp_get_user_context (private->active_shell->display->gimp); + + if (context) + active_image = gimp_context_get_image (context); + + /* Since we are running idle, it is possible this runs after the + * active display switched, and therefore we may call the wrong + * actions for an image. See #10441. + */ + if ((active_image && + (! private->active_shell->display || ! gimp_display_get_image (private->active_shell->display))) || + active_image != gimp_display_get_image (private->active_shell->display)) + { + private->update_ui_manager_idle_id = 0; + return G_SOURCE_REMOVE; + } + gimp_ui_manager_update (menus_get_image_manager_singleton (private->active_shell->display->gimp), private->active_shell->display);