Index: app/tools/gimptransformtool.c
===================================================================
RCS file: /cvs/gnome/gimp/app/tools/gimptransformtool.c,v
retrieving revision 1.176
diff -u -p -r1.176 gimptransformtool.c
--- app/tools/gimptransformtool.c	19 Oct 2006 17:37:25 -0000	1.176
+++ app/tools/gimptransformtool.c	19 Oct 2006 21:32:51 -0000
@@ -391,9 +391,35 @@ gimp_transform_tool_button_press (GimpTo
                                   GimpDisplay     *display)
 {
   GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tool);
+  GimpTransformOptions *options;
+  GimpItem             *active_item = NULL;
+
+  options = GIMP_TRANSFORM_OPTIONS (tool->tool_info->tool_options);
 
   if (tr_tool->function == TRANSFORM_CREATING)
-    gimp_transform_tool_oper_update (tool, coords, state, TRUE, display);
+    {
+      if (gimp_channel_is_empty (gimp_image_get_mask (display->image))
+          && options->type == GIMP_TRANSFORM_TYPE_LAYER 
+          && tr_tool->direction != GIMP_TRANSFORM_BACKWARD)
+        {
+          active_item = (GimpItem *) gimp_image_active_drawable (display->image);
+          tr_tool->hidden_item = NULL;
+          if (GIMP_IS_LAYER_MASK (active_item))
+            {
+              if (gimp_layer_mask_get_show ((GimpLayerMask *)active_item))
+                tr_tool->hidden_item = active_item;
+              gimp_layer_mask_set_show ((GimpLayerMask *)active_item, FALSE, FALSE);
+            }
+          else if (GIMP_IS_LAYER (active_item) || GIMP_IS_CHANNEL (active_item))
+            {
+              if (gimp_item_get_visible (active_item))
+                tr_tool->hidden_item = active_item;
+              gimp_item_set_visible (active_item, FALSE, FALSE);
+            }
+          gimp_image_flush (display->image);
+        }
+      gimp_transform_tool_oper_update (tool, coords, state, TRUE, display);
+    }
 
   tr_tool->lastx = tr_tool->startx = coords->x;
   tr_tool->lasty = tr_tool->starty = coords->y;
@@ -1401,6 +1427,12 @@ static void
 gimp_transform_tool_halt (GimpTransformTool *tr_tool)
 {
   GimpTool *tool = GIMP_TOOL (tr_tool);
+  GimpTransformOptions *options;
+  GimpItem             *active_item = NULL;
+  GimpDisplay *display = tool->display;
+
+
+
 
   if (gimp_draw_tool_is_active (GIMP_DRAW_TOOL (tr_tool)))
     {
@@ -1423,6 +1455,19 @@ gimp_transform_tool_halt (GimpTransformT
       tr_tool->original = NULL;
     }
 
+  options = GIMP_TRANSFORM_OPTIONS (tool->tool_info->tool_options);
+  if (options->type == GIMP_TRANSFORM_TYPE_LAYER)
+    {
+      active_item = tr_tool->hidden_item;
+      if (active_item && GIMP_IS_LAYER_MASK (active_item))
+        gimp_layer_mask_set_show ((GimpLayerMask *)active_item, TRUE, FALSE);
+      else if (active_item && (GIMP_IS_LAYER (active_item) || GIMP_IS_CHANNEL (active_item)))
+        gimp_item_set_visible (active_item, TRUE, FALSE);
+      tr_tool->hidden_item = NULL;
+      if (display)
+        gimp_image_flush (display->image);
+    }
+
   /*  inactivate the tool  */
   tr_tool->function = TRANSFORM_CREATING;
 
@@ -1434,6 +1479,7 @@ gimp_transform_tool_halt (GimpTransformT
 
   tool->display  = NULL;
   tool->drawable = NULL;
+  
 }
 
 static void
Index: app/tools/gimptransformtool.h
===================================================================
RCS file: /cvs/gnome/gimp/app/tools/gimptransformtool.h,v
retrieving revision 1.44
diff -u -p -r1.44 gimptransformtool.h
--- app/tools/gimptransformtool.h	5 Sep 2006 18:25:30 -0000	1.44
+++ app/tools/gimptransformtool.h	19 Oct 2006 21:32:51 -0000
@@ -93,7 +93,9 @@ struct _GimpTransformTool
 
   GimpTransformType       type;
   GimpTransformDirection  direction;
-
+  GimpItem       *hidden_item;   /* If NULL, active item was initially hidden
+                                  * otherwise contains value of active layer, 
+                                  * layer mask, or channel to be reshown. */
   const gchar    *undo_desc;
 
   const gchar    *shell_desc;
