Commit 22690aba authored by Ell's avatar Ell

Issue #5472 - CRITICAL while using Move tool with arrow keys

In gimp_edit_selection_tool_translate(), perform the active-item
checks even when the effective translation offset is 0, and only
bail afterwards.  This avoids erroneously calling
gimp_tool_message_literal() with a NULL message in this case.

(cherry picked from commit 3a462a5e)
parent 0bf0f31a
Pipeline #200103 passed with stages
in 27 minutes and 58 seconds
...@@ -1084,106 +1084,103 @@ gimp_edit_selection_tool_translate (GimpTool *tool, ...@@ -1084,106 +1084,103 @@ gimp_edit_selection_tool_translate (GimpTool *tool,
0); 0);
if (inc_x != 0 || inc_y != 0) switch (translate_type)
{ {
switch (translate_type) case GIMP_TRANSFORM_TYPE_SELECTION:
item = GIMP_ITEM (gimp_image_get_mask (image));
if (gimp_channel_is_empty (GIMP_CHANNEL (item)))
item = NULL;
edit_mode = GIMP_TRANSLATE_MODE_MASK;
undo_type = GIMP_UNDO_GROUP_MASK;
if (! item)
{
/* cannot happen, don't translate this message */
null_message = "There is no selection to move.";
}
else if (gimp_item_is_position_locked (item))
{ {
case GIMP_TRANSFORM_TYPE_SELECTION: /* cannot happen, don't translate this message */
item = GIMP_ITEM (gimp_image_get_mask (image)); locked_message = "The selection's position is locked.";
}
break;
if (gimp_channel_is_empty (GIMP_CHANNEL (item))) case GIMP_TRANSFORM_TYPE_PATH:
item = NULL; item = GIMP_ITEM (gimp_image_get_active_vectors (image));
edit_mode = GIMP_TRANSLATE_MODE_MASK; edit_mode = GIMP_TRANSLATE_MODE_VECTORS;
undo_type = GIMP_UNDO_GROUP_MASK; undo_type = GIMP_UNDO_GROUP_ITEM_DISPLACE;
if (! item) if (! item)
{ {
/* cannot happen, don't translate this message */ null_message = _("There is no path to move.");
null_message = "There is no selection to move."; }
} else if (gimp_item_is_position_locked (item))
else if (gimp_item_is_position_locked (item)) {
{ locked_message = _("The active path's position is locked.");
/* cannot happen, don't translate this message */ }
locked_message = "The selection's position is locked."; break;
}
break; case GIMP_TRANSFORM_TYPE_LAYER:
item = GIMP_ITEM (gimp_image_get_active_drawable (image));
case GIMP_TRANSFORM_TYPE_PATH: undo_type = GIMP_UNDO_GROUP_ITEM_DISPLACE;
item = GIMP_ITEM (gimp_image_get_active_vectors (image));
edit_mode = GIMP_TRANSLATE_MODE_VECTORS; if (! item)
undo_type = GIMP_UNDO_GROUP_ITEM_DISPLACE; {
null_message = _("There is no layer to move.");
}
else if (GIMP_IS_LAYER_MASK (item))
{
edit_mode = GIMP_TRANSLATE_MODE_LAYER_MASK;
if (! item) if (gimp_item_is_position_locked (item))
{ {
null_message = _("There is no path to move."); locked_message = _("The active layer's position is locked.");
} }
else if (gimp_item_is_position_locked (item)) else if (gimp_item_is_content_locked (item))
{ {
locked_message = _("The active path's position is locked."); locked_message = _("The active layer's pixels are locked.");
} }
break; }
else if (GIMP_IS_CHANNEL (item))
case GIMP_TRANSFORM_TYPE_LAYER: {
item = GIMP_ITEM (gimp_image_get_active_drawable (image)); edit_mode = GIMP_TRANSLATE_MODE_CHANNEL;
undo_type = GIMP_UNDO_GROUP_ITEM_DISPLACE;
if (! item) if (gimp_item_is_position_locked (item))
{ {
null_message = _("There is no layer to move."); locked_message = _("The active channel's position is locked.");
} }
else if (GIMP_IS_LAYER_MASK (item)) else if (gimp_item_is_content_locked (item))
{ {
edit_mode = GIMP_TRANSLATE_MODE_LAYER_MASK; locked_message = _("The active channel's pixels are locked.");
if (gimp_item_is_position_locked (item))
{
locked_message = _("The active layer's position is locked.");
}
else if (gimp_item_is_content_locked (item))
{
locked_message = _("The active layer's pixels are locked.");
}
} }
else if (GIMP_IS_CHANNEL (item)) }
else if (gimp_layer_is_floating_sel (GIMP_LAYER (item)))
{
edit_mode = GIMP_TRANSLATE_MODE_FLOATING_SEL;
if (gimp_item_is_position_locked (item))
{ {
edit_mode = GIMP_TRANSLATE_MODE_CHANNEL; locked_message = _("The active layer's position is locked.");
if (gimp_item_is_position_locked (item))
{
locked_message = _("The active channel's position is locked.");
}
else if (gimp_item_is_content_locked (item))
{
locked_message = _("The active channel's pixels are locked.");
}
} }
else if (gimp_layer_is_floating_sel (GIMP_LAYER (item))) }
{ else
edit_mode = GIMP_TRANSLATE_MODE_FLOATING_SEL; {
edit_mode = GIMP_TRANSLATE_MODE_LAYER;
if (gimp_item_is_position_locked (item)) if (gimp_item_is_position_locked (item))
{
locked_message = _("The active layer's position is locked.");
}
}
else
{ {
edit_mode = GIMP_TRANSLATE_MODE_LAYER; locked_message = _("The active layer's position is locked.");
if (gimp_item_is_position_locked (item))
{
locked_message = _("The active layer's position is locked.");
}
} }
}
break; break;
case GIMP_TRANSFORM_TYPE_IMAGE: case GIMP_TRANSFORM_TYPE_IMAGE:
g_return_val_if_reached (FALSE); g_return_val_if_reached (FALSE);
}
} }
if (! item) if (! item)
...@@ -1200,6 +1197,9 @@ gimp_edit_selection_tool_translate (GimpTool *tool, ...@@ -1200,6 +1197,9 @@ gimp_edit_selection_tool_translate (GimpTool *tool,
return TRUE; return TRUE;
} }
if (inc_x == 0 && inc_y == 0)
return TRUE;
switch (edit_mode) switch (edit_mode)
{ {
case GIMP_TRANSLATE_MODE_FLOATING_SEL: case GIMP_TRANSLATE_MODE_FLOATING_SEL:
......
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