app: check selected items changed before running "select-items".
This prevents repeatitively running the same signals when it is useless. In particular, I encountered a case of infinite loops between "floating-selection-changed" and "select-items" ending up infinitely calling each other (then crashing GIMP).
This commit is contained in:
@ -146,6 +146,9 @@ static gint gimp_container_view_real_get_selected (GimpContainerView *view,
|
||||
GList **list,
|
||||
GList **paths);
|
||||
|
||||
static gboolean gimp_container_view_are_selected_items (GimpContainerView *view,
|
||||
GList *items);
|
||||
|
||||
|
||||
G_DEFINE_INTERFACE (GimpContainerView, gimp_container_view, GTK_TYPE_WIDGET)
|
||||
|
||||
@ -632,8 +635,11 @@ gimp_container_view_select_items (GimpContainerView *view,
|
||||
if (gimp_container_frozen (private->container))
|
||||
return TRUE;
|
||||
|
||||
g_signal_emit (view, view_signals[SELECT_ITEMS], 0,
|
||||
viewables, NULL, &success);
|
||||
if (gimp_container_view_are_selected_items (view, viewables))
|
||||
success = TRUE;
|
||||
else
|
||||
g_signal_emit (view, view_signals[SELECT_ITEMS], 0,
|
||||
viewables, NULL, &success);
|
||||
|
||||
return success;
|
||||
}
|
||||
@ -1430,3 +1436,32 @@ gimp_container_view_button_viewable_dropped (GtkWidget *widget,
|
||||
gtk_button_clicked (GTK_BUTTON (widget));
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_container_view_are_selected_items (GimpContainerView *view,
|
||||
GList *items)
|
||||
{
|
||||
GList *selected;
|
||||
gboolean identical = FALSE;
|
||||
|
||||
gimp_container_view_get_selected (view, &selected, NULL);
|
||||
|
||||
if (g_list_length (items) == g_list_length (selected))
|
||||
{
|
||||
GList *iter;
|
||||
|
||||
identical = TRUE;
|
||||
for (iter = items; iter; iter = iter->next)
|
||||
{
|
||||
if (g_list_find (selected, iter->data) == NULL)
|
||||
{
|
||||
identical = FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
g_list_free (selected);
|
||||
|
||||
return identical;
|
||||
}
|
||||
|
Reference in New Issue
Block a user