[gimp/soc-2011-seamless-clone2] app: avoid inadvertent calls to image actions on file -> revert
- From: Clayton Walker <claytonw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/soc-2011-seamless-clone2] app: avoid inadvertent calls to image actions on file -> revert
- Date: Wed, 8 May 2013 14:51:05 +0000 (UTC)
commit 853f1b005f77e3a578f1c2ada701480ddd5015b4
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]