mirror of https://github.com/GNOME/gimp.git
app: fix selected layers in duplicated image.
This seems to have been broken since much longer, but it only made a problem with recent changes. Since we were duplicating layer groups and contents layers at once, the current code could not keep layer selection other than at root level in a duplicated image. Use the layer paths to make sure we select exactly the right copied layers, since the path should not change in a fully duplicated image.
This commit is contained in:
parent
257ada495f
commit
dadae644bf
|
@ -225,13 +225,19 @@ static GList *
|
|||
gimp_image_duplicate_layers (GimpImage *image,
|
||||
GimpImage *new_image)
|
||||
{
|
||||
GList *new_selected_layers = NULL;
|
||||
GList *selected_layers;
|
||||
GList *list;
|
||||
gint count;
|
||||
GList *new_selected_layers = NULL;
|
||||
GList *selected_paths = NULL;
|
||||
GList *selected_layers;
|
||||
GimpItemStack *new_item_stack;
|
||||
GList *list;
|
||||
gint count;
|
||||
|
||||
selected_layers = gimp_image_get_selected_layers (image);
|
||||
|
||||
for (list = selected_layers; list; list = list->next)
|
||||
selected_paths = g_list_prepend (selected_paths,
|
||||
gimp_item_get_path (list->data));
|
||||
|
||||
for (list = gimp_image_get_layer_iter (image), count = 0;
|
||||
list;
|
||||
list = g_list_next (list))
|
||||
|
@ -252,13 +258,17 @@ gimp_image_duplicate_layers (GimpImage *image,
|
|||
gimp_object_set_name (GIMP_OBJECT (new_layer->mask),
|
||||
gimp_object_get_name (layer->mask));
|
||||
|
||||
if (g_list_find (selected_layers, layer))
|
||||
new_selected_layers = g_list_prepend (new_selected_layers, new_layer);
|
||||
|
||||
gimp_image_add_layer (new_image, new_layer,
|
||||
NULL, count++, FALSE);
|
||||
}
|
||||
|
||||
new_item_stack = GIMP_ITEM_STACK (gimp_image_get_layers (new_image));
|
||||
for (list = selected_paths; list; list = list->next)
|
||||
new_selected_layers = g_list_prepend (new_selected_layers,
|
||||
gimp_item_stack_get_item_by_path (new_item_stack, list->data));
|
||||
|
||||
g_list_free_full (selected_paths, (GDestroyNotify) g_list_free);
|
||||
|
||||
return new_selected_layers;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue