[gimp] app: avoid inadvertent calls to image actions on file -> revert
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: avoid inadvertent calls to image actions on file -> revert
- Date: Sun, 9 Dec 2012 21:55:40 +0000 (UTC)
commit b348678890a8ee3227ee9868303afc398344187f
Author: Michael Natterer <mitch gimp org>
Date: Sun Dec 9 22:44:33 2012 +0100
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.
app/display/gimpdisplay-foreach.c | 20 ++++++++++++--------
1 files changed, 12 insertions(+), 8 deletions(-)
---
diff --git a/app/display/gimpdisplay-foreach.c b/app/display/gimpdisplay-foreach.c
index 831da9b..e9a2f09 100644
--- a/app/display/gimpdisplay-foreach.c
+++ b/app/display/gimpdisplay-foreach.c
@@ -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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]