Index: plug-ins/common/warp.c
===================================================================
RCS file: /cvs/gnome/gimp/plug-ins/common/warp.c,v
retrieving revision 1.67
diff -u -p -r1.67 warp.c
--- plug-ins/common/warp.c	21 Jun 2006 10:22:14 -0000	1.67
+++ plug-ins/common/warp.c	21 Jun 2006 11:01:08 -0000
@@ -111,6 +111,7 @@ typedef struct
  * Function prototypes.
  */
 
+static void      quit   (void);
 static void      query  (void);
 static void      run    (const gchar      *name,
 			 gint              nparams,
@@ -169,7 +170,7 @@ static gdouble   warp_map_mag_give_value
 const GimpPlugInInfo PLUG_IN_INFO =
 {
   NULL,  /* init_proc  */
-  NULL,  /* quit_proc  */
+  quit,  /* quit_proc  */
   query, /* query_proc */
   run,   /* run_proc   */
 };
@@ -198,6 +199,7 @@ static gint         progress = 0;       
 static guint        tile_width, tile_height;   /* size of an image tile       */
 static GimpRunMode  run_mode;                  /* interactive, non-, etc.     */
 static guchar       color_pixel[4] = {0, 0, 0, 255};  /* current fg color     */
+static gint32       temp_image_ID  = -1;       /* image holding diff.  layers */
 
 /* -------------------------------------------------------------------------- */
 
@@ -206,6 +208,15 @@ static guchar       color_pixel[4] = {0,
 MAIN ()
 
 static void
+quit (void)
+{
+  g_printerr ("warp: quit (%d)\n", temp_image_ID);
+
+  if (temp_image_ID != -1)
+    gimp_image_delete (temp_image_ID);
+}
+
+static void
 query (void)
 {
   static const GimpParamDef args[] =
@@ -865,7 +876,6 @@ diff (GimpDrawable *drawable,
   GimpDrawable *draw_xd, *draw_yd; /* vector disp. drawables */
   GimpDrawable *mdraw, *vdraw, *gdraw;
   gint32 image_id;                 /* image holding X and Y diff. arrays */
-  gint32 new_image_id;             /* image holding X and Y diff. layers */
   gint32 layer_active;             /* currently active layer */
   gint32 xlayer_id, ylayer_id;     /* individual X and Y layer ID numbers */
   GimpPixelRgn srcPR, destxPR, destyPR;
@@ -939,21 +949,21 @@ diff (GimpDrawable *drawable,
   layer_active = gimp_image_get_active_layer (image_id);
 
   /* create new image for X,Y diff */
-  new_image_id = gimp_image_new (width, height, GIMP_RGB);
+  temp_image_ID = gimp_image_new (width, height, GIMP_RGB);
 
-  xlayer_id = gimp_layer_new (new_image_id, "Warp_X_Vectors",
+  xlayer_id = gimp_layer_new (temp_image_ID, "Warp_X_Vectors",
                               width, height,
                               GIMP_RGB_IMAGE, 100.0, GIMP_NORMAL_MODE);
 
-  ylayer_id = gimp_layer_new (new_image_id, "Warp_Y_Vectors",
+  ylayer_id = gimp_layer_new (temp_image_ID, "Warp_Y_Vectors",
                               width, height,
                               GIMP_RGB_IMAGE, 100.0, GIMP_NORMAL_MODE);
 
   draw_yd = gimp_drawable_get (ylayer_id);
   draw_xd = gimp_drawable_get (xlayer_id);
 
-  gimp_image_add_layer (new_image_id, xlayer_id, 1);
-  gimp_image_add_layer (new_image_id, ylayer_id, 1);
+  gimp_image_add_layer (temp_image_ID, xlayer_id, 1);
+  gimp_image_add_layer (temp_image_ID, ylayer_id, 1);
   gimp_drawable_fill (xlayer_id, GIMP_BACKGROUND_FILL);
   gimp_drawable_fill (ylayer_id, GIMP_BACKGROUND_FILL);
   gimp_image_set_active_layer (image_id, layer_active);
@@ -1221,7 +1231,6 @@ warp (GimpDrawable *orig_draw)
   gint          x1, y1, x2, y2;
   gint32        xdlayer = -1;
   gint32        ydlayer = -1;
-  gint32        image_ID;
 
   /* index var. over all "warp" Displacement iterations */
   gint          warp_iter;
@@ -1268,12 +1277,14 @@ warp (GimpDrawable *orig_draw)
       first_time = FALSE;
     }
 
-  image_ID = gimp_drawable_get_image (map_x->drawable_id);
-
   gimp_drawable_detach (map_x);
   gimp_drawable_detach (map_y);
 
-  gimp_image_delete (image_ID);
+  if (temp_image_ID != -1)
+    {
+      gimp_image_delete (temp_image_ID);
+      temp_image_ID = -1;
+    }
 }
 
 /* -------------------------------------------------------------------------- */
