Commit b3486788 authored by Michael Natterer's avatar Michael Natterer 😴

app: avoid inadvertent calls to image actions on file -> revert

When reverting, we load a new image into the old image's existing
displays, and replace all references to the old image by the new image
in all GimpContext instances. We used to first update the displays and
then the contexts, which would shortly produce an inconsistent state
where the contexts were out of sync. When updating the displays with
the new image, we sometimes call menu update functions which would
then use that old image from the context when they should use the new
one, and thus triggered callbacks as if the user had activated a menu
(like image -> precision). To fix this, update the contexts before the
displays. It is also more logical to first update model objects and
then view objects.
parent 4b85c9e2
......@@ -204,7 +204,7 @@ gimp_displays_reconnect (Gimp *gimp,
g_return_if_fail (GIMP_IS_IMAGE (old));
g_return_if_fail (GIMP_IS_IMAGE (new));
/* remember which contexts refer to old_image */
/* check which contexts refer to old_image */
for (list = gimp->context_list; list; list = g_list_next (list))
{
GimpContext *context = list->data;
......@@ -213,6 +213,17 @@ gimp_displays_reconnect (Gimp *gimp,
contexts = g_list_prepend (contexts, list->data);
}
/* set the new_image on the remembered contexts (in reverse order,
* since older contexts are usually the parents of newer
* ones). Also, update the contexts before the displays, or we
* might run into menu update functions that would see an
* inconsistent state (display = new, context = old), and thus
* inadvertently call actions as if the user had selected a menu
* item.
*/
g_list_foreach (contexts, (GFunc) gimp_context_set_image, new);
g_list_free (contexts);
for (list = gimp_get_display_iter (gimp);
list;
list = g_list_next (list))
......@@ -222,13 +233,6 @@ gimp_displays_reconnect (Gimp *gimp,
if (gimp_display_get_image (display) == old)
gimp_display_set_image (display, new);
}
/* set the new_image on the remembered contexts (in reverse
* order, since older contexts are usually the parents of
* newer ones)
*/
g_list_foreach (contexts, (GFunc) gimp_context_set_image, new);
g_list_free (contexts);
}
gint
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment